+ def lowerenabledstate(self, state):
+ return max(st for st in self._enabledstates if st < state)
+ def higherenabledstate(self, state):
+ return min(st for st in self._enabledstates if st > state)
def stateheads(self, state):
- """Return the set of head that define the state"""
+ """return the heads of the ``state``. If not found - state not
+ enabled or heads not fixed - return the heads of the previous
# look for a relevant state
- while state.trackheads and state.next not in self._enabledstates:
- # last state have no cached head.
+ higher = self.higherenabledstate(state)
+ if state in self._statesheads:
+ lower = self.lowerenabledstate(state)
+ return self._statesheads[lower]