[PATCH] dispatch: tolerate non-standard version strings in tuplever()

Adrian Buehlmann adrian at cadifra.com
Fri Jun 1 12:29:47 CDT 2012


On 2012-06-01 17:44, Augie Fackler wrote:
> Thanks! I did have a couple of comments.
> 
> On May 25, 2012, at 7:32 AM, Adrian Buehlmann wrote:
> 
>> # HG changeset patch
>> # User Adrian Buehlmann <adrian at cadifra.com>
>> # Date 1337948647 -7200
>> # Node ID c516ea214b28d738e1c6b8010b8d4202c208b572
>> # Parent  5d64306f39bb1f7ceab8d482156cd071d75f4d17
>> dispatch: tolerate non-standard version strings in tuplever()
> 
> should mention issue3470 in the summary line

Yeah. I think the bug was filed after I sent the patch. :-)

And the code it fixes has not been released yet.

>> When developing, we may see non-standard version strings of the form
>>
>>  5d64306f39bb+20120525
>>
>> which caused tuplever() to raise
>>
>>  ValueError: invalid literal for int() with base 10: '5d64306f39bb'
>>
>> and shadowing the real traceback.
>>
>> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
>> --- a/mercurial/dispatch.py
>> +++ b/mercurial/dispatch.py
>> @@ -252,8 +252,10 @@
>>     return -1
>>
>> def tuplever(v):
>> -    return tuple([int(i) for i in v.split('.')])
>> -
>> +    try:
>> +        return tuple([int(i) for i in v.split('.')])
>> +    except ValueError:
>> +        return tuple()
> 
> (,) strikes me as the more common way to have an empty tuple, but whatever.

I guess I somehow loved to match the line above. Not using Python here
for anything but Mercurial.

> Might be worth printing a warning (later though) that we couldn't identify hg's version and so extension version checks will be broken.

Perhaps you can adopt the duty of making a better version of this patch?

I'm not particularly interested in this part of the code. It just
started to get annoying when developing on default and your new trick
was eating all my nasty littly syntax error tracebacks :-)



More information about the Mercurial-devel mailing list