# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1540233275 25200
#      Mon Oct 22 11:34:35 2018 -0700
# Node ID bf249bb60087b8aa2c9ea6ef4031768620c7a790
# Parent  106adc2614922a24adc1e662ea78c83ec19aa4bf
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

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'):