Mercurial > public > mercurial-scm > hg-stable
diff mercurial/phases.py @ 15456:abcaaf51d568
phases: handle unknown nodes in boundary
We filter unknown node out of the boundary. No data is lost. A
filtering is explicitly done after strip too
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 07 Nov 2011 13:20:22 +0100 |
parents | 5a7dde5adec8 |
children | 7d4f364c980b |
line wrap: on
line diff
--- a/mercurial/phases.py Mon Nov 07 12:27:25 2011 +0100 +++ b/mercurial/phases.py Mon Nov 07 13:20:22 2011 +0100 @@ -8,7 +8,8 @@ # GNU General Public License version 2 or any later version. import errno -from node import nullid, bin, hex +from node import nullid, bin, hex, short +from i18n import _ allphases = range(2) trackedphases = allphases[1:] @@ -41,6 +42,22 @@ finally: f.close() +def filterunknown(repo, phaseroots=None): + """remove unknown nodes from the phase boundary + + no data is lost as unknown node only old data for their descentants + """ + if phaseroots is None: + phaseroots = repo._phaseroots + for phase, nodes in enumerate(phaseroots): + missing = [node for node in nodes if node not in repo] + if missing: + for mnode in missing: + msg = _('Removing unknown node %(n)s from %(p)i-phase boundary') + repo.ui.debug(msg, {'n': short(mnode), 'p': phase}) + nodes.symmetric_difference_update(missing) + repo._dirtyphases = True + def moveboundary(repo, target_phase, nodes): """Add nodes to a phase changing other nodes phases if necessary.