[PATCH 06 of 10] largefiles: introduce pull --lfrev option

Mads Kiilerich mads at kiilerich.com
Mon Apr 15 14:23:59 CDT 2013


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1365983836 -7200
#      Mon Apr 15 01:57:16 2013 +0200
# Node ID 0b69489d3bcfc387dbac95d818bf0e3a011f8d6d
# Parent  d31981da545c40c77e1296d591acefad459c5df7
largefiles: introduce pull --lfrev option

The revset will be evaluated after the changesets has been pulled, and missing
largefiles from matching revisions will be pulled to the local caches.

This in combination with revsets will make it possible to specify different
strategies for pulling largefiles.

The revset expressions used for this option might be quite complex and will
probably be most useful from scripts or an alias ... but less complicated than
configuring hooks.

diff --git a/hgext/largefiles/__init__.py b/hgext/largefiles/__init__.py
--- a/hgext/largefiles/__init__.py
+++ b/hgext/largefiles/__init__.py
@@ -50,11 +50,13 @@
 largefiles).
 
 If you want to pull largefiles you don't need for update yet, then
-you can use the `lfpull` command.
+you can use pull with the `--lfrev` option or the :hg:`lfpull` command.
 
 If you just want to ensure that you will have the largefiles needed to
 merge or rebase with new heads that you are pulling, then you can pull
-with `--cache-largefiles` flag to pre-emptively download any largefiles
+with `--lfrev "head(0:)"` flag to pre-emptively download any largefiles
+that are in the heads after pulling. You can also pull with the
+`--cache-largefiles` flag to pre-emptively download any largefiles
 that are new in the heads you are pulling.
 
 Keep in mind that network access may now be required to update to
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -753,6 +753,14 @@
         for rev in xrange(revsprepull, revspostpull):
             revs.append(repo[rev].rev())
         lfcommands.downloadlfiles(ui, repo, revs)
+    lfrevs = opts.get('lfrev', [])
+    if lfrevs and revspostpull > revsprepull:
+        numcached = 0
+        for rev in scmutil.revrange(repo, lfrevs):
+            ui.note(_('pulling largefiles for revision %s\n') % rev)
+            (cached, missing) = lfcommands.cachelfiles(ui, repo, rev)
+            numcached += len(cached)
+        ui.status(_("%d largefiles cached\n") % numcached)
     return result
 
 def overrideclone(orig, ui, source, dest=None, **opts):
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -81,7 +81,9 @@
     pullopt = [('', 'all-largefiles', None,
                  _('download all pulled versions of largefiles')),
                ('', 'cache-largefiles', None,
-                 _('caches new largefiles in all pulled heads'))]
+                 _('caches new largefiles in all pulled heads')),
+               ('', 'lfrev', [],
+                _('download largefiles for these revisions'), _('REV'))]
     entry[1].extend(pullopt)
     entry = extensions.wrapcommand(commands.table, 'clone',
                                    overrides.overrideclone)
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -885,6 +885,27 @@
   (run 'hg update' to get a working copy)
   6 additional largefiles cached
 
+redo pull with --lfrev and check it pulls largefiles for the right revs
+
+  $ hg rollback
+  repository tip rolled back to revision 1 (undo pull)
+  $ hg pull -v --lfrev 'heads(0:)'
+  pulling from $TESTTMP/a (glob)
+  searching for changes
+  all local heads known remotely
+  6 changesets found
+  adding changesets
+  adding manifests
+  adding file changes
+  added 6 changesets with 16 changes to 8 files
+  calling hook changegroup.lfiles: <function checkrequireslfiles at *> (glob)
+  (run 'hg update' to get a working copy)
+  pulling largefiles for revision 7
+  found 971fb41e78fea4f8e0ba5244784239371cb00591 in store
+  found 0d6d75887db61b2c7e6c74b5dd8fc6ad50c0cc30 in store
+  found bb3151689acb10f0c3125c560d5e63df914bc1af in store
+  0 largefiles cached
+
 lfpull
 
   $ hg lfpull -r : --config largefiles.usercache=usercache-lfpull


More information about the Mercurial-devel mailing list