# HG changeset patch # User Pierre-Yves David # Date 1326903834 -3600 # Node ID 23921c17299a1f3b2d0f0c12cc778181a4669fc6 # Parent 92e455f2866cd51ac48866fd48c1587eb10bda1a phases: mechanism to allow extension to alter initial computation of phase This commit add a whennodata list where extension can register a callback to be called if no phase related data are found in the repository. The goal is to ensure the existing extension that move phase data in 2.1 can compute consistent phase boundary for existing repo. diff -r 92e455f2866c -r 23921c17299a mercurial/localrepo.py --- a/mercurial/localrepo.py Wed Jan 18 17:11:27 2012 +0100 +++ b/mercurial/localrepo.py Wed Jan 18 17:23:54 2012 +0100 @@ -37,6 +37,10 @@ self.baseui = baseui self.ui = baseui.copy() self._dirtyphases = False + # A list of callback to shape the phase if no data were found. + # Callback are in the form: func(repo, roots) --> processed root. + # This list it to be filled by extension during repo setup + self._phasedefaults = [] try: self.ui.readconfig(self.join("hgrc"), self.root) diff -r 92e455f2866c -r 23921c17299a mercurial/phases.py --- a/mercurial/phases.py Wed Jan 18 17:11:27 2012 +0100 +++ b/mercurial/phases.py Wed Jan 18 17:23:54 2012 +0100 @@ -109,7 +109,6 @@ def readroots(repo): """Read phase roots from disk""" roots = [set() for i in allphases] - roots[0].add(nullid) try: f = repo.sopener('phaseroots') try: @@ -121,6 +120,8 @@ except IOError, inst: if inst.errno != errno.ENOENT: raise + for f in repo._phasedefaults: + roots = f(repo, roots) return roots def writeroots(repo): diff -r 92e455f2866c -r 23921c17299a mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py Wed Jan 18 17:11:27 2012 +0100 +++ b/mercurial/statichttprepo.py Wed Jan 18 17:23:54 2012 +0100 @@ -86,6 +86,7 @@ opener = build_opener(ui, authinfo) self.opener = opener(self.path) + self._phasedefaults = [] try: requirements = scmutil.readrequires(self.opener, self.supported)