D3500: shortest: make pure code also disambigute against revnums at end
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Fri May 11 15:32:39 EDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0db7fe7c34d3: shortest: make pure code also disambigute against revnums at end (authored by martinvonz, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D3500?vs=8553&id=8640
REVISION DETAIL
https://phab.mercurial-scm.org/D3500
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
@@ -1542,31 +1542,22 @@
length = max(self.index.shortest(node), minlength)
return disambiguate(hexnode, length)
except RevlogError:
- if node == wdirid:
- for length in range(minlength, 41):
- prefix = hexnode[:length]
- if isvalid(prefix):
- return prefix
- else:
+ if node != wdirid:
raise LookupError(node, self.indexfile, _('no node'))
except AttributeError:
# Fall through to pure code
pass
- shortest = hexnode
- startlength = max(6, minlength)
- length = startlength
- while True:
+ if node == wdirid:
+ for length in range(minlength, 41):
+ prefix = hexnode[:length]
+ if isvalid(prefix):
+ return prefix
+
+ for length in range(minlength, 41):
prefix = hexnode[:length]
if isvalid(prefix):
- shortest = prefix
- if length == minlength or length > startlength:
- return shortest
- length -= 1
- else:
- length += 1
- if len(shortest) <= length:
- return shortest
+ return disambiguate(hexnode, length)
def cmp(self, node, text):
"""compare text with a given file revision
To: martinvonz, indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list