changeset 27113:77850d2a161c

dispatch: use versiontuple() We have a new generic function for this. Use it.
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 24 Nov 2015 14:23:46 -0800
parents 39c14e89b881
children a636a46f5094
files mercurial/dispatch.py
diffstat 1 files changed, 4 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Tue Nov 24 14:23:51 2015 -0800
+++ b/mercurial/dispatch.py	Tue Nov 24 14:23:46 2015 -0800
@@ -320,7 +320,6 @@
     except socket.error as inst:
         ui.warn(_("abort: %s\n") % inst.args[-1])
     except: # re-raises
-        myver = util.version()
         # For compatibility checking, we discard the portion of the hg
         # version after the + on the assumption that if a "normal
         # user" is running a build with a + in it the packager
@@ -328,8 +327,7 @@
         # 'make local' copy of hg (where the version number can be out
         # of date) will be clueful enough to notice the implausible
         # version number and try updating.
-        compare = myver.split('+')[0]
-        ct = tuplever(compare)
+        ct = util.versiontuple(n=2)
         worst = None, ct, ''
         if ui.config('ui', 'supportcontact', None) is None:
             for name, mod in extensions.extensions():
@@ -344,7 +342,7 @@
                 if testedwith == 'internal':
                     continue
 
-                tested = [tuplever(t) for t in testedwith.split()]
+                tested = [util.versiontuple(t, 2) for t in testedwith.split()]
                 if ct in tested:
                     continue
 
@@ -369,7 +367,8 @@
             warning = (_("** unknown exception encountered, "
                          "please report by visiting\n** ") + bugtracker + '\n')
         warning += ((_("** Python %s\n") % sys.version.replace('\n', '')) +
-                    (_("** Mercurial Distributed SCM (version %s)\n") % myver) +
+                    (_("** Mercurial Distributed SCM (version %s)\n") %
+                     util.version()) +
                     (_("** Extensions loaded: %s\n") %
                      ", ".join([x[0] for x in extensions.extensions()])))
         ui.log("commandexception", "%s\n%s\n", warning, traceback.format_exc())
@@ -378,15 +377,6 @@
 
     return -1
 
-def tuplever(v):
-    try:
-        # Assertion: tuplever is only used for extension compatibility
-        # checking. Otherwise, the discarding of extra version fields is
-        # incorrect.
-        return tuple([int(i) for i in v.split('.')[0:2]])
-    except ValueError:
-        return tuple()
-
 def aliasargs(fn, givenargs):
     args = getattr(fn, 'args', [])
     if args: