Mercurial > hg-stable
diff mercurial/scmutil.py @ 24582:56fff44cce98
scmutil: add function to help handling workingctx in arithmetic operation
It's unfortunate that workingctx revision is None, which doesn't work well in
arithmetic operation or comparison. This function is trivial but will be used
in several places.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 14 Mar 2015 19:38:59 +0900 |
parents | d44d53bc9a1e |
children | a0b47885a1c5 |
line wrap: on
line diff
--- a/mercurial/scmutil.py Thu Apr 02 08:18:33 2015 +0200 +++ b/mercurial/scmutil.py Sat Mar 14 19:38:59 2015 +0900 @@ -582,6 +582,13 @@ _rcpath = osrcpath() return _rcpath +def intrev(repo, rev): + """Return integer for a given revision that can be used in comparison or + arithmetic operation""" + if rev is None: + return len(repo) + return rev + def revsingle(repo, revspec, default='.'): if not revspec and revspec != 0: return repo[default]