Commit Graph

150 Commits

Author SHA1 Message Date
Mads Kiilerich
b315fbc5ab largefiles: use wlock for lfconvert (issue3444)
largefiles and lfconvert do dirty hacks with dirstate, so to avoid writing that
as a side effect of the wlock release we clear dirstate first.

To avoid confusing lock validation algorithms in error situations we unlock
_before_ removing the target directory.
2012-05-13 17:34:55 +02:00
Na'Tosha Bard
7899056542 largefiles: fix deletion of multiple missing largefiles (issue3329) 2012-05-11 15:32:22 +02:00
Na'Tosha Bard
d4432c172d largefiles: follow normal codepath for addremove if non-largefiles repo (issue3249) 2012-05-11 14:42:26 +02:00
hlian
992a6313f9 largefiles: in putlfile, ensure tempfile's directory exists prior to creation
Let R be a repo served by an hg daemon on a machine with an empty largefiles
cache. Pushing a largefiles repo to R will result in a no-such-file-or-directory
OSError because putlfile will attempt to create a temporary file in
R/.hg/largefiles, which does not yet exist.

This patch also adds a regression test for this scenario.
2012-05-04 14:36:40 -04:00
Patrick Mezard
9b4af94333 largefiles: fix "hg status dir" missing regular files (issue3421)
largefiles status implementation attemps to rewrite the input match objects to
match the "standins" as well as the regular files. When fixing the directories
listed in match.files(), if there was related standin entry, it was kept and
the original path discarded. But directories can appear both as regular and
standin entries.
2012-05-06 13:14:58 +02:00
Na'Tosha Bard
da576e6ebb largefiles: fix commit of both largefiles and non-largefiles (issue3354)
This bug was caused by some old code that should have been removed long ago.
2012-05-03 15:24:45 +02:00
Patrick Mezard
2c65c226cf localrepo: add setparents() to adjust dirstate copies (issue3407)
The fix introduced in 3509b9cf8f86 was only partially successful. It is correct
to turn dirstate 'm' merge records into normal/dirty ones but copy records are
lost in the process. To adjust them as well, we need to look in the first
parent manifest to know which files were added and preserve only related
records. But the dirstate does not have access to changesets, the logic has to
moved at another level, in localrepo.
2012-04-29 22:25:55 +02:00
Matt Harbison
165acc96be largefiles: notice dirty large files in a subrepo
Summary and commit use dirty() to check the status of a subrepository,
so this overrides dirty() in the subrepo in the same manner as
status() to check the large files instead of their standins.

Previously, if only a large file was changed in a subrepo, summary in
the top level repo would not report the subrepo was dirty and commit
-S would report nothing changed.  If any type of file was changed in
the top repo and only a large file in the subrepo, commit -S would not
commit the changes to the subrepo.
2012-04-22 13:19:22 -04:00
Matt Harbison
677d4b2efc largefiles: fix status -S reporting of subrepos (issue3231)
Wrapping the status command will only invoke overridestatus() and set
the lfstatus field for the top level repository.  Wrapping the status
function is required to set the field on child repositories.

Previously, status -S would report large files in a subrepo as '?'
regardless of their actual states, and was inconsistent with what
status would report from within that subrepo.
2012-04-22 03:47:34 -04:00
Martin Geisler
004ba88f28 largefiles: hide .hglf/ prefix for largefiles in hgweb
This makes the manifest view in hgweb match what you see in the
working copy and what you get when you download an archive in hgweb.
2012-04-15 16:05:57 +02:00
Na'Tosha Bard
26cdea9a9e largefiles: fix cat for largefiles (issue3352)
This is a fix to largefiles so that 'hg cat' will work correctly when a
largefile is specified.

As per discussion on Issue 3352:

1) The file will be printed regardless if it is binary or large.
2) The file is downloaded if it is not readily available (not found in
   the system cache), so that it can be printed.  If the download fails,
   then we abort.
2012-04-16 17:03:39 +02:00
Matt Mackall
9b533bc599 merge with stable 2012-03-26 16:42:53 -05:00
FUJIWARA Katsunori
a3e4d70aa4 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
original implementation queries whether specified pattern is related
or not to largefiles in target context by 'dirstate.__contains__()'.

but this can't recognize 'directory pattern' correctly, so this patch
uses 'dirstate.dirs()' for it.

this patch uses dirstate instead of lfdirstate in 'working' route
(second patch hunk for 'hgext/largefiles/reposetup.py'), because
'dirs()' information may be already built for dirstate but not yet for
lfdirstate at this point. this prevents lfdirstate from building up
and having 'dirs()' information.
2012-03-22 23:58:47 +09:00
FUJIWARA Katsunori
74e7c5bd04 largefiles: suppress unexpected warning of 'hg status' for removed files
original implementation queries whether specified pattern is related
or not to largefiles, to target context.

but changectx/workingctx returns False about relationship with files
marked as removed.

So, 'hg status' with 'file pattern' for removed file shows unexpected
warning message in below process:

    1. 'tostandin()' returns non-STANDIN filename for removed file,
       because changectx/workingctx returns False about relationship
       with it

    2. 'match.files()' contains non-STANDIN filename, which is already
       removed from working directory

    3. 'dirstate.walk()' invoked via 'localrepository.status()' treats
       non-STANDIN filename as bad filename, because there is no entry
       for it in dirstate: only STANDIN is managed in dirstate

    4. 'dirstate.walk()' invokes 'match.bad()', which is defined in
       'localrepository.status()' as 'bad()'

    5. 'bad()' shows warning message for non-STANDIN, because it is
       not related to source context: only STANDIN is related to it

this patch queries to dirstate instead of changectxt/workingctx,
because dirstate returns expected result for removed files.

'match.files()' is used by 'localrepository.status()' only in
'working' case, so this patched code also works correctly in
non-'working' case.
2012-03-22 23:58:47 +09:00
Matt Mackall
f2a652218a i18n: fix all remaining uses of % inside _() 2012-03-08 13:35:27 -06:00
Na'Tosha Bard
c51d8441de largefiles: fix check-code errors. 2012-03-09 17:11:07 +01:00
Na'Tosha Bard
65205ee295 largefiles: remove use of underscores that breaks coding convention 2012-03-09 16:11:52 +01:00
Na'Tosha Bard
a5ba0413ef largefiles: only update changed largefiles when transplanting 2012-03-09 15:26:13 +01:00
Na'Tosha Bard
064a3d8577 largefiles: move calculation of largefiles for updating to utility function 2012-03-09 16:45:49 +01:00
Martin Geisler
b8759cea3b largefiles: respect store.createmode and avoid extra file copy
Before, a tempfile was used to create a temp file was created with 600
permissions and the uploaded data was written into it. This file was
then *copied* to .hg/largefiles/<hash>.

We now simply use atomictempfile to write the data to a temp file with
the right permissions and then rename that into place.
2012-02-23 13:37:10 +01:00
Martin Geisler
61a444869a largefiles: respect store.createmode in basestore.get
This replaces another use of tempfile with atomictempfile. The problem
with tempfile is that it creates files with 600 permissions instead of
respecting repo.store.createmode.
2012-02-23 13:37:10 +01:00
Martin Geisler
c3f611d55c largefiles: use repo.store.createmode for new files in .hg/largefiles
Before, the mode was copied from the file in the working copy. This is
inconsistent with how Mercurial normally creates files inside the .hg
folder. This can lead to a situation where you can read the files
under .hg/store but not under .hg/largefiles and so a clone will fail
if it needs to access a largefile.
2012-02-23 13:22:55 +01:00
Dan Villiom Podlaski Christiansen
83af46e848 largefiles: don't break filesets 2012-02-20 17:59:48 +01:00
Matt Mackall
7f2d6a6af7 merge with stable 2012-03-08 15:59:33 -06:00
Matt Mackall
ee77ef5137 merge with stable 2012-02-24 16:16:48 -06:00
Matt Mackall
72210502d5 merge with stable 2012-02-22 17:36:33 -06:00
FUJIWARA Katsunori
c3838f8d3f largefiles: check whether specified patterns are related to largefiles strictly
current 'lfiles_repo.status()' implementation examines whether
specified patterns are related to largefiles in working directory (not
to STANDIN) or not by NOT-EMPTY-NESS of below list:

    [f for f in match.files() if f in lfdirstate]

but it can not be assumed that all in 'match.files()' are file itself
exactly, because user may only specify part of path to match whole
under subdirectories recursively.

above examination will mis-recognize such pattern as 'not related to
largefiles', and executes normal 'status()' procedure. so, 'hg status'
shows '?'(unknown) status for largefiles in working directory unexpectedly.

this patch examines relation of pattern to largefiles by applying
'match()' on each entries in lfdirstate and checking wheter there is
no matched entry.

it may increase cost of examination, because it causes of full scan of
entries in lfdirstate.

so this patch uses normal for-loop instead of list comprehensions, to
decrease cost when matching is found.
2012-02-15 23:01:09 +09:00
Na'Tosha Bard
8564a2aba3 largefiles: only cache largefiles in new heads
This fixes a serious performance regression in largefiles introduced in
Mercurial 2.1.  Caching new largefiles on pull is necessary, because
otherwise largefiles will be missing (and unable to be downloaded) when
the user tries to merge or rebase a new head with an old one.  But this
is an expensive operation and should only be done for heads that are new
from the pull, rather than on all heads in the repository.
2012-02-10 14:46:09 +01:00
FUJIWARA Katsunori
b1ab26d815 i18n: use util.pconvert() instead of 'str.replace()' for problematic encoding
some problematic encodings use backslash as part of multi-byte characters.

util.pconvert() can treat strings in such encodings correctly, if
win32mbcs is enabled, but str.replace() can not.
2012-02-05 22:58:31 +09:00
Na'Tosha Bard
979dbb4473 largefiles: fix revert on missing largefile (issue3217) 2012-01-25 16:52:16 +01:00
Na'Tosha Bard
e63a87cfd7 largefiles: fix transplant for all cases (issue3192) 2012-01-25 14:10:01 +01:00
Matt Mackall
ee1d294b90 merge with stable 2012-02-16 16:40:29 -06:00
Na'Tosha Bard
8640514f70 largefiles: optimize update speed by only updating changed largefiles
Historically, during 'hg update', every largefile in the working copy was
hashed (which is a very expensive operation on big files) and any
largefiles that did not have a hash that matched their standin were
updated.

This patch optimizes 'hg update' by keeping track of what standins have
changed between the old and new revisions, and only updating the largefiles
that have changed.  This saves a lot of time by avoiding the unecessary
calculation of a list of sha1 hashes for big files.

With this patch, the time 'hg update' takes to complete is a function of
how many largefiles need to be updated and what their size is.

Performance tests on a repository with about 80 largefiles ranging from
a few MB to about 97 MB are shown below.  The tests show how long it takes
to run 'hg update' with no changes actually being updated.

Mercurial 2.1 release:

$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
getting changed largefiles
0 largefiles updated, 0 removed

real    0m10.045s
user    0m9.367s
sys    0m0.674s

With this patch:

$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

real    0m0.965s
user    0m0.845s
sys    0m0.115s

The same repsoitory, without the largefiles extension enabled:

$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

real    0m0.799s
user    0m0.684s
sys    0m0.111s

So before the patch, 'hg update' with no changes was approximately 9.25s
slower with largefiles enabled.  With this patch, it is approximately 0.165s
slower.
2012-02-13 18:37:07 +01:00
Matt Mackall
bd7d3adcb4 merge with stable 2012-02-10 17:09:23 -06:00
Matt Mackall
e3a172f2f0 merge: don't use unknown()
This removes use of unknown files for building the synthetic working
directory manifest used by manifestmerge. Instead, we adopt the
strategy used by _checkunknown.

Side-effect: unknown files are no longer moved by remote directory
renames, and now are left alone like ignored files.
2012-02-09 17:04:17 -06:00
Matt Mackall
f454042775 merge: refactor unknown file conflict checking
Previously, we would do a full working directory walk including
unknown files to perform a merge. In many cases, this was painful
because unknown files greatly outnumbered tracked files and generally
had no useful effect on the merge.

Here we instead wait until we find a file in the destination that's
not tracked locally and detect if it exists and is not ignored. This
is usually cheaper but can be -more- expensive in the case where we're
adding a huge number of files. On the other hand, the cost of statting
the new files should be dwarfed by the cost of eventually writing
them.

In this version, case collisions are detected implicitly by
os.path.exists and wctx[f] lookup.
2012-02-09 16:50:19 -06:00
Matt Mackall
6715adc25e merge with stable 2012-02-06 15:22:43 -06:00
FUJIWARA Katsunori
1343f41ef6 largefiles: reduce redundant splitstandin/standin combination
assumptions:

    - 'lfutil.splitstandin(f)' strips 'f' of '.hglf/', if it can
    - 'lfile(f)' examines 'lfutil.standin(f) in manifest'
    - 'lfutil.standin(f)' adds '.hglf/' to 'f'

and

    - 'f' should start with '.hglf/' there, because it is already
      examined by 'lfutil.isstandin(f)'

then:

    lfile(lfutil.splitstandin(f))
      => lfile(<f without '.hglf/'>)
      => lfutil.standin(<f without '.hglf/'>) in manifest
      => <<f without '.hglf/'> with '.hglf/'> in manifest
      => f in manifest
2012-02-06 12:16:29 +09:00
FUJIWARA Katsunori
7600c7feb1 largefiles: reduce OR-ing of same conditions 2012-02-06 12:16:29 +09:00
Na'Tosha Bard
a93a493b94 largefiles: fix addremove when no largefiles are specified 2012-01-23 13:24:32 +01:00
Na'Tosha Bard
ccfa519703 largefiles: add --normal option to hg add (issue3061) 2011-12-02 18:20:32 +01:00
Na'Tosha Bard
77c6b2a6a2 largefiles: fix caching largefiles from an aliased repo (issue3212) 2012-01-20 11:56:12 +01:00
Patrick Mezard
7768e63bf5 largefiles: test and simplify empty directory removal in remove 2012-01-19 10:07:13 +01:00
Na'Tosha Bard
1e5b58f8a8 largefiles: cache new largefiles for new heads when pulling
When the user pulls from a remote repository that is not his default repo, it
is quite likely that he will pull a new head.  This means that if he tries to
merge or rebase with the other head, he will run into a problem becuase
largefiles has no way of tracking where the remote repository for this other
head is, so it cannot download the largefiles from this other remote repository.
It will attempt to download them from its default remote repository, which will
not yet contain the largefiles.

This patch solves this problem by caching any new largefiles for all heads
directly into the system cache at the time of the pull, so they are available
later.

This behavior is actually more in line with Mercurial's distributed nature,
because pulling already implies we have a connection to the remote server, but
merging or rebasing does not.
2012-01-18 11:33:14 +01:00
Patrick Mezard
b21e9758d9 largefiles: remove unused lfutil.readhash() 2012-01-18 14:33:19 +01:00
Na'Tosha Bard
69b4cf9fd4 largefiles: check if largefile could be found when archiving (issue3193) 2012-01-18 14:19:43 +01:00
Na'Tosha Bard
be9c0ca800 largefiles: refactor lfutil.findfiles to be more logical 2012-01-18 13:41:03 +01:00
Matt Mackall
35e56c3616 merge with stable 2012-01-18 15:07:15 -06:00
Patrick Mezard
2c7c26d633 largefiles: remove empty directories upon update (issue3202) 2012-01-17 11:29:32 +01:00
Na'Tosha Bard
922ddbc57a largefiles: correctly handle newly added largefile on other side of merge 2012-01-16 19:45:35 +01:00