# HG changeset patch # User Matt Harbison # Date 1347209004 14400 # Node ID 6e2ab601be3f4b9f5b05d62e640a35d2366154c6 # Parent 3a1c6b64e052c66a589557aeb377eea5cd034a1f largefiles: delegate to the wrapped clone command This allows the wrapped command's validation code to run (which is currently only to ensure 'noupdate' and 'updaterev' aren't both specified), the copy/pasted unpacking of hg.clone() args to be removed, and any future changes to the base command (however unlikely) to be inherited by largefiles. Unfortunately, the command override can't be swapped entirely for an hg.clone() override because the extra --all-largefiles arg needs to be injected. It also isn't enough to call the wrapped clone command and leave the caching code after it, because the file caching code needs access to the destination repo, which is only available from hg.clone(). An alternative would be to use the dest path in the clone command override to re-obtain a reference to the repo. A slight deviation from the regular hg.clone() function is that the repo is NOT deleted if the caching fails, but that was also the previous behavior. Maybe it should for consistency? diff -r 3a1c6b64e052 -r 6e2ab601be3f hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py Sun Sep 09 12:09:53 2012 -0400 +++ b/hgext/largefiles/overrides.py Sun Sep 09 12:43:24 2012 -0400 @@ -727,15 +727,13 @@ raise util.Abort(_( '--all-largefiles is incompatible with non-local destination %s' % d)) - result = hg.clone(ui, opts, source, dest, - pull=opts.get('pull'), - stream=opts.get('uncompressed'), - rev=opts.get('rev'), - update=opts.get('updaterev') or not opts.get('noupdate'), - branch=opts.get('branch')) - if result is None: - return True - if opts.get('all_largefiles'): + + return orig(ui, source, dest, **opts) + +def hgclone(orig, ui, opts, *args, **kwargs): + result = orig(ui, opts, *args, **kwargs) + + if result is not None and opts.get('all_largefiles'): sourcerepo, destrepo = result repo = destrepo.local() @@ -750,8 +748,11 @@ # Caching is implicitly limited to 'rev' option, since the dest repo was # truncated at that point. success, missing = lfcommands.downloadlfiles(ui, repo, None) - return missing != 0 - return result is None + + if missing != 0: + return None + + return result def overriderebase(orig, ui, repo, **opts): repo._isrebasing = True diff -r 3a1c6b64e052 -r 6e2ab601be3f hgext/largefiles/uisetup.py --- a/hgext/largefiles/uisetup.py Sun Sep 09 12:09:53 2012 -0400 +++ b/hgext/largefiles/uisetup.py Sun Sep 09 12:43:24 2012 -0400 @@ -77,8 +77,9 @@ overrides.overrideclone) cloneopt = [('', 'all-largefiles', None, _('download all versions of all largefiles'))] + entry[1].extend(cloneopt) + entry = extensions.wrapfunction(hg, 'clone', overrides.hgclone) - entry[1].extend(cloneopt) entry = extensions.wrapcommand(commands.table, 'cat', overrides.overridecat) entry = extensions.wrapfunction(merge, '_checkunknownfile', diff -r 3a1c6b64e052 -r 6e2ab601be3f tests/test-largefiles.t --- a/tests/test-largefiles.t Sun Sep 09 12:09:53 2012 -0400 +++ b/tests/test-largefiles.t Sun Sep 09 12:43:24 2012 -0400 @@ -717,6 +717,12 @@ 3 largefiles updated, 0 removed $ cd .. +Ensure base clone command argument validation + + $ hg clone -U -u 0 a a-clone-failure + abort: cannot specify both --noupdate and --updaterev + [255] + $ hg clone --all-largefiles a ssh://localhost/a abort: --all-largefiles is incompatible with non-local destination ssh://localhost/a [255]