comparison mercurial/phases.py @ 33458:cf694e6422f0

phases: track phase changes from 'retractboundary' We adds new computation to find and record the revision affected by the boundary retraction. This add more complication to the function but this seems fine since it is only used in a couple of rare and explicit cases (`hg phase --force` and `hg qimport`). Having strong tracking of phase changes is worth the effort.
author Boris Feld <boris.feld@octobus.net>
date Wed, 12 Jul 2017 20:11:00 +0200
parents 61714c282106
children 57a017f79e96
comparison
equal deleted inserted replaced
33457:61714c282106 33458:cf694e6422f0
346 if targetphase != 0: 346 if targetphase != 0:
347 self._retractboundary(repo, tr, targetphase, delroots) 347 self._retractboundary(repo, tr, targetphase, delroots)
348 repo.invalidatevolatilesets() 348 repo.invalidatevolatilesets()
349 349
350 def retractboundary(self, repo, tr, targetphase, nodes): 350 def retractboundary(self, repo, tr, targetphase, nodes):
351 self._retractboundary(repo, tr, targetphase, nodes) 351 oldroots = self.phaseroots[:targetphase + 1]
352 if tr is None:
353 phasetracking = None
354 else:
355 phasetracking = tr.changes.get('phases')
356 repo = repo.unfiltered()
357 if (self._retractboundary(repo, tr, targetphase, nodes)
358 and phasetracking is not None):
359
360 # find the affected revisions
361 new = self.phaseroots[targetphase]
362 old = oldroots[targetphase]
363 affected = set(repo.revs('(%ln::) - (%ln::)', new, old))
364
365 # find the phase of the affected revision
366 for phase in xrange(targetphase, -1, -1):
367 if phase:
368 roots = oldroots[phase]
369 revs = set(repo.revs('%ln::%ld', roots, affected))
370 affected -= revs
371 else: # public phase
372 revs = affected
373 for r in revs:
374 _trackphasechange(phasetracking, r, phase, targetphase)
352 repo.invalidatevolatilesets() 375 repo.invalidatevolatilesets()
353 376
354 def _retractboundary(self, repo, tr, targetphase, nodes): 377 def _retractboundary(self, repo, tr, targetphase, nodes):
355 # Be careful to preserve shallow-copied values: do not update 378 # Be careful to preserve shallow-copied values: do not update
356 # phaseroots values, replace them. 379 # phaseroots values, replace them.