Rev 2398: Teach GraphDelta to handle ghosts. in file:///home/robertc/source/baz/netsim/

Robert Collins robertc at robertcollins.net
Mon Apr 2 08:28:54 BST 2007


At file:///home/robertc/source/baz/netsim/

------------------------------------------------------------
revno: 2398
revision-id: robertc at robertcollins.net-20070402072850-a7b90xg48rdujr63
parent: robertc at robertcollins.net-20070401113531-onqhpzb37lexq17a
committer: Robert Collins <robertc at robertcollins.net>
branch nick: netsim
timestamp: Mon 2007-04-02 17:28:50 +1000
message:
  Teach GraphDelta to handle ghosts.
modified:
  bzrlib/graph.py                graph.py-20050905070950-b47dce53236c5e48
  bzrlib/tests/test_graph.py     testgraph.py-20050905070950-42e6c958106610fd
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py	2007-04-01 11:35:31 +0000
+++ b/bzrlib/graph.py	2007-04-02 07:28:50 +0000
@@ -214,8 +214,12 @@
         while pending:
             node = pending.pop()
             if node not in cut_from:
-                result.add_node(node, ancestors[node])
-                pending.update(ancestors[node])
+                try:
+                    result.add_node(node, ancestors[node])
+                    pending.update(ancestors[node])
+                except KeyError:
+                    result.add_ghost(node)
+                    pass
         return result
 
     @classmethod

=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py	2007-04-01 11:35:31 +0000
+++ b/bzrlib/tests/test_graph.py	2007-04-02 07:28:50 +0000
@@ -387,6 +387,17 @@
         result.cut_from = set(['C1'])
         self.check_delta(result, graph_from, graph_to)
 
+    def testApplyToGraphWithGhosts(self):
+        # applying a delta when the graph has ghosts should not error.
+        graph_from = Graph()
+        graph_from.add_node('A', ['B'])
+        graph_from.add_ghost('B')
+        graph_to = Graph()
+        graph_to.add_node('A', ['B'])
+        graph_to.add_ghost('B')
+        result = GraphDelta()
+        self.check_delta(result, graph_from, graph_to)
+
 
 class TestNodeSelector(TestCase):
 



More information about the bazaar-commits mailing list