comparison mercurial/commands.py @ 16657:b6081c2c4647

phases: introduce phasecache The original motivation was changectx.phase() had special logic to correctly lookup in repo._phaserev, including invalidating it when necessary. And at other places, repo._phaserev was accessed directly. This led to the discovery that phases state including _phaseroots, _phaserev and _dirtyphase was manipulated in localrepository.py, phases.py, repair.py, etc. phasecache helps encapsulating that. This patch replaces all phase state in localrepo with phasecache and adjust related code except for advance/retractboundary() in phases. These still access to phasecache internals directly. This will be addressed in a followup.
author Patrick Mezard <patrick@mezard.eu>
date Sat, 12 May 2012 00:24:07 +0200
parents 1388cc711ea7
children 58edd786e96f
comparison
equal deleted inserted replaced
16656:4ae3ba9e4d7a 16657:b6081c2c4647
4376 try: 4376 try:
4377 # set phase 4377 # set phase
4378 nodes = [ctx.node() for ctx in repo.set('%ld', revs)] 4378 nodes = [ctx.node() for ctx in repo.set('%ld', revs)]
4379 if not nodes: 4379 if not nodes:
4380 raise util.Abort(_('empty revision set')) 4380 raise util.Abort(_('empty revision set'))
4381 olddata = repo._phaserev[:] 4381 olddata = repo._phasecache.getphaserevs(repo)[:]
4382 phases.advanceboundary(repo, targetphase, nodes) 4382 phases.advanceboundary(repo, targetphase, nodes)
4383 if opts['force']: 4383 if opts['force']:
4384 phases.retractboundary(repo, targetphase, nodes) 4384 phases.retractboundary(repo, targetphase, nodes)
4385 finally: 4385 finally:
4386 lock.release() 4386 lock.release()
4387 if olddata is not None: 4387 if olddata is not None:
4388 changes = 0 4388 changes = 0
4389 newdata = repo._phaserev 4389 newdata = repo._phasecache.getphaserevs(repo)
4390 changes = sum(o != newdata[i] for i, o in enumerate(olddata)) 4390 changes = sum(o != newdata[i] for i, o in enumerate(olddata))
4391 rejected = [n for n in nodes 4391 rejected = [n for n in nodes
4392 if newdata[repo[n].rev()] < targetphase] 4392 if newdata[repo[n].rev()] < targetphase]
4393 if rejected: 4393 if rejected:
4394 ui.warn(_('cannot move %i changesets to a more permissive ' 4394 ui.warn(_('cannot move %i changesets to a more permissive '