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

Adrian Buehlmann adrian at cadifra.com
Fri May 25 07:32:10 CDT 2012


# 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()

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()
 
 def aliasargs(fn, givenargs):
     args = getattr(fn, 'args', [])


More information about the Mercurial-devel mailing list