changeset 20539:aa021ece4506

templater: shorten pure integers Originally, the addition of the 'shorten' template function in 9c6b86dd2ed2 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).
author Sean Farley <sean.michael.farley@gmail.com>
date Thu, 20 Feb 2014 00:46:13 -0600
parents fe220013e4db
children fa16c710a3d8
files mercurial/templater.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templater.py	Fri Feb 21 13:16:17 2014 -0800
+++ b/mercurial/templater.py	Thu Feb 20 00:46:13 2014 -0600
@@ -416,7 +416,12 @@
                     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