# HG changeset patch # User Pierre-Yves David # Date 1320668422 -3600 # Node ID abcaaf51d56805d518f713bc1923dbc5e29a8ebe # Parent c6f87bdab2a10610ac2ac2ebb432d68f1c7496f7 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 diff -r c6f87bdab2a1 -r abcaaf51d568 mercurial/localrepo.py --- a/mercurial/localrepo.py Mon Nov 07 12:27:25 2011 +0100 +++ b/mercurial/localrepo.py Mon Nov 07 13:20:22 2011 +0100 @@ -174,7 +174,9 @@ @filecache('phaseroots') def _phaseroots(self): self._dirtyphases = False - return phases.readroots(self) + phaseroots = phases.readroots(self) + phases.filterunknown(self, phaseroots) + return phaseroots @propertycache def _phaserev(self): diff -r c6f87bdab2a1 -r abcaaf51d568 mercurial/phases.py --- 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. diff -r c6f87bdab2a1 -r abcaaf51d568 mercurial/repair.py --- a/mercurial/repair.py Mon Nov 07 12:27:25 2011 +0100 +++ b/mercurial/repair.py Mon Nov 07 13:20:22 2011 +0100 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. -from mercurial import changegroup, bookmarks +from mercurial import changegroup, bookmarks, phases from mercurial.node import short from mercurial.i18n import _ import os @@ -145,7 +145,9 @@ for m in updatebm: bm[m] = repo['.'].node() bookmarks.write(repo) - + # remove potential unknown phase + # XXX using to_strip data would be faster + phases.filterunknown(repo) except: if backupfile: ui.warn(_("strip failed, full bundle stored in '%s'\n")