diff -r 24fee31fda05 -r 8e8541610d85 mercurial/scmutil.py --- a/mercurial/scmutil.py Sun Apr 15 19:41:34 2018 +0800 +++ b/mercurial/scmutil.py Fri Apr 13 10:36:03 2018 -0700 @@ -436,7 +436,7 @@ def resolvehexnodeidprefix(repo, prefix): # Uses unfiltered repo because it's faster when prefix is ambiguous/ - # This matches the "shortest" template function. + # This matches the shortesthexnodeidprefix() function below. node = repo.unfiltered().changelog._partialmatch(prefix) if node is None: return @@ -445,7 +445,10 @@ def shortesthexnodeidprefix(repo, hexnode, minlength=1): """Find the shortest unambiguous prefix that matches hexnode.""" - return repo.changelog.shortest(hexnode, minlength) + # _partialmatch() of filtered changelog could take O(len(repo)) time, + # which would be unacceptably slow. so we look for hash collision in + # unfiltered space, which means some hashes may be slightly longer. + return repo.unfiltered().changelog.shortest(hexnode, minlength) def isrevsymbol(repo, symbol): """Checks if a symbol exists in the repo.