comparison 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
comparison
equal deleted inserted replaced
24581:85219d6ece67 24582:56fff44cce98
580 _rcpath.append(p) 580 _rcpath.append(p)
581 else: 581 else:
582 _rcpath = osrcpath() 582 _rcpath = osrcpath()
583 return _rcpath 583 return _rcpath
584 584
585 def intrev(repo, rev):
586 """Return integer for a given revision that can be used in comparison or
587 arithmetic operation"""
588 if rev is None:
589 return len(repo)
590 return rev
591
585 def revsingle(repo, revspec, default='.'): 592 def revsingle(repo, revspec, default='.'):
586 if not revspec and revspec != 0: 593 if not revspec and revspec != 0:
587 return repo[default] 594 return repo[default]
588 595
589 l = revrange(repo, [revspec]) 596 l = revrange(repo, [revspec])