changeset 15420:e80d0d3198f0

phases: add a cache allowing to know in which phase a changeset is
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 04 Nov 2011 00:20:20 +0100
parents ccb7de21625a
children 405ca90df2b1
files mercurial/localrepo.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sun Nov 06 11:57:24 2011 -0600
+++ b/mercurial/localrepo.py	Fri Nov 04 00:20:20 2011 +0100
@@ -174,6 +174,18 @@
     def _phaseroots(self):
         return phases.readroots(self)
 
+    @propertycache
+    def _phaserev(self):
+        cache = [0] * len(self)
+        for phase in phases.trackedphases:
+            roots = map(self.changelog.rev, self._phaseroots[phase])
+            if roots:
+                for rev in roots:
+                    cache[rev] = phase
+                for rev in self.changelog.descendants(*roots):
+                    cache[rev] = phase
+        return cache
+
     @filecache('00changelog.i', True)
     def changelog(self):
         c = changelog.changelog(self.sopener)