[PATCH 03 of 12] phases: add a cache allowing to know in which phase a changeset is

Matt Mackall mpm at selenic.com
Tue Oct 18 13:55:54 CDT 2011


On Tue, 2011-10-18 at 19:27 +0200, pierre-yves.david at logilab.fr wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1318955107 -7200
> # Node ID d8381a929be96f1320becc6b05a68a043900b420
> # Parent  6fd51910bd8bed80307f29fd5a536cfbeab0a9f6
> phases: add a cache allowing to know in which phase a changeset is
> 
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -172,10 +172,25 @@ class localrepository(repo.repository):
>  
>      @filecache('phaseheads')
>      def _phaseheads(self):
>          return phases.readheads(self)
>  
> +    @propertycache
> +    def _phaserev(self):
> +        cache = [phases.allphases[-1]] * len(self)
> +        for phase in reversed(phases.trackedphases):
> +            heads = map(self.changelog.rev, self._phaseheads[phase])
> +            # we probably have majority of lower state changeset
> +            for rev in heads:
> +                if rev == -1:

nullrev, please.

> diff --git a/mercurial/phases.py b/mercurial/phases.py
> --- a/mercurial/phases.py
> +++ b/mercurial/phases.py
> @@ -36,5 +36,6 @@ def writeheads(repo):
>          for phase, heads in enumerate(repo._phaseheads):
>              for h in heads:
>                  f.write('%i %s\n' % (phase, hex(h)))
>      finally:
>          f.close()
> +

Oops.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list