shortest: never emit 0-length prefix even if unique
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 22 Oct 2018 11:34:35 -0700
changeset 40403 bf249bb60087
parent 40402 106adc261492
child 40404 956ec6f1320d
child 40407 3d76a8e627a6
shortest: never emit 0-length prefix even if unique 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. Differential Revision: https://phab.mercurial-scm.org/D5181
mercurial/scmutil.py
--- a/mercurial/scmutil.py	Mon Oct 22 15:51:01 2018 +0200
+++ b/mercurial/scmutil.py	Mon Oct 22 11:34:35 2018 -0700
@@ -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'):