comparison mercurial/scmutil.py @ 32656:4bec8cce6a09

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.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Jun 2017 18:57:28 +0900
parents 218ca8526ec0
children 55ff67ffcead
comparison
equal deleted inserted replaced
32655:7dab4c0cdb41 32656:4bec8cce6a09
374 yield hgname 374 yield hgname
375 else: 375 else:
376 newdirs.append(d) 376 newdirs.append(d)
377 dirs[:] = newdirs 377 dirs[:] = newdirs
378 378
379 def intrev(rev): 379 def intrev(ctx):
380 """Return integer for a given revision that can be used in comparison or 380 """Return integer for a given basectx that can be used in comparison or
381 arithmetic operation""" 381 arithmetic operation"""
382 rev = ctx.rev()
382 if rev is None: 383 if rev is None:
383 return wdirrev 384 return wdirrev
384 return rev 385 return rev
385 386
386 def revsingle(repo, revspec, default='.'): 387 def revsingle(repo, revspec, default='.'):
464 parents = ctx.parents() 465 parents = ctx.parents()
465 if len(parents) > 1: 466 if len(parents) > 1:
466 return parents 467 return parents
467 if repo.ui.debugflag: 468 if repo.ui.debugflag:
468 return [parents[0], repo['null']] 469 return [parents[0], repo['null']]
469 if parents[0].rev() >= intrev(ctx.rev()) - 1: 470 if parents[0].rev() >= intrev(ctx) - 1:
470 return [] 471 return []
471 return parents 472 return parents
472 473
473 def expandpats(pats): 474 def expandpats(pats):
474 '''Expand bare globs when running on windows. 475 '''Expand bare globs when running on windows.