##// END OF EJS Templates
templater: protect word() from crashing on out of range negative value...
Matt Harbison -
r26502:4ca98a38 stable
parent child Browse files
Show More
@@ -649,7 +649,7 b' def word(context, mapping, args):'
649 splitter = None
649 splitter = None
650
650
651 tokens = text.split(splitter)
651 tokens = text.split(splitter)
652 if num >= len(tokens):
652 if num >= len(tokens) or num < -len(tokens):
653 return ''
653 return ''
654 else:
654 else:
655 return tokens[num]
655 return tokens[num]
@@ -3368,6 +3368,11 b' Test word for invalid numbers'
3368 hg: parse error: word expects an integer index
3368 hg: parse error: word expects an integer index
3369 [255]
3369 [255]
3370
3370
3371 Test word for out of range
3372
3373 $ hg log -R a --template "{word(10000, desc)}"
3374 $ hg log -R a --template "{word(-10000, desc)}"
3375
3371 Test indent and not adding to empty lines
3376 Test indent and not adding to empty lines
3372
3377
3373 $ hg log -T "-----\n{indent(desc, '>> ', ' > ')}\n" -r 0:1 -R a
3378 $ hg log -T "-----\n{indent(desc, '>> ', ' > ')}\n" -r 0:1 -R a
General Comments 0
You need to be logged in to leave comments. Login now