diff hgext/largefiles/lfcommands.py @ 18976:6734951e2d24

largefiles: introduce lfpull command for pulling missing largefiles
author Mads Kiilerich <madski@unity3d.com>
date Mon, 15 Apr 2013 01:53:37 +0200
parents d78a136a8036
children 0509ae083ec1
line wrap: on
line diff
--- a/hgext/largefiles/lfcommands.py	Mon Apr 15 01:46:10 2013 +0200
+++ b/hgext/largefiles/lfcommands.py	Mon Apr 15 01:53:37 2013 +0200
@@ -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"