[PATCH 2 of 2] largefiles: add --all-largefiles flag to pull

Na'Tosha Bard natosha at unity3d.com
Sat May 12 04:47:06 CDT 2012


# HG changeset patch
# User Na'Tosha Bard <natosha at unity3d.com>
# Date 1336815922 -7200
# Node ID b496a35f805990dfc5502cdae52b52096a56df7c
# Parent  91b40a4dc53e4ed39ca182d8f76012456acb1105
largefiles: add --all-largefiles flag to pull

diff -r 91b40a4dc53e -r b496a35f8059 hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Sat May 12 09:59:01 2012 +0200
+++ b/hgext/largefiles/overrides.py	Sat May 12 11:45:22 2012 +0200
@@ -651,6 +651,7 @@
 # take some extra care so that the largefiles are correctly updated in the
 # working copy
 def overridepull(orig, ui, repo, source=None, **opts):
+    revsprepull = len(repo)
     if opts.get('rebase', False):
         repo._isrebasing = True
         try:
@@ -660,7 +661,6 @@
                           'the update flag\n')
             del opts['rebase']
             cmdutil.bailifchanged(repo)
-            revsprepull = len(repo)
             origpostincoming = commands.postincoming
             def _dummy(*args, **kwargs):
                 pass
@@ -695,6 +695,12 @@
             (cached, missing) = lfcommands.cachelfiles(ui, repo, head)
             numcached += len(cached)
         ui.status(_("%d largefiles cached\n") % numcached)
+    if opts.get('all_largefiles'):
+        revspostpull = len(repo)
+        revs = []
+        for rev in xrange(revsprepull + 1, revspostpull):
+            revs.append(repo[rev].rev())
+        lfcommands.downloadlfiles(ui, repo, revs)
     return result
 
 def overrideclone(orig, ui, source, dest=None, **opts):
diff -r 91b40a4dc53e -r b496a35f8059 hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py	Sat May 12 09:59:01 2012 +0200
+++ b/hgext/largefiles/uisetup.py	Sat May 12 11:45:22 2012 +0200
@@ -70,6 +70,9 @@
                                    overrides.overrideupdate)
     entry = extensions.wrapcommand(commands.table, 'pull',
                                    overrides.overridepull)
+    pullopt = [('', 'all-largefiles', None,
+                 _('download all pulled versions of largefiles'))]
+    entry[1].extend(pullopt)
     entry = extensions.wrapcommand(commands.table, 'clone',
                                    overrides.overrideclone)
     cloneopt = [('', 'all-largefiles', None,
diff -r 91b40a4dc53e -r b496a35f8059 tests/test-largefiles.t
--- a/tests/test-largefiles.t	Sat May 12 09:59:01 2012 +0200
+++ b/tests/test-largefiles.t	Sat May 12 11:45:22 2012 +0200
@@ -444,6 +444,33 @@
   3 largefiles updated, 0 removed
   8 additional largefiles cached
 
+Test pulling with --all-largefiles flag
+
+  $ rm -Rf a-backup
+  $ hg clone -r 1 a a-backup
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 8 changes to 4 files
+  updating to branch default
+  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  getting changed largefiles
+  2 largefiles updated, 0 removed
+  $ rm -Rf ${USERCACHE}/*
+  $ cd a-backup
+  $ hg pull --all-largefiles
+  pulling from $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 6 changesets with 16 changes to 8 files
+  (run 'hg update' to get a working copy)
+  caching new largefiles
+  3 largefiles cached
+  3 additional largefiles cached
+  $ cd ..
+
 Rebasing between two repositories does not revert largefiles to old
 revisions (this was a very bad bug that took a lot of work to fix).
 


More information about the Mercurial-devel mailing list