D4420: shortest: fix an off-by-1 when disambiguating against revnums

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Wed Aug 29 22:56:34 UTC 2018


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Revision "5" is an unambiguous hex prefix in a repo with 5 revisions;
  it's only "4" and lower that are ambiguous.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4420

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -475,7 +475,7 @@
         # 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:1] == b'0' or i > len(repo):
+        if prefix[0:1] == b'0' or i >= len(repo):
             return False
         return True
     except ValueError:



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list