largefiles: add --all-largefiles flag to clone (
issue3188)
--- a/hgext/largefiles/overrides.py Fri May 04 16:00:33 2012 -0500
+++ b/hgext/largefiles/overrides.py Fri May 11 23:11:43 2012 +0200
@@ -697,6 +697,33 @@
ui.status(_("%d largefiles cached\n") % numcached)
return result
+def overrideclone(orig, ui, source, dest=None, **opts):
+ result = hg.clone(ui, opts, source, dest,
+ pull=opts.get('pull'),
+ stream=opts.get('uncompressed'),
+ rev=opts.get('rev'),
+ update=True, # required for successful walkchangerevs
+ branch=opts.get('branch'))
+ if result is None:
+ return True
+ totalsuccess = 0
+ totalmissing = 0
+ if opts.get('all_largefiles'):
+ sourcerepo, destrepo = result
+ matchfn = scmutil.match(destrepo[None],
+ [destrepo.wjoin(lfutil.shortname)], {})
+ def prepare(ctx, fns):
+ pass
+ for ctx in cmdutil.walkchangerevs(destrepo, matchfn, {'rev' : None},
+ prepare):
+ success, missing = lfcommands.cachelfiles(ui, destrepo, ctx.node())
+ totalsuccess += len(success)
+ totalmissing += len(missing)
+ ui.status(_("%d additional largefiles cached\n") % totalsuccess)
+ if totalmissing > 0:
+ ui.status(_("%d largefiles failed to download\n") % totalmissing)
+ return totalmissing != 0
+
def overriderebase(orig, ui, repo, **opts):
repo._isrebasing = True
try:
--- a/hgext/largefiles/uisetup.py Fri May 04 16:00:33 2012 -0500
+++ b/hgext/largefiles/uisetup.py Fri May 11 23:11:43 2012 +0200
@@ -70,6 +70,12 @@
overrides.overrideupdate)
entry = extensions.wrapcommand(commands.table, 'pull',
overrides.overridepull)
+ entry = extensions.wrapcommand(commands.table, 'clone',
+ overrides.overrideclone)
+ cloneopt = [('', 'all-largefiles', None,
+ _('download all versions of all largefiles'))]
+
+ entry[1].extend(cloneopt)
entry = extensions.wrapcommand(commands.table, 'cat',
overrides.overridecat)
entry = extensions.wrapfunction(merge, '_checkunknownfile',
--- a/tests/test-largefiles.t Fri May 04 16:00:33 2012 -0500
+++ b/tests/test-largefiles.t Fri May 11 23:11:43 2012 +0200
@@ -432,11 +432,21 @@
large11
$ cat sub/large2
large22
+ $ cd ..
+
+Test cloning with --all-largefiles flag
+
+ $ rm -Rf ${USERCACHE}/*
+ $ hg clone --all-largefiles a a-backup
+ updating to branch default
+ 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ getting changed largefiles
+ 3 largefiles updated, 0 removed
+ 8 additional largefiles cached
Rebasing between two repositories does not revert largefiles to old
revisions (this was a very bad bug that took a lot of work to fix).
- $ cd ..
$ hg clone a d
updating to branch default
5 files updated, 0 files merged, 0 files removed, 0 files unresolved