diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1349,7 +1349,7 @@ class changeset_printer(object): hexfunc = short # as of now, wctx.node() and wctx.rev() return None, but we want to # show the same values as {node} and {rev} templatekw - revnode = (scmutil.intrev(rev), hexfunc(bin(ctx.hex()))) + revnode = (scmutil.intrev(ctx), hexfunc(bin(ctx.hex()))) if self.ui.quiet: self.ui.write("%d:%s\n" % revnode, label='log.node') diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -376,9 +376,10 @@ def walkrepos(path, followsym=False, see newdirs.append(d) dirs[:] = newdirs -def intrev(rev): - """Return integer for a given revision that can be used in comparison or +def intrev(ctx): + """Return integer for a given basectx that can be used in comparison or arithmetic operation""" + rev = ctx.rev() if rev is None: return wdirrev return rev @@ -466,7 +467,7 @@ def meaningfulparents(repo, ctx): return parents if repo.ui.debugflag: return [parents[0], repo['null']] - if parents[0].rev() >= intrev(ctx.rev()) - 1: + if parents[0].rev() >= intrev(ctx) - 1: return [] return parents diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -161,7 +161,7 @@ def _formatrevnode(ctx): hexnode = ctx.hex() else: hexnode = ctx.hex()[:12] - return '%d:%s' % (scmutil.intrev(ctx.rev()), hexnode) + return '%d:%s' % (scmutil.intrev(ctx), hexnode) def getfiles(repo, ctx, revcache): if 'files' not in revcache: @@ -611,7 +611,7 @@ def showphaseidx(repo, ctx, templ, **arg @templatekeyword('rev') def showrev(repo, ctx, templ, **args): """Integer. The repository-local changeset revision number.""" - return scmutil.intrev(ctx.rev()) + return scmutil.intrev(ctx) def showrevslist(name, revs, **args): """helper to generate a list of revisions in which a mapped template will