D3455: shortest: make {shortest("fffffffff")} work again

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue May 8 08:46:58 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG66dc9db6ed2c: shortest: make {shortest("fffffffff")} work again (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3455?vs=8487&id=8509

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

AFFECTED FILES
  mercurial/templatefuncs.py
  tests/test-command-template.t

CHANGE DETAILS

diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -3916,6 +3916,15 @@
   $ hg log --template '{shortest("not a hex string, but it'\''s 40 bytes long")}\n' -l1
   not a hex string, but it's 40 bytes long
 
+  $ hg log --template '{shortest("ffffffffffffffffffffffffffffffffffffffff")}\n' -l1
+  ffff
+
+  $ hg log --template '{shortest("fffffff")}\n' -l1
+  ffff
+
+  $ hg log --template '{shortest("ff")}\n' -l1
+  ffff
+
   $ cd ..
 
 Test shortest(node) with the repo having short hash collision:
diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py
--- a/mercurial/templatefuncs.py
+++ b/mercurial/templatefuncs.py
@@ -12,6 +12,7 @@
 from .i18n import _
 from .node import (
     bin,
+    wdirid,
 )
 from . import (
     color,
@@ -601,7 +602,9 @@
     else:
         try:
             node = scmutil.resolvehexnodeidprefix(repo, hexnode)
-        except (error.LookupError, error.WdirUnsupported):
+        except error.WdirUnsupported:
+            node = wdirid
+        except error.LookupError:
             return hexnode
         if not node:
             return hexnode



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


More information about the Mercurial-devel mailing list