changeset 37906:858c7bfb3f49

shortest: move some safe code out of exception block The RevlogError and WdirUnsupported could be raised by _partialmatch(), but not by the rest of isvalid(), so let's move the rest out to make it clearer. Differential Revision: https://phab.mercurial-scm.org/D3458
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 02 May 2018 22:49:06 -0700
parents a9d9802d577e
children 6921d3ecadc1
files mercurial/revlog.py
diffstat 1 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Fri May 04 22:04:44 2018 -0700
+++ b/mercurial/revlog.py	Wed May 02 22:49:06 2018 -0700
@@ -1506,22 +1506,21 @@
             try:
                 if self._partialmatch(test) is None:
                     return False
-
-                try:
-                    i = int(test)
-                    # if we are a pure int, then starting with zero will not be
-                    # confused as a rev; or, obviously, if the int is larger
-                    # than the value of the tip rev
-                    if test[0] == '0' or i > len(self):
-                        return True
-                    return False
-                except ValueError:
-                    return True
             except error.RevlogError:
                 return False
             except error.WdirUnsupported:
                 # single 'ff...' match
                 return True
+            try:
+                i = int(test)
+                # if we are a pure int, then starting with zero will not be
+                # confused as a rev; or, obviously, if the int is larger
+                # than the value of the tip rev
+                if test[0] == '0' or i > len(self):
+                    return True
+                return False
+            except ValueError:
+                return True
 
         hexnode = hex(node)
         shortest = hexnode