comparison mercurial/templater.py @ 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 cda9d2b6beab
children 0084fcd5d7e2
comparison
equal deleted inserted replaced
20538:fe220013e4db 20539:aa021ece4506
414 # Fallback to the slow way. 414 # Fallback to the slow way.
415 if cl._partialmatch(test) is None: 415 if cl._partialmatch(test) is None:
416 return False 416 return False
417 417
418 try: 418 try:
419 int(test) 419 i = int(test)
420 # if we are a pure int, then starting with zero will not be
421 # confused as a rev; or, obviously, if the int is larger than
422 # the value of the tip rev
423 if test[0] == '0' or i > len(cl):
424 return True
420 return False 425 return False
421 except ValueError: 426 except ValueError:
422 return True 427 return True
423 except error.RevlogError: 428 except error.RevlogError:
424 return False 429 return False