diff -r 2a8d8b4097c8 -r 4474a750413f mercurial/templatekw.py --- a/mercurial/templatekw.py Sat Jul 04 23:11:32 2015 -0400 +++ b/mercurial/templatekw.py Fri Jun 26 23:11:05 2015 -0400 @@ -334,6 +334,19 @@ """:latesttagdistance: Integer. Longest path to the latest tag.""" return getlatesttags(repo, ctx, cache)[1] +def showchangessincelatesttag(repo, ctx, templ, cache, **args): + """:changessincelatesttag: Integer. All ancestors not in the latest tag.""" + latesttag = getlatesttags(repo, ctx, cache)[2][0] + offset = 0 + revs = [ctx.rev()] + + # The only() revset doesn't currently support wdir() + if ctx.rev() is None: + offset = 1 + revs = [p.rev() for p in ctx.parents()] + + return len(repo.revs('only(%ld, %s)', revs, latesttag)) + offset + def showmanifest(**args): repo, ctx, templ = args['repo'], args['ctx'], args['templ'] mnode = ctx.manifestnode() @@ -427,6 +440,7 @@ 'branch': showbranch, 'branches': showbranches, 'bookmarks': showbookmarks, + 'changessincelatesttag': showchangessincelatesttag, 'children': showchildren, # currentbookmark is deprecated 'currentbookmark': showcurrentbookmark,