##// END OF EJS Templates
templater: introduce {latesttag()} function to match a pattern (issue4184)...
Matt Harbison -
r26485:43bf9471 default
parent child Browse files
Show More
@@ -102,6 +102,10 b' Some sample command line templates:'
102 102
103 103 $ hg log --template "{bookmarks % '{bookmark}{ifeq(bookmark, active, '*')} '}\n"
104 104
105 - Find the previous release candidate tag, the distance and changes since the tag::
106
107 $ hg log -r . --template "{latesttag('re:^.*-rc$') % '{tag}, {changes}, {distance}'}\n"
108
105 109 - Mark the working copy parent with '@'::
106 110
107 111 $ hg log --template "{ifcontains(rev, revset('.'), '@')}\n"
@@ -512,6 +512,19 b' def label(context, mapping, args):'
512 512 # ignore args[0] (the label string) since this is supposed to be a a no-op
513 513 yield args[1][0](context, mapping, args[1][1])
514 514
515 def latesttag(context, mapping, args):
516 """:latesttag([pattern]): The global tags matching the given pattern on the
517 most recent globally tagged ancestor of this changeset."""
518 if len(args) > 1:
519 # i18n: "latesttag" is a keyword
520 raise error.ParseError(_("latesttag expects at most one argument"))
521
522 pattern = None
523 if len(args) == 1:
524 pattern = stringify(args[0][0](context, mapping, args[0][1]))
525
526 return templatekw.showlatesttags(pattern, **mapping)
527
515 528 def localdate(context, mapping, args):
516 529 """:localdate(date[, tz]): Converts a date to the specified timezone.
517 530 The default is local date."""
@@ -733,6 +746,7 b' funcs = {'
733 746 "indent": indent,
734 747 "join": join,
735 748 "label": label,
749 "latesttag": latesttag,
736 750 "localdate": localdate,
737 751 "pad": pad,
738 752 "revset": revset,
@@ -2690,6 +2690,19 b' Merged tag overrides:'
2690 2690 1: t1+0
2691 2691 0: null+1
2692 2692
2693 $ hg log --template "{rev}: {latesttag('re:^t[13]$') % '{tag}, C: {changes}, D: {distance}'}\n"
2694 10: t3, C: 8, D: 7
2695 9: t3, C: 7, D: 6
2696 8: t3, C: 6, D: 5
2697 7: t3, C: 5, D: 4
2698 6: t3, C: 4, D: 3
2699 5: t3, C: 3, D: 2
2700 4: t3, C: 1, D: 1
2701 3: t3, C: 0, D: 0
2702 2: t1, C: 1, D: 1
2703 1: t1, C: 0, D: 0
2704 0: null, C: 1, D: 1
2705
2693 2706 $ cd ..
2694 2707
2695 2708
@@ -461,6 +461,13 b' check that we can merge tags that differ'
461 461 $ hg log -r '.' -T "{latesttag % '{latesttag}\n'}"
462 462 t4
463 463 t6
464 $ hg log -r '.' -T "{latesttag('t4') % 'T: {tag}, C: {changes}, D: {distance}\n'}"
465 T: t4, C: 2, D: 2
466 $ hg log -r '.' -T "{latesttag('re:\d') % 'T: {tag}, C: {changes}, D: {distance}\n'}"
467 T: t4, C: 2, D: 2
468 T: t6, C: 2, D: 2
469 $ hg log -r . -T '{join(latesttag(), "*")}\n'
470 t4*t6
464 471 $ hg ci -A -m4
465 472 adding f4
466 473 $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n"
General Comments 0
You need to be logged in to leave comments. Login now