mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 15:57:43 +03:00
phases: extract the core of boundary retraction in '_retractboundary'
At the moment the 'retractboundary' function is called for multiple reasons: First, actually retracting boundaries. There are only two cases for theses: 'hg phase --force' and 'hg qimport'. This will need extra graph computation to retrieve the phase changes. Second, setting the phases of newly added changesets. In this case we already know all the affected nodes and we just needs to register different information (old phase is None). Third, when reducing the set of roots when advancing phase. The phase are already properly tracked so we do not needs anything else in this case. To deal with this difference in phase tracking, we extract the core logic into a private method that all three cases can use.
This commit is contained in:
parent
794ac05dda
commit
3de612f757
@ -331,10 +331,14 @@ class phasecache(object):
|
||||
delroots.extend(olds - roots)
|
||||
# declare deleted root in the target phase
|
||||
if targetphase != 0:
|
||||
self.retractboundary(repo, tr, targetphase, delroots)
|
||||
self._retractboundary(repo, tr, targetphase, delroots)
|
||||
repo.invalidatevolatilesets()
|
||||
|
||||
def retractboundary(self, repo, tr, targetphase, nodes):
|
||||
self._retractboundary(repo, tr, targetphase, nodes)
|
||||
repo.invalidatevolatilesets()
|
||||
|
||||
def _retractboundary(self, repo, tr, targetphase, nodes):
|
||||
# Be careful to preserve shallow-copied values: do not update
|
||||
# phaseroots values, replace them.
|
||||
|
||||
@ -343,6 +347,7 @@ class phasecache(object):
|
||||
newroots = [n for n in nodes
|
||||
if self.phase(repo, repo[n].rev()) < targetphase]
|
||||
if newroots:
|
||||
|
||||
if nullid in newroots:
|
||||
raise error.Abort(_('cannot change null revision phase'))
|
||||
currentroots = currentroots.copy()
|
||||
@ -360,7 +365,6 @@ class phasecache(object):
|
||||
finalroots.update(ctx.node() for ctx in updatedroots)
|
||||
|
||||
self._updateroots(targetphase, finalroots, tr)
|
||||
repo.invalidatevolatilesets()
|
||||
|
||||
def filterunknown(self, repo):
|
||||
"""remove unknown nodes from the phase boundary
|
||||
|
Loading…
Reference in New Issue
Block a user