Commits

Pierre-Yves David committed 8784a98

introduce a ``laststatewithout`` method

We use it to remove explicite reference to state in to module code. This allow
more flexible dev for now.

Comments (0)

Files changed (1)

 
 class state(object):
 
-    def __init__(self, name, order=0, next=None):
+    def __init__(self, name, properties=0, next=None):
         self.name = name
-        self.order = order
+        self.properties = properties
         assert next is None or self < next
         self.next = next
 
         return self.next is not None
 
     def __cmp__(self, other):
-        return cmp(self.order, other.order)
+        return cmp(self.properties, other.properties)
 
     @util.propertycache
     def _revsetheads(self):
 
 STATES = (ST0, ST1, ST2)
 
+def laststatewithout(prop):
+    for state in STATES:
+        if not state.properties & prop:
+            candidate = state
+        else:
+            return candidate
+
 # util function
 #############################
 def noderange(repo, revsets):
     # Write protocols
     ####################
     def heads(repo, proto):
-        h = repo.stateheads(ST1)
+        st = laststatewithout(_NOSHARE)
+        h = repo.stateheads(st)
         return wireproto.encodelist(h) + "\n"
 
     def _reducehead(wirerepo, heads):
 
         def _reducehead(self, candidates):
             selected = set()
+            st = laststatewithout(_NOSHARE)
             for candidate in candidates:
                 rev = self.changelog.rev(candidate)
                 ok = True
-                for h in self.stateheads(ST1):
+                for h in self.stateheads(st):
                     revh = self.changelog.rev(h)
                     if self.changelog.descendant(revh, rev):
                         ok = False
             return sorted(selected)
 
         def cancopy(self):
-            return o_cancopy() and (self.stateheads(ST1) == self.heads())
+            st = laststatewithout(_NOSHARE)
+            return o_cancopy() and (self.stateheads(st) == self.heads())
 
     repo.__class__ = statefulrepo