mercurial/phases.py
changeset 15454 5a7dde5adec8
parent 15419 ccb7de21625a
child 15456 abcaaf51d568
equal deleted inserted replaced
15453:cff509500a24 15454:5a7dde5adec8
    35     f = repo.sopener('phaseroots', 'w', atomictemp=True)
    35     f = repo.sopener('phaseroots', 'w', atomictemp=True)
    36     try:
    36     try:
    37         for phase, roots in enumerate(repo._phaseroots):
    37         for phase, roots in enumerate(repo._phaseroots):
    38             for h in roots:
    38             for h in roots:
    39                 f.write('%i %s\n' % (phase, hex(h)))
    39                 f.write('%i %s\n' % (phase, hex(h)))
       
    40         repo._dirtyphases = False
    40     finally:
    41     finally:
    41         f.close()
    42         f.close()
       
    43 
       
    44 def moveboundary(repo, target_phase, nodes):
       
    45     """Add nodes to a phase changing other nodes phases if necessary.
       
    46 
       
    47     Simplify boundary to contains phase roots only."""
       
    48 
       
    49     # move roots of lower states
       
    50     for phase in xrange(target_phase + 1, len(allphases)):
       
    51         # filter nodes that are not in a compatible phase already
       
    52         # XXX rev phase cache might have been invalidated by a previous loop
       
    53         # XXX we need to be smarter here
       
    54         nodes = [n for n in nodes if repo[n].phase() >= phase]
       
    55         if not nodes:
       
    56             break # no roots to move anymore
       
    57         roots = repo._phaseroots[phase]
       
    58         olds = roots.copy()
       
    59         ctxs = list(repo.set('roots((%ln::) - (%ln::%ln))', olds, olds, nodes))
       
    60         roots.clear()
       
    61         roots.update(ctx.node() for ctx in ctxs)
       
    62         if olds != roots:
       
    63             # invalidate cache (we probably could be smarter here
       
    64             if '_phaserev' in vars(repo):
       
    65                 del repo._phaserev
       
    66             repo._dirtyphases = True