From 4e69c94634fba56b78edf140eef0e2786e3cf07f Mon Sep 17 00:00:00 2001 From: Sean Farley Date: Thu, 20 Feb 2014 00:46:13 -0600 Subject: [PATCH] templater: shorten pure integers Originally, the addition of the 'shorten' template function in 83d773060c28 would not consider pure integers for shortening. This patch considers two simple cases: when the integer starts with zero (which is parsed by Mercurial as a hash first) and when the integer is larger than the tip (obviously not a rev). --- mercurial/templater.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mercurial/templater.py b/mercurial/templater.py index ae81d763ce..12ae5b9587 100644 --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -416,7 +416,12 @@ def shortest(context, mapping, args): return False try: - int(test) + i = int(test) + # if we are a pure int, then starting with zero will not be + # confused as a rev; or, obviously, if the int is larger than + # the value of the tip rev + if test[0] == '0' or i > len(cl): + return True return False except ValueError: return True