Commits

Benoit Boissinot committed 7ea4445

add ancestors to dagutils

Comments (0)

Files changed (2)

                 pending.extend(children.get(n, []))
         return d
 
+    def ancestors(self, start, stop=None):
+        if stop is not None:
+            seen = set(stop)
+        else:
+            seen = set()
+
+        d = set()
+        pending = list(start)
+        while pending:
+            n = pending.pop()
+            if n not in seen:
+                d.add(n)
+                seen.add(n)
+                pending.extend(self.parents(n))
+        return d
+
     def walk(self, heads=None, stops=None):
         '''iterate ids from heads to stops (or root), depth-first'''
         pending = (heads or self.heads())[:]

src/discovery_tonfa.py

             i += 1
 
             self._missing.update(self.dag.descendants((n for n in sample if n not in common), self._missing))
-            for n in sample:
-                if n in common:
-                    self._common.update(self.dag.walk([n], self._common))
-            #self._common.update(self.dag.walk(list(n for n in sample if n in common), self._common))
+            #for n in sample:
+            #    if n in common:
+            #        self._common.update(self.dag.walk([n], self._common))
+            self._common.update(self.dag.ancestors(list(n for n in sample if n in common), self._common))
 
             self._unknown.difference_update(self._missing)
             self._unknown.difference_update(self._common)
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.