[PATCH 04 of 10] largefiles: introduce lfpull command for pulling missing largefiles

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


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1365983617 -7200
#      Mon Apr 15 01:53:37 2013 +0200
# Node ID 4630416134f12f4b2e97c4bd923c1e208744487b
# Parent  c3b470c746af3bae27e691bd06ba9c3519d992e0
largefiles: introduce lfpull command for pulling missing largefiles

diff --git a/hgext/largefiles/__init__.py b/hgext/largefiles/__init__.py
--- a/hgext/largefiles/__init__.py
+++ b/hgext/largefiles/__init__.py
@@ -49,6 +49,9 @@
 copy to the latest pulled revision (and thereby downloading any new
 largefiles).
 
+If you want to pull largefiles you don't need for update yet, then
+you can use the `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
diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -530,6 +530,41 @@
         lfdirstate.drop(lfile)
     return ret
 
+def lfpull(ui, repo, source="default", **opts):
+    """pull largefiles for the specified revisions from the specified source
+
+    Pull largefiles that are referenced from local changesets but missing
+    locally, pulling from a remote repository to the local cache.
+
+    If SOURCE is omitted, the 'default' path will be used.
+    See :hg:`help urls` for more information.
+
+    .. container:: verbose
+
+      Some examples:
+
+      - pull largefiles for all branch heads::
+
+          hg lfpull -r "head() and not closed()"
+
+      - pull largefiles on the default branch::
+
+          hg lfpull -r "branch(default)"
+    """
+    repo.lfpullsource = source
+
+    revs = opts.get('rev', [])
+    if not revs:
+        raise util.Abort(_('no revisions specified'))
+    revs = scmutil.revrange(repo, revs)
+
+    numcached = 0
+    for rev in revs:
+        ui.note(_('pulling largefiles for revision %s\n') % rev)
+        (cached, missing) = cachelfiles(ui, repo, rev)
+        numcached += len(cached)
+    ui.status(_("%d largefiles cached\n") % numcached)
+
 # -- hg commands declarations ------------------------------------------------
 
 cmdtable = {
@@ -542,6 +577,11 @@
                    _('convert from a largefiles repo to a normal repo')),
                   ],
                   _('hg lfconvert SOURCE DEST [FILE ...]')),
+    'lfpull': (lfpull,
+               [('r', 'rev', [], _('pull largefiles for these revisions'))
+                ] +  commands.remoteopts,
+               _('-r REV... [-e CMD] [--remotecmd CMD] [SOURCE]')
+               ),
     }
 
 commands.inferrepo += " lfconvert"
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -884,6 +884,23 @@
   added 6 changesets with 16 changes to 8 files
   (run 'hg update' to get a working copy)
   6 additional largefiles cached
+
+lfpull
+
+  $ hg lfpull -r : --config largefiles.usercache=usercache-lfpull
+  2 largefiles cached
+  $ hg lfpull -v -r 4+2 --config largefiles.usercache=usercache-lfpull
+  pulling largefiles for revision 4
+  found eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 in store
+  found eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 in store
+  pulling largefiles for revision 2
+  found eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 in store
+  0 largefiles cached
+
+  $ ls usercache-lfpull/* | sort
+  usercache-lfpull/1deebade43c8c498a3c8daddac0244dc55d1331d
+  usercache-lfpull/4669e532d5b2c093a78eca010077e708a071bb64
+
   $ cd ..
 
 Rebasing between two repositories does not revert largefiles to old


More information about the Mercurial-devel mailing list