# HG changeset patch # User Na'Tosha Bard # Date 2012-05-11 21:11:43 # Node ID 98a9266db80306efe6994d972f7962fe8aeb51c4 # Parent 24dbef11f477e13511e6f462dcd84d00a7d13f45 largefiles: add --all-largefiles flag to clone (issue3188) diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -697,6 +697,33 @@ def overridepull(orig, ui, repo, source= 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: diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py --- a/hgext/largefiles/uisetup.py +++ b/hgext/largefiles/uisetup.py @@ -70,6 +70,12 @@ def uisetup(ui): 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', diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t --- a/tests/test-largefiles.t +++ b/tests/test-largefiles.t @@ -432,11 +432,21 @@ tests update). 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