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

Gregory Szorc gregory.szorc at gmail.com
Wed Oct 14 11:52:57 CDT 2015


On Tue, Oct 13, 2015 at 9:27 PM, Pierre-Yves David <
pierre-yves.david at ens-lyon.org> wrote:

>
>
> 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.
>

Yes, this is exactly why we don't catch it in commands.bundle().
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20151014/3d7f2a56/attachment.html>


More information about the Mercurial-devel mailing list