changeset 20:9983f240ac63

Smarter states heads. We use the next relevant heads instead of repo one when asking for the head of a disabled state.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Mon, 06 Jun 2011 16:52:03 +0200
parents 8784a989a572
children aa0870d093b8
files states.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/states.py	Mon Jun 06 15:30:43 2011 +0200
+++ b/states.py	Mon Jun 06 16:52:03 2011 +0200
@@ -78,6 +78,10 @@
         else:
             return 'heads'
 
+    def enabled(self, ui):
+        return ui.configbool('states', self.name, False)
+
+
 ST2 = state('draft', _NOSHARE | _MUTABLE)
 ST1 = state('ready', _MUTABLE, next=ST2)
 ST0 = state('published', next=ST1)
@@ -188,9 +192,12 @@
 
 
         def stateheads(self, state):
+            # look for a relevant state
+            while state.trackheads and not state.next.enabled(self.ui):
+                state = state.next
+            # last state have no cached head.
             if state.trackheads:
-                if self.ui.configbool('states', state.next.name, False):
-                    return self._statesheads[state]
+                return self._statesheads[state]
             return self.heads()
 
         @util.propertycache