Patchwork [3,of,6,V2] templatekw: factor out the changessincetag calculation to a private method

login
register
mail settings
Submitter Matt Harbison
Date Oct. 6, 2015, 1:40 a.m.
Message ID <c974da0b9203471fcb0a.1444095655@Envy>
Download mbox | patch
Permalink /patch/10824/
State Accepted
Commit e94f93043a4ee3372fef61167850f2b16e4d3ba3
Headers show

Comments

Matt Harbison - Oct. 6, 2015, 1:40 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1444093910 14400
#      Mon Oct 05 21:11:50 2015 -0400
# Node ID c974da0b9203471fcb0a640a4837b247056c8b23
# Parent  7587015a4110d288d382095afb48daf8048c4e4e
templatekw: factor out the changessincetag calculation to a private method

This will be reused in the next patch.

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -357,15 +357,20 @@ 
 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']