Mercurial > hg
changeset 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 | c6f87bdab2a1 |
children | 1470f8b00694 |
files | mercurial/localrepo.py mercurial/phases.py mercurial/repair.py |
diffstat | 3 files changed, 25 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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):
--- 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.
--- 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")