diff --git a/mercurial/phases.py b/mercurial/phases.py --- a/mercurial/phases.py +++ b/mercurial/phases.py @@ -352,7 +352,7 @@ _trackphasechange(phasetracking, rev, None, revphase) repo.invalidatevolatilesets() - def advanceboundary(self, repo, tr, targetphase, nodes): + def advanceboundary(self, repo, tr, targetphase, nodes, dryrun=None): """Set all 'nodes' to phase 'targetphase' Nodes with a phase lower than 'targetphase' are not affected. @@ -366,6 +366,13 @@ repo = repo.unfiltered() + rejected = list() + changes = [set(), set(), set()] + if dryrun: + getphase = repo._phasecache.phase + rejected = [repo[n].rev() for n in nodes + if getphase(repo, repo[n].rev()) < targetphase] + delroots = [] # set of root deleted by this path for phase in xrange(targetphase + 1, len(allphases)): # filter nodes that are not in a compatible phase already @@ -377,20 +384,28 @@ olds = self.phaseroots[phase] affected = repo.revs('%ln::%ln', olds, nodes) - for r in affected: - _trackphasechange(phasetracking, r, self.phase(repo, r), - targetphase) + if dryrun: + faffected = filter(lambda x: getphase(repo, + repo[x].rev()) == phase, + affected) + changes[phase].update(faffected) + else: + for r in affected: + _trackphasechange(phasetracking, r, self.phase(repo, r), + targetphase) - roots = set(ctx.node() for ctx in repo.set( - 'roots((%ln::) - %ld)', olds, affected)) - if olds != roots: - self._updateroots(phase, roots, tr) - # some roots may need to be declared for lower phases - delroots.extend(olds - roots) - # declare deleted root in the target phase - if targetphase != 0: - self._retractboundary(repo, tr, targetphase, delroots) - repo.invalidatevolatilesets() + roots = set(ctx.node() for ctx in repo.set( + 'roots((%ln::) - %ld)', olds, affected)) + if olds != roots: + self._updateroots(phase, roots, tr) + # some roots may need to be declared for lower phases + delroots.extend(olds - roots) + if not dryrun: + # declare deleted root in the target phase + if targetphase != 0: + self._retractboundary(repo, tr, targetphase, delroots) + repo.invalidatevolatilesets() + return rejected, changes def retractboundary(self, repo, tr, targetphase, nodes): oldroots = self.phaseroots[:targetphase + 1] @@ -478,7 +493,7 @@ # (see branchmap one) self.invalidate() -def advanceboundary(repo, tr, targetphase, nodes): +def advanceboundary(repo, tr, targetphase, nodes, dryrun=None): """Add nodes to a phase changing other nodes phases if necessary. This function move boundary *forward* this means that all nodes @@ -486,8 +501,11 @@ Simplify boundary to contains phase roots only.""" phcache = repo._phasecache.copy() - phcache.advanceboundary(repo, tr, targetphase, nodes) - repo._phasecache.replace(phcache) + rejected, changes = phcache.advanceboundary(repo, tr, targetphase, nodes, + dryrun=dryrun) + if not dryrun: + repo._phasecache.replace(phcache) + return rejected, changes def retractboundary(repo, tr, targetphase, nodes): """Set nodes back to a phase changing other nodes phases if