[PATCH 2 of 5 clonebundles V3] exchange: refactor bundle specification parsing

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Oct 13 23:27:59 CDT 2015



On 10/13/2015 11:54 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1444759074 25200
> #      Tue Oct 13 10:57:54 2015 -0700
> # Node ID 770e985c4dd0e46deebcdeecf74f75f2351b86b1
> # Parent  e81dbde0649bed83a2260790e1248d38aece6b9d
> exchange: refactor bundle specification parsing
>
> The old code was tailored to `hg bundle` usage and not appropriate for
> use as a general API, which clone bundles will require. The code has
> been rewritten to make it more generally suitable.
>
> We introduce dedicated error types to represent invalid and unsupported
> bundle specifications. The reason we need dedicated error types (rather
> than error.Abort) is because clone bundles will want to catch these
> exception as part of filtering entries. We don't want to swallow
> error.Abort on principle.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -1241,9 +1241,15 @@ def bundle(ui, repo, fname, dest=None, *
>       if 'rev' in opts:
>           revs = scmutil.revrange(repo, opts['rev'])
>
>       bundletype = opts.get('type', 'bzip2').lower()
> -    cgversion, bcompression = exchange.parsebundlespec(repo, bundletype)
> +    try:
> +        bcompression, cgversion = exchange.parsebundlespec(
> +                repo, bundletype, strict=False)
> +    except error.UnsupportedBundleSpecification as e:

You have two new classes of error (Invalid/Unsupported) but you only 
catch one. Is that expected ?

We probably should we have some inheritance at work to simplify the 
catching here.

As the Invalid is only raised in the strict case we currently no user. I 
do not see this as a blocker and have pushed it to the clowncopter.

(As my plane is currently aligning for take off, this is the last one 
I'll push tonight.)

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list