changeset 18978:8abaadab9abb

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.
author Mads Kiilerich <madski@unity3d.com>
date Mon, 15 Apr 2013 01:57:16 +0200
parents 864232481e76
children 1176832fc757
files hgext/largefiles/__init__.py hgext/largefiles/overrides.py hgext/largefiles/uisetup.py tests/test-largefiles.t
diffstat 4 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/__init__.py	Mon Apr 15 01:54:43 2013 +0200
+++ b/hgext/largefiles/__init__.py	Mon Apr 15 01:57:16 2013 +0200
@@ -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
--- a/hgext/largefiles/overrides.py	Mon Apr 15 01:54:43 2013 +0200
+++ b/hgext/largefiles/overrides.py	Mon Apr 15 01:57:16 2013 +0200
@@ -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):
--- a/hgext/largefiles/uisetup.py	Mon Apr 15 01:54:43 2013 +0200
+++ b/hgext/largefiles/uisetup.py	Mon Apr 15 01:57:16 2013 +0200
@@ -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)
--- a/tests/test-largefiles.t	Mon Apr 15 01:54:43 2013 +0200
+++ b/tests/test-largefiles.t	Mon Apr 15 01:57:16 2013 +0200
@@ -913,6 +913,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