D3460: shortest: extract function for checking if a prefix is a revnum
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Tue May 8 12:47:21 UTC 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG890bdf0e33c8: shortest: extract function for checking if a prefix is a revnum (authored by martinvonz, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D3460?vs=8485&id=8514
REVISION DETAIL
https://phab.mercurial-scm.org/D3460
AFFECTED FILES
mercurial/revlog.py
CHANGE DETAILS
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1502,6 +1502,18 @@
def shortest(self, node, minlength=1):
"""Find the shortest unambiguous prefix that matches node."""
+ def isrev(prefix):
+ try:
+ i = int(prefix)
+ # 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 prefix[0] == '0' or i > len(self):
+ return False
+ return True
+ except ValueError:
+ return False
+
def isvalid(prefix):
try:
if self._partialmatch(prefix) is None:
@@ -1511,16 +1523,7 @@
except error.WdirUnsupported:
# single 'ff...' match
return True
- try:
- i = int(prefix)
- # 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 prefix[0] == '0' or i > len(self):
- return True
- return False
- except ValueError:
- return True
+ return not isrev(prefix)
hexnode = hex(node)
shortest = hexnode
To: martinvonz, indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list