Commits

Pierre-Yves David committed e95e8cf

Get ride of dedicated heads property.

This is now handle throught a generic repo.stateheads(state) methode.

Comments (0)

Files changed (1)

     # Write protocols
     ####################
     def heads(repo, proto):
-        h = repo._readyheads
+        h = repo.stateheads(ST1)
         return wireproto.encodelist(h) + "\n"
 
     def _reducehead(wirerepo, heads):
 
         def nodestate(self, node):
             rev = self.changelog.rev(node)
-            for head in self._readyheads:
-                revhead = self.changelog.rev(head)
-                if self.changelog.descendant(revhead, rev):
-                    return STATES[2]
-            for head in self._publishedheads:
-                revhead = self.changelog.rev(head)
-                if self.changelog.descendant(revhead, rev):
-                    return STATES[1]
-            return STATES[0]
+            for state in STATES[::-1]:
+                # XXX avoid for untracked heads
+                if state.next is not None:
+                    for head in self.stateheads(state):
+                        revhead = self.changelog.rev(head)
+                        if self.changelog.descendant(revhead, rev):
+                            return state.next
+            return state
 
 
-        @property
-        def _readyheads(self):
-            if self.ui.configbool('states', ST1.next.name, False):
-                return self._statesheads[ST1]
-            return self.heads()
 
-        @property
-        def _publishedheads(self):
-            if self.ui.configbool('states', ST0.next.name, False):
-                return self._statesheads[ST0]
+        def stateheads(self, state):
+            if state.trackheads:
+                if self.ui.configbool('states', state.next.name, False):
+                    return self._statesheads[state]
             return self.heads()
 
         @util.propertycache
             for candidate in candidates:
                 rev = self.changelog.rev(candidate)
                 ok = True
-                for h in self._readyheads:
+                for h in self.stateheads(ST1):
                     revh = self.changelog.rev(h)
                     if self.changelog.descendant(revh, rev):
                         ok = False
             return sorted(selected)
 
         def cancopy(self):
-            return o_cancopy() and (self._readyheads == self.heads())
+            return o_cancopy() and (self.stateheads(ST1) == self.heads())
 
     repo.__class__ = statefulrepo
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.