# HG changeset patch # User Mads Kiilerich # Date 1365983617 -7200 # Node ID 6734951e2d24b5ad36068f7b17db4d2b03d76720 # Parent aa8205a9f51a893b29aa2876ec15d3d23c1e5fec largefiles: introduce lfpull command for pulling missing largefiles diff -r aa8205a9f51a -r 6734951e2d24 hgext/largefiles/__init__.py --- a/hgext/largefiles/__init__.py Mon Apr 15 01:46:10 2013 +0200 +++ b/hgext/largefiles/__init__.py Mon Apr 15 01:53:37 2013 +0200 @@ -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 -r aa8205a9f51a -r 6734951e2d24 hgext/largefiles/lfcommands.py --- 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" diff -r aa8205a9f51a -r 6734951e2d24 tests/test-largefiles.t --- a/tests/test-largefiles.t Mon Apr 15 01:46:10 2013 +0200 +++ b/tests/test-largefiles.t Mon Apr 15 01:53:37 2013 +0200 @@ -912,6 +912,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