# HG changeset patch # User Martin von Zweigbergk # Date 2018-04-17 06:49:38 # Node ID a01200b25da69bf3e0d78200abe1bdfc8d18a5db # Parent 7848f284b211320177e4427256f824c74d1320d0 shortest: use 'x' prefix to disambiguate from revnum if configured Differential Revision: https://phab.mercurial-scm.org/D4042 diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -490,6 +490,12 @@ def shortesthexnodeidprefix(repo, node, def disambiguate(prefix): """Disambiguate against revnums.""" + if repo.ui.configbool('experimental', 'revisions.prefixhexnode'): + if mayberevnum(repo, prefix): + return 'x' + prefix + else: + return prefix + hexnode = hex(node) for length in range(len(prefix), len(hexnode) + 1): prefix = hexnode[:length] diff --git a/tests/test-template-functions.t b/tests/test-template-functions.t --- a/tests/test-template-functions.t +++ b/tests/test-template-functions.t @@ -892,6 +892,11 @@ Test shortest(node) with the repo having $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden 4:107 + $ hg --config experimental.revisions.prefixhexnode=yes log -r 4 -T '{rev}:{shortest(node, 0)}\n' + 4:x10 + $ hg --config experimental.revisions.prefixhexnode=yes log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden + 4:x10 + node 'c562' should be unique if the other 'c562' nodes are hidden (but we don't try the slow path to filter out hidden nodes for now)