# HG changeset patch # User Patrick Mezard # Date 1336666875 -7200 # Node ID 3f85cef66dcc5ff35aa2a4e6eb66ec640ddcacc7 # Parent def6a19c3b4d5b58fc0043a0e9ef20c63155e125 phases: call filterunknown() in readroots() One less function manipulating localrepo state. diff -r def6a19c3b4d -r 3f85cef66dcc mercurial/localrepo.py --- a/mercurial/localrepo.py Thu May 10 18:21:15 2012 +0200 +++ b/mercurial/localrepo.py Thu May 10 18:21:15 2012 +0200 @@ -185,7 +185,6 @@ def _phaseroots(self): self._dirtyphases = False phaseroots = phases.readroots(self) - phases.filterunknown(self, phaseroots) return phaseroots @propertycache diff -r def6a19c3b4d -r 3f85cef66dcc mercurial/phases.py --- a/mercurial/phases.py Thu May 10 18:21:15 2012 +0200 +++ b/mercurial/phases.py Thu May 10 18:21:15 2012 +0200 @@ -106,6 +106,24 @@ trackedphases = allphases[1:] phasenames = ['public', 'draft', 'secret'] +def _filterunknown(ui, changelog, phaseroots): + """remove unknown nodes from the phase boundary + + Nothing is lost as unknown nodes only hold data for their descendants + """ + updated = False + nodemap = changelog.nodemap # to filter unknown nodes + for phase, nodes in enumerate(phaseroots): + missing = [node for node in nodes if node not in nodemap] + if missing: + for mnode in missing: + ui.debug( + 'removing unknown node %s from %i-phase boundary\n' + % (short(mnode), phase)) + nodes.symmetric_difference_update(missing) + updated = True + return updated + def readroots(repo): """Read phase roots from disk""" roots = [set() for i in allphases] @@ -123,6 +141,8 @@ for f in repo._phasedefaults: roots = f(repo, roots) repo._dirtyphases = True + if _filterunknown(repo.ui, repo.changelog, roots): + repo._dirtyphases = True return roots def writeroots(repo): @@ -136,24 +156,6 @@ 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 - nodemap = repo.changelog.nodemap # to filter unknown nodes - for phase, nodes in enumerate(phaseroots): - missing = [node for node in nodes if node not in nodemap] - if missing: - for mnode in missing: - repo.ui.debug( - 'removing unknown node %s from %i-phase boundary\n' - % (short(mnode), phase)) - nodes.symmetric_difference_update(missing) - repo._dirtyphases = True - def advanceboundary(repo, targetphase, nodes): """Add nodes to a phase changing other nodes phases if necessary.