mercurial/scmutil.py
changeset 38843 6f7c9527030b
parent 38842 503f936489dd
child 38853 3588e41f796d
--- a/mercurial/scmutil.py	Wed Mar 28 09:36:02 2018 -0700
+++ b/mercurial/scmutil.py	Fri Apr 13 23:23:47 2018 -0700
@@ -489,6 +489,21 @@
             if not isrev(prefix):
                 return prefix
 
+    revset = repo.ui.config('experimental', 'revisions.disambiguatewithin')
+    if revset:
+        revs = repo.anyrevs([revset], user=True)
+        if cl.rev(node) in revs:
+            hexnode = hex(node)
+            for length in range(minlength, len(hexnode) + 1):
+                matches = []
+                prefix = hexnode[:length]
+                for rev in revs:
+                    otherhexnode = repo[rev].hex()
+                    if prefix == otherhexnode[:length]:
+                        matches.append(otherhexnode)
+                if len(matches) == 1:
+                    return disambiguate(prefix)
+
     try:
         return disambiguate(cl.shortest(node, minlength))
     except error.LookupError: