AU: when cutting a cycle, add proper dependencies.
The old behavior was:
Imagine a cycle: A->B->C->D->A. We cut A->B which creates the graph:
B->C->D->A->New. We depended on B to depend (indirectly) on New.
The problem is, say we cut two edges, A->B and C->D. Then the result
would be: D->A->New and B->C->New2. Now, B no longer depdends
(directly or indirectly) on New.
Now, When we cut a cycle, we have both the src/dst of the cut edge
depends on the New node. Following the example, this new behavior
gives us:
A->New<-B->C->New2<-D->A
It's both cycle free and doesn't lose the fact that B depends New.
BUG=chromium-os:5061
TEST=unittest, tested on generating delta that needed this fix
Review URL: http://codereview.chromium.org/3013030
diff --git a/delta_diff_generator_unittest.cc b/delta_diff_generator_unittest.cc
index 50f1180..b137766 100644
--- a/delta_diff_generator_unittest.cc
+++ b/delta_diff_generator_unittest.cc
@@ -284,11 +284,13 @@
EXPECT_EQ(2, graph[0].op.dst_extents(0).num_blocks());
EXPECT_EQ(4, graph[0].op.dst_extents(1).start_block());
EXPECT_EQ(1, graph[0].op.dst_extents(1).num_blocks());
-
- // Ensure it only depends on the next node
- EXPECT_EQ(1, graph[0].out_edges.size());
+
+ // Ensure it only depends on the next node and the new temp node
+ EXPECT_EQ(2, graph[0].out_edges.size());
EXPECT_TRUE(graph[0].out_edges.end() != graph[0].out_edges.find(1));
-
+ EXPECT_TRUE(graph[0].out_edges.end() != graph[0].out_edges.find(graph.size() -
+ 1));
+
// Check second node has unchanged extents
EXPECT_EQ(2, graph[1].op.src_extents_size());
EXPECT_EQ(1, graph[1].op.src_extents(0).start_block());