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

login
register
mail settings
Submitter phabricator
Date May 7, 2018, 10:19 p.m.
Message ID <5892b001f973193da9df4b46fbcd62fc@localhost.localdomain>
Download mbox | patch
Permalink /patch/31313/
State Not Applicable
Headers show

Comments

phabricator - May 7, 2018, 10:19 p.m.
martinvonz updated this revision to Diff 8487.
martinvonz edited the summary of this revision.

REPOSITORY
  rHG Mercurial

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

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

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

CHANGE DETAILS




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

Patch

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