phases: track phase movements in 'advanceboundary'

Makes advanceboundary record the phase movement of affected revisions in
tr.changes['phases'].

The tracking is not usable yet because the 'retractboundary' function can also
affect phases.

We'll improve that in the coming changesets.
This commit is contained in:
Boris Feld 2017-07-11 02:39:52 +02:00
parent e0ae9be376
commit 794ac05dda
2 changed files with 22 additions and 0 deletions

View File

@ -1216,6 +1216,7 @@ class localrepository(object):
checkambigfiles=_cachedfiles) checkambigfiles=_cachedfiles)
tr.changes['revs'] = set() tr.changes['revs'] = set()
tr.changes['obsmarkers'] = set() tr.changes['obsmarkers'] = set()
tr.changes['phases'] = {}
tr.hookargs['txnid'] = txnid tr.hookargs['txnid'] = txnid
# note: writing the fncache only during finalize mean that the file is # note: writing the fncache only during finalize mean that the file is

View File

@ -154,6 +154,18 @@ def _readroots(repo, phasedefaults=None):
dirty = True dirty = True
return roots, dirty return roots, dirty
def _trackphasechange(data, rev, old, new):
"""add a phase move the <data> dictionnary
If data is None, nothing happens.
"""
if data is None:
return
existing = data.get(rev)
if existing is not None:
old = existing[0]
data[rev] = (old, new)
class phasecache(object): class phasecache(object):
def __init__(self, repo, phasedefaults, _load=True): def __init__(self, repo, phasedefaults, _load=True):
if _load: if _load:
@ -289,8 +301,13 @@ class phasecache(object):
""" """
# Be careful to preserve shallow-copied values: do not update # Be careful to preserve shallow-copied values: do not update
# phaseroots values, replace them. # phaseroots values, replace them.
if tr is None:
phasetracking = None
else:
phasetracking = tr.changes.get('phases')
repo = repo.unfiltered() repo = repo.unfiltered()
delroots = [] # set of root deleted by this path delroots = [] # set of root deleted by this path
for phase in xrange(targetphase + 1, len(allphases)): for phase in xrange(targetphase + 1, len(allphases)):
# filter nodes that are not in a compatible phase already # filter nodes that are not in a compatible phase already
@ -300,7 +317,11 @@ class phasecache(object):
break # no roots to move anymore break # no roots to move anymore
olds = self.phaseroots[phase] olds = self.phaseroots[phase]
affected = repo.revs('%ln::%ln', olds, nodes) affected = repo.revs('%ln::%ln', olds, nodes)
for r in affected:
_trackphasechange(phasetracking, r, self.phase(repo, r),
targetphase)
roots = set(ctx.node() for ctx in repo.set( roots = set(ctx.node() for ctx in repo.set(
'roots((%ln::) - %ld)', olds, affected)) 'roots((%ln::) - %ld)', olds, affected))