[PATCH 2 of 4 V2] largefiles: update largefiles in a subrepo when updating the parent (issue3752)

Matt Harbison matt_harbison at yahoo.com
Sun Jan 6 16:16:39 CST 2013


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1357450348 18000
# Node ID 06f51c9f9a9b5c47b9d763949f9559dafe5437a3
# Parent  a35f6d98d65f24d5d6f1a7928342b2bc479ef44c
largefiles: update largefiles in a subrepo when updating the parent (issue3752)

Starting with 17c030014ddf, largefiles in a subrepo weren't checked out when
updating the parent repo.  That cset changed hg.clean() and hg.update() to call
the newly introduced hg.updaterepo(), and also changed hgsubrepo.get() to call
updaterepo() directly.  Since only clean and update were overridden, largefiles
in subrepos were no longer being updated.

Since clean() and update() delegate to updaterepo() to do their work, the latter
is the only override required.

Backing out 17c030014ddf and implementing hgsubrepo.get() with hg.clean() and
hg.update() caused extra _showstats() lines to be printed, without the context
of which (sub)repo it was related too.  Multiple of these lines in a row looks
confusing.

Overriding hgsubrepo.get() would have made it necessary to duplicate the
largefiles handling in both clean() and update(), while adding yet another
override.

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -647,18 +647,20 @@
     finally:
         wlock.release()
 
-def hgupdate(orig, repo, node):
-    # Only call updatelfiles the standins that have changed to save time
-    oldstandins = lfutil.getstandinsstate(repo)
-    result = orig(repo, node)
-    newstandins = lfutil.getstandinsstate(repo)
-    filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
+def hgupdaterepo(orig, repo, node, overwrite, showstats=False):
+    if not overwrite:
+        # Only call updatelfiles on the standins that have changed to save time
+        oldstandins = lfutil.getstandinsstate(repo)
+
+    result = orig(repo, node, overwrite, showstats)
+    filelist = None
+
+    if not overwrite:
+        newstandins = lfutil.getstandinsstate(repo)
+        filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
+
     lfcommands.updatelfiles(repo.ui, repo, filelist=filelist, printmessage=True)
-    return result
 
-def hgclean(orig, repo, node, show_stats=True):
-    result = orig(repo, node, show_stats)
-    lfcommands.updatelfiles(repo.ui, repo)
     return result
 
 def hgmerge(orig, repo, node, force=None, remind=True):
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -109,11 +109,7 @@
     entry = extensions.wrapfunction(commands, 'revert',
                                     overrides.overriderevert)
 
-    # clone uses hg._update instead of hg.update even though they are the
-    # same function... so wrap both of them)
-    extensions.wrapfunction(hg, 'update', overrides.hgupdate)
-    extensions.wrapfunction(hg, '_update', overrides.hgupdate)
-    extensions.wrapfunction(hg, 'clean', overrides.hgclean)
+    extensions.wrapfunction(hg, 'updaterepo', overrides.hgupdaterepo)
     extensions.wrapfunction(hg, 'merge', overrides.hgmerge)
 
     extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1703,6 +1703,18 @@
   lf_subrepo_archive/subrepo/large.txt
   lf_subrepo_archive/subrepo/normal.txt
 
+Test that largefiles in subrepos are checked out (issue3752)
+
+  $ hg clone . ../update_on_clone
+  updating to branch default
+  cloning subrepo subrepo from $TESTTMP/statusmatch/subrepo
+  getting changed largefiles
+  1 largefiles updated, 0 removed
+  5 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  getting changed largefiles
+  1 largefiles updated, 0 removed
+  $ hg -R ../update_on_clone status -S
+
 Test archiving a revision that references a subrepo that is not yet
 cloned (see test-subrepo-recursion.t):
 


More information about the Mercurial-devel mailing list