# HG changeset patch # User Matt Harbison # Date 2015-10-06 01:11:50 # Node ID e94f93043a4ee3372fef61167850f2b16e4d3ba3 # Parent d2e69584e330f152d634fbc0e3907df84420b012 templatekw: factor out the changessincetag calculation to a private method This will be reused in the next patch. diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -357,15 +357,20 @@ def showlatesttagdistance(repo, ctx, tem def showchangessincelatesttag(repo, ctx, templ, cache, **args): """:changessincelatesttag: Integer. All ancestors not in the latest tag.""" latesttag = getlatesttags(repo, ctx, cache)[2][0] + + return _showchangessincetag(repo, ctx, tag=latesttag, **args) + +def _showchangessincetag(repo, ctx, **args): offset = 0 revs = [ctx.rev()] + tag = args['tag'] # 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 + return len(repo.revs('only(%ld, %s)', revs, tag)) + offset def showmanifest(**args): repo, ctx, templ = args['repo'], args['ctx'], args['templ']