Rev 2391: Tighten the algorithm requirements - tails are not required because the exclusion on misses will converge. Also add Nonempty to empty test. in file:///home/robertc/source/baz/netsim/
Robert Collins
robertc at robertcollins.net
Sun Apr 1 07:31:20 BST 2007
At file:///home/robertc/source/baz/netsim/
------------------------------------------------------------
revno: 2391
revision-id: robertc at robertcollins.net-20070401063117-71od8scu0te38npy
parent: robertc at robertcollins.net-20070401061938-xzhb1m77i7fzzkb6
committer: Robert Collins <robertc at robertcollins.net>
branch nick: netsim
timestamp: Sun 2007-04-01 16:31:17 +1000
message:
Tighten the algorithm requirements - tails are not required because the exclusion on misses will converge. Also add Nonempty to empty test.
modified:
bzrlib/graph.py graph.py-20050905070950-b47dce53236c5e48
bzrlib/tests/test_graph.py testgraph.py-20050905070950-42e6c958106610fd
doc/design/server.txt server.txt-20070401020531-rqa7d77i22idnj78-2
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py 2007-04-01 06:19:38 +0000
+++ b/bzrlib/graph.py 2007-04-01 06:31:17 +0000
@@ -137,14 +137,6 @@
self._ensure_descendant(parent)
self._graph_descendants[parent][node_id] = 1
- def apply_changes(self, delta):
- """Apply a delta obtained from a changes_from call.
-
- :return: A new graph which is the result of applying delta to this
- graph.
- """
- return Graph()
-
def changes_from(self, graph_from):
"""Create a GraphDelta from graph_from to self."""
return GraphDelta._changes_from(graph_from, self)
@@ -185,6 +177,16 @@
This restriction may be lifted in the future.
"""
+ def __eq__(self, other):
+ return isinstance(other, GraphDelta) and self.__dict__ == other.__dict__
+
+ def apply_to(self, from_):
+ """Apply this delta to the graph from_.
+
+ :return: A new graph derived from from_ and this delta.
+ """
+ return Graph()
+
@classmethod
def _changes_from(cls, from_, to):
"""Construct a delta from from_ to to."""
=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py 2007-04-01 06:19:38 +0000
+++ b/bzrlib/tests/test_graph.py 2007-04-01 06:31:17 +0000
@@ -83,17 +83,33 @@
class TestGraphDelta(TestCase):
- def testEmptyEmptyGraph(self):
- graph_from = Graph()
- graph_to = Graph()
+ def check_delta(self, expected_delta, graph_from, graph_to):
+ """Check the delta from graph_from to graph_to.
+
+ This will calculate a new delta, check that applying it to graph_from
+ results in graph_to, and that it is equal to expected_delta.
+ """
delta = graph_to.changes_from(graph_from)
self.assertIsInstance(delta, GraphDelta)
- new_to = graph_from.apply_changes(delta)
+ self.assertEqual(expected_delta, delta)
+ new_to = delta.apply_to(graph_from)
self.assertEqual(graph_to, new_to)
+ def testEmptyEmptyGraph(self):
+ graph_from = Graph()
+ graph_to = Graph()
+ self.check_delta(GraphDelta(), graph_from, graph_to)
+
def testTargetNotSubGraph(self):
"""When the target is not a sub-graph of the source, get an exception."""
graph_from = Graph()
graph_to = Graph()
graph_to.add_node('A', [])
self.assertRaises(NotSubGraph, graph_to.changes_from, graph_from)
+
+ def testSmallEmptyGraph(self):
+ graph_from = Graph()
+ graph_from.add_node('A', [])
+ graph_to = Graph()
+ result = GraphDelta()
+ self.check_delta(result, graph_from, graph_to)
=== modified file 'doc/design/server.txt'
--- a/doc/design/server.txt 2007-04-01 02:16:22 +0000
+++ b/doc/design/server.txt 2007-04-01 06:31:17 +0000
@@ -34,9 +34,6 @@
have the following properties:
* It is repeatable given the token and the graph.
* The token must be short(< the size of a node) and serialisable.
-To prevent repeating loops it must also:
- * include all the terminal nodes of each disjoint subgraph.
-
Constraints:
* The client is permitted state.
More information about the bazaar-commits
mailing list