Added VCS._ancestors
authorW. Trevor King <wking@drexel.edu>
Mon, 18 Jan 2010 15:10:30 +0000 (10:10 -0500)
committerW. Trevor King <wking@drexel.edu>
Mon, 18 Jan 2010 15:10:30 +0000 (10:10 -0500)
libbe/storage/vcs/base.py

index 1719f06e13b879b096990369f5fc2bc30da288b1..692064cdcfddeb9dd63894673df386b7f19b83d6 100644 (file)
@@ -745,6 +745,27 @@ os.listdir(self.get_path("bugs")):
             if p.startswith(path):
                 self._cached_path_id.remove_id(id)
 
+    def _ancestors(self, id=None, revision=None):
+        if revision == None:
+            id_to_path = self._cached_path_id.path
+        else:
+            id_to_path = lambda id : self._vcs_path(id, revision)
+        if id==None:
+            path = self.be_dir
+        else:
+            path = id_to_path(id)
+        ancestors = []
+        while True:
+            if path == self.repo:
+                break
+            path = os.path.dirname(path)
+            try:
+                id = self._u_path_to_id(path)
+                ancestors.append(id)
+            except (SpacerCollision, InvalidPath):
+                pass    
+        return ancestors
+
     def _children(self, id=None, revision=None):
         if revision == None:
             id_to_path = self._cached_path_id.path