[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Daniel Pittman
daniel at rimspace.net
Tue May 10 08:04:19 UTC 2011
The following commit has been merged in the experimental branch:
commit 1ad6470e3df59caf67c484ef4e43274314c0bc40
Author: Daniel Pittman <daniel at rimspace.net>
Date: Fri Jan 21 23:32:40 2011 -0800
Feature #2597 -- fix cycle relationship notification format.
The SimpleGraph class was reporting duplicate data when printing cycles:
Notify[c]Notify[c] => Notify[d]
Notify[a]Notify[a] => Notify[b]
This was caused by throwing the array representation of the edge into a
string, rather than just the relationship data; we only care about the later,
so now we only emit that later and have the correct text in the error.
diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index 9d7f218..29e46c9 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -109,7 +109,7 @@ class Puppet::SimpleGraph
# each of its out-edges.
while v = zeros.pop
result << v
- @out_from[v].each { |v2,es|
+ @out_from[v].each { |v2,es|
degree[v2].delete(v)
zeros << v2 if degree[v2].empty?
}
@@ -117,7 +117,9 @@ class Puppet::SimpleGraph
# If we have any vertices left with non-zero in-degrees, then we've found a cycle.
if cycles = degree.values.reject { |ns| ns.empty? } and cycles.length > 0
- message = cycles.collect { |edges| '('+edges.collect { |e| e.to_s }.join(", ")+')' }.join(", ")
+ message = cycles.collect { |edges|
+ '(' + edges.collect { |e| e[1].to_s }.join(", ") + ')'
+ }.join(", ")
raise Puppet::Error, "Found dependency cycles in the following relationships: #{message}; try using the '--graph' option and open the '.dot' files in OmniGraffle or GraphViz"
end
@@ -141,7 +143,7 @@ class Puppet::SimpleGraph
# each of its out-edges.
while v = zeros.pop
result << v
- @out_from[v].each { |v2,es|
+ @out_from[v].each { |v2,es|
zeros << v2 if (degree[v2] -= 1) == 0
}
end
diff --git a/spec/unit/simple_graph_spec.rb b/spec/unit/simple_graph_spec.rb
index e49811e..0d1a3b4 100755
--- a/spec/unit/simple_graph_spec.rb
+++ b/spec/unit/simple_graph_spec.rb
@@ -303,6 +303,12 @@ describe Puppet::SimpleGraph do
proc { @graph.topsort }.should_not raise_error
end
+ it "should produce the correct relationship text" do
+ add_edges :a => :b, :b => :a
+ want = %r{following relationships: \(b => a\), \(a => b\)}
+ expect { @graph.topsort }.to raise_error(Puppet::Error, want)
+ end
+
# Our graph's add_edge method is smart enough not to add
# duplicate edges, so we use the objects, which it doesn't
# check.
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list