D5181: shortest: never emit 0-length prefix even if unique

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Mon Oct 22 18:37:54 UTC 2018


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

REVISION SUMMARY
  It turned out that the pure version of our code for finding the
  shortest unique nodeid prefix would return a 0-length string if that
  was unique (because there was at most one revision in the
  disambiguation set). That's kind of correct, but it can't be used as
  input, so we shouldn't return it. Let's just adjust the given
  minlength up to at least 1. This fixes test-template-functions.t,
  which was failing in pure mode.

REPOSITORY
  rHG Mercurial

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

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
@@ -495,6 +495,8 @@
     # which would be unacceptably slow. so we look for hash collision in
     # unfiltered space, which means some hashes may be slightly longer.
 
+    minlength=max(minlength, 1)
+
     def disambiguate(prefix):
         """Disambiguate against revnums."""
         if repo.ui.configbool('experimental', 'revisions.prefixhexnode'):



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


More information about the Mercurial-devel mailing list