largefiles: for update -C, only update largefiles when necessary
Before, a --clean update with largefiles would use the "optimization" that it
didn't read hashes from standin files before and after the update. Instead of
trusting the content of the standin files, it would rehash all the actual
largefiles that lfdirstate reported clean and update the standins that didn't
have the expected content. It could thus in some "impossible" situations
automatically recover from some "largefile got out sync with its standin"
issues (even there apparently still were weird corner cases where it could
fail). This extra checking is similar to what core --clean intentionally do
not do, and it made update --clean unbearable slow.
Usually in core Mercurial, --clean will rely on the dirstate to find the files
it should update. (It is thus intentionally possible (when trying to trick the
system or if there should be bugs) to end up in situations where --clean not
will restore the working directory content correctly.) Checking every file when
we "know" it is ok is however not an option - that would be too slow.
Instead, trust the content of the standin files. Use the same logic for --clean
as for linear updates and trust the dirstate and that our "logic" will keep
them in sync. It is much cheaper to just rehash the largefiles reported dirty
by a status walk and read all standins than to hash largefiles.
Most of the changes are just a change of indentation now when the different
kinds of updates no longer are handled that differently. Standins for added
files are however only written when doing a normal update, while deleted and
removed files only will be updated for --clean updates.
--- a/hgext/largefiles/overrides.py Wed Apr 15 11:49:44 2015 -0400
+++ b/hgext/largefiles/overrides.py Wed Apr 15 15:22:16 2015 -0400
@@ -1318,45 +1318,37 @@
# (*) don't care
# (*1) deprecated, but used internally (e.g: "rebase --collapse")
- linearmerge = not branchmerge and not force and not partial
+ lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
+ unsure, s = lfdirstate.status(match_.always(repo.root,
+ repo.getcwd()),
+ [], False, False, False)
+ pctx = repo['.']
+ for lfile in unsure + s.modified:
+ lfileabs = repo.wvfs.join(lfile)
+ if not os.path.exists(lfileabs):
+ continue
+ lfhash = lfutil.hashrepofile(repo, lfile)
+ standin = lfutil.standin(lfile)
+ lfutil.writestandin(repo, standin, lfhash,
+ lfutil.getexecutable(lfileabs))
+ if (standin in pctx and
+ lfhash == lfutil.readstandin(repo, lfile, '.')):
+ lfdirstate.normal(lfile)
+ for lfile in s.added:
+ lfutil.updatestandin(repo, lfutil.standin(lfile))
+ lfdirstate.write()
- if linearmerge or (branchmerge and force and not partial):
- # update standins for linear-merge or force-branch-merge,
- # because largefiles in the working directory may be modified
- lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
- unsure, s = lfdirstate.status(match_.always(repo.root,
- repo.getcwd()),
- [], False, False, False)
- pctx = repo['.']
- for lfile in unsure + s.modified:
- lfileabs = repo.wvfs.join(lfile)
- if not os.path.exists(lfileabs):
- continue
- lfhash = lfutil.hashrepofile(repo, lfile)
- standin = lfutil.standin(lfile)
- lfutil.writestandin(repo, standin, lfhash,
- lfutil.getexecutable(lfileabs))
- if (standin in pctx and
- lfhash == lfutil.readstandin(repo, lfile, '.')):
- lfdirstate.normal(lfile)
- for lfile in s.added:
- lfutil.updatestandin(repo, lfutil.standin(lfile))
- lfdirstate.write()
-
- if linearmerge:
- # Only call updatelfiles on the standins that have changed
- # to save time
- oldstandins = lfutil.getstandinsstate(repo)
+ oldstandins = lfutil.getstandinsstate(repo)
result = orig(repo, node, branchmerge, force, partial, *args, **kwargs)
- filelist = None
- if linearmerge:
- newstandins = lfutil.getstandinsstate(repo)
- filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
+ newstandins = lfutil.getstandinsstate(repo)
+ filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
+ if branchmerge or force or partial:
+ filelist.extend(s.deleted + s.removed)
lfcommands.updatelfiles(repo.ui, repo, filelist=filelist,
- normallookup=partial, checked=linearmerge)
+ normallookup=partial, checked=True)
return result
finally:
--- a/tests/test-issue3084.t Wed Apr 15 11:49:44 2015 -0400
+++ b/tests/test-issue3084.t Wed Apr 15 15:22:16 2015 -0400
@@ -113,8 +113,6 @@
$ echo "l" | hg merge --config ui.interactive=Yes
remote turned local largefile foo into a normal file
keep (l)argefile or use (n)ormal file? l
- getting changed largefiles
- 0 largefiles updated, 0 removed
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
@@ -249,8 +247,6 @@
$ hg up -Cqr large
$ hg merge -r normal-id
- getting changed largefiles
- 0 largefiles updated, 0 removed
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ cat f
@@ -271,8 +267,6 @@
$ hg up -Cqr large
$ hg merge -r normal-same
- getting changed largefiles
- 0 largefiles updated, 0 removed
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ cat f
@@ -307,8 +301,6 @@
$ hg merge -r normal2
remote turned local largefile f into a normal file
keep (l)argefile or use (n)ormal file? l
- getting changed largefiles
- 0 largefiles updated, 0 removed
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ cat f
@@ -372,8 +364,6 @@
$ hg merge -r normal
remote turned local largefile f into a normal file
keep (l)argefile or use (n)ormal file? l
- getting changed largefiles
- 0 largefiles updated, 0 removed
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ cat f
--- a/tests/test-largefiles-misc.t Wed Apr 15 11:49:44 2015 -0400
+++ b/tests/test-largefiles-misc.t Wed Apr 15 15:22:16 2015 -0400
@@ -364,8 +364,6 @@
$ hg update -C
getting changed largefiles
1 largefiles updated, 0 removed
- getting changed largefiles
- 0 largefiles updated, 0 removed
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg status -S
@@ -805,8 +803,6 @@
R d1/f
$ hg merge
merging d2/f and d1/f to d2/f
- getting changed largefiles
- 0 largefiles updated, 0 removed
1 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ cd ..
--- a/tests/test-largefiles.t Wed Apr 15 11:49:44 2015 -0400
+++ b/tests/test-largefiles.t Wed Apr 15 15:22:16 2015 -0400
@@ -581,8 +581,6 @@
C sub2/large6
C sub2/large7
$ hg up -C '.^'
- getting changed largefiles
- 0 largefiles updated, 0 removed
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg remove large
$ hg addremove --traceback
@@ -1431,8 +1429,6 @@
verify that largefile .orig file no longer is overwritten on every update -C:
$ hg update --clean
- getting changed largefiles
- 0 largefiles updated, 0 removed
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cat sub2/large7.orig
mistake