# File lib/puppet/simple_graph.rb, line 317
317:   def splice!(other, type)
318:     # We have to get the container list via a topological sort on the
319:     # configuration graph, because otherwise containers that contain
320:     # other containers will add those containers back into the
321:     # graph.  We could get a similar affect by only setting relationships
322:     # to container leaves, but that would result in many more
323:     # relationships.
324:     stage_class = Puppet::Type.type(:stage)
325:     whit_class  = Puppet::Type.type(:whit)
326:     containers = other.topsort.find_all { |v| (v.is_a?(type) or v.is_a?(stage_class)) and vertex?(v) }
327:     containers.each do |container|
328:       # Get the list of children from the other graph.
329:       children = other.adjacent(container, :direction => :out)
330: 
331:       # MQR TODO: Luke suggests that it should be possible to refactor the system so that
332:       #           container nodes are retained, thus obviating the need for the whit. 
333:       children = [whit_class.new(:name => container.name, :catalog => other)] if children.empty?
334: 
335:       # First create new edges for each of the :in edges
336:       [:in, :out].each do |dir|
337:         edges = adjacent(container, :direction => dir, :type => :edges)
338:         edges.each do |edge|
339:           children.each do |child|
340:             if dir == :in
341:               s = edge.source
342:               t = child
343:             else
344:               s = child
345:               t = edge.target
346:             end
347: 
348:             add_edge(s, t, edge.label)
349:           end
350: 
351:           # Now get rid of the edge, so remove_vertex! works correctly.
352:           remove_edge!(edge)
353:         end
354:       end
355:       remove_vertex!(container)
356:     end
357:   end