phases: add a cache allowing to know in which phase a changeset is
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 04 Nov 2011 00:20:20 +0100
changeset 15420 e80d0d3198f0
parent 15419 ccb7de21625a
child 15421 405ca90df2b1
phases: add a cache allowing to know in which phase a changeset is
mercurial/localrepo.py
--- 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)