changeset 30:a2189159e92f

fix outgoing filtering.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 07 Jul 2011 13:42:47 +0200
parents 52c227772dad
children 1fef89f56588
files states.py
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/states.py	Thu Jul 07 11:24:33 2011 +0200
+++ b/states.py	Thu Jul 07 13:42:47 2011 +0200
@@ -228,11 +228,13 @@
 
         def nodestate(self, node):
             rev = self.changelog.rev(node)
+
             for state in STATES:
                 # XXX avoid for untracked heads
                 if state.next is not None:
-                    revs = scmutil.revrange(self, ["::%s()" % state.headssymbol])
-                    if rev in revs:
+                    ancestors = map(self.changelog.rev, self.stateheads(state))
+                    ancestors.extend(self.changelog.ancestors(*ancestors))
+                    if rev in ancestors:
                         break
             return state
 
@@ -310,17 +312,17 @@
         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(st):
-                    revh = self.changelog.rev(h)
+            candidates = set(map(self.changelog.rev, candidates))
+            heads = set(map(self.changelog.rev, self.stateheads(st)))
+            shareable = set(self.changelog.ancestors(*heads))
+            shareable.update(heads)
+            selected = candidates & shareable
+            unselected = candidates - shareable
+            for rev in unselected:
+                for revh in heads:
                     if self.changelog.descendant(revh, rev):
-                        ok = False
-                        selected.add(h)
-                if ok:
-                    selected.add(candidate)
-            return sorted(selected)
+                        selected.add(revh)
+            return sorted(map(self.changelog.node, selected))
 
         ### enable // disable logic