# HG changeset patch # User Yuya Nishihara # Date 1496483848 -32400 # Node ID 4bec8cce6a099e562edc7b9f6246e10d2b829fc5 # Parent 7dab4c0cdb41fb19f2fe4e069864c5aa043b31e7 scmutil: pass ctx object to intrev() This makes it slightly easier to sort basectx objects by key=scmutil.intrev. We're most likely to have ctx objects where changectx/workingctx abstraction is necessary, so this won't increase the abstraction overhead. diff -r 7dab4c0cdb41 -r 4bec8cce6a09 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Sat Jun 03 14:05:52 2017 +0900 +++ b/mercurial/cmdutil.py Sat Jun 03 18:57:28 2017 +0900 @@ -1349,7 +1349,7 @@ 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 -r 7dab4c0cdb41 -r 4bec8cce6a09 mercurial/scmutil.py --- a/mercurial/scmutil.py Sat Jun 03 14:05:52 2017 +0900 +++ b/mercurial/scmutil.py Sat Jun 03 18:57:28 2017 +0900 @@ -376,9 +376,10 @@ 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 @@ 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 -r 7dab4c0cdb41 -r 4bec8cce6a09 mercurial/templatekw.py --- a/mercurial/templatekw.py Sat Jun 03 14:05:52 2017 +0900 +++ b/mercurial/templatekw.py Sat Jun 03 18:57:28 2017 +0900 @@ -161,7 +161,7 @@ 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 @@ @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