phases: improve context.phase()
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Mon, 07 Nov 2011 18:37:58 +0100
changeset 15453 cff509500a24
parent 15452 de7e2fba4326
child 15454 5a7dde5adec8
phases: improve context.phase() * force recompute of outdated cache * handle nullrev case
mercurial/context.py
--- a/mercurial/context.py	Mon Nov 07 03:25:10 2011 +0100
+++ b/mercurial/context.py	Mon Nov 07 18:37:58 2011 +0100
@@ -118,6 +118,11 @@
     def bookmarks(self):
         return self._repo.nodebookmarks(self._node)
     def phase(self):
+        if self._rev == -1:
+            return 0
+        if self._rev >= len(self._repo._phaserev):
+            # outdated cache
+            del self._repo._phaserev
         return self._repo._phaserev[self._rev]
     def hidden(self):
         return self._rev in self._repo.changelog.hiddenrevs