[PATCH 7 of 8 phases] phases: mechanism to allow extension to alter initial computation of phase
Matt Mackall
mpm at selenic.com
Tue Jan 17 17:01:27 CST 2012
On Tue, 2012-01-17 at 18:35 +0100, pierre-yves.david at logilab.fr wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1326821506 -3600
> # Node ID b4680e030682a7fad6cc7226f03b9ead203f84b6
> # Parent 1b22ef5905a472f8264839b3eb70091666e61205
> 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 --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -35,10 +35,14 @@ class localrepository(repo.repository):
> self.opener = scmutil.opener(self.path)
> self.wopener = scmutil.opener(self.root)
> 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._whennophasedata = []
Not excited about this name. How about _phasedefaults?
> try:
> self.ui.readconfig(self.join("hgrc"), self.root)
> extensions.loadall(self.ui)
> except IOError:
> diff --git a/mercurial/phases.py b/mercurial/phases.py
> --- a/mercurial/phases.py
> +++ b/mercurial/phases.py
> @@ -107,11 +107,10 @@ trackedphases = allphases[1:]
> phasenames = ['public', 'draft', 'secret']
>
> def readroots(repo):
> """Read phase roots from disk"""
> roots = [set() for i in allphases]
> - roots[0].add(nullid)
> try:
> f = repo.sopener('phaseroots')
> try:
> for line in f:
> phase, nh = line.strip().split()
> @@ -119,10 +118,13 @@ def readroots(repo):
> finally:
> f.close()
> except IOError, inst:
> if inst.errno != errno.ENOENT:
> raise
> + for wnd in repo._whennophasedata:
> + roots = wnd(repo, roots)
> + assert roots is not None, '%r forgot to return a value' % wnd
asserts are discouraged. With or without, we get a traceback in the
field, so why bother?
> return roots
>
> def writeroots(repo):
> """Write phase roots from disk"""
> f = repo.sopener('phaseroots', 'w', atomictemp=True)
> diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
> --- a/mercurial/statichttprepo.py
> +++ b/mercurial/statichttprepo.py
> @@ -84,10 +84,11 @@ class statichttprepository(localrepo.loc
> u = util.url(path.rstrip('/') + "/.hg")
> self.path, authinfo = u.authinfo()
>
> opener = build_opener(ui, authinfo)
> self.opener = opener(self.path)
> + self._whennophasedata = []
Why is this needed? Doesn't inheritance take care of this? Or are we
clearing it out again?
If the latter, then I think we need to explicitly tweak statichttp to
act like publish=True instead.
> try:
> requirements = scmutil.readrequires(self.opener, self.supported)
> except IOError, inst:
> if inst.errno != errno.ENOENT:
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list