[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:31:03 UTC 2010


The following commit has been merged in the upstream branch:
commit a9fc13409db7147918eeeb47e91315c6eb980432
Author: Luke Kanies <luke at reductivelabs.com>
Date:   Wed Jan 20 01:50:27 2010 -0800

    Removing mention of @changes in Transaction
    
    This is handled in the Status instances now.
    
    Signed-off-by: Luke Kanies <luke at reductivelabs.com>

diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index b49d122..f8c7a85 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -74,19 +74,9 @@ class Puppet::Transaction
         resource.err "Could not evaluate: #{detail}"
     end
 
-    # Apply each change in turn.
-    def apply_changes(resource, changes)
-        changes.each { |change| apply_change(resource, change) }
-    end
-
     # Find all of the changed resources.
     def changed?
-        @changes.find_all { |change| change.changed }.collect do |change|
-            unless change.property.resource
-                raise "No resource for %s" % change.inspect
-            end
-            change.property.resource
-        end.uniq
+        report.resource_statuses.values.find_all { |status| status.changed }.collect { |status| catalog.resource(status.resource) }
     end
 
     # Do any necessary cleanup.  If we don't get rid of the graphs, the
@@ -139,8 +129,6 @@ class Puppet::Transaction
     def eval_children_and_apply_resource(resource)
         @resourcemetrics[:scheduled] += 1
 
-        changecount = @changes.length
-
         # We need to generate first regardless, because the recursive
         # actions sometimes change how the top resource is applied.
         children = eval_generate(resource)
@@ -163,10 +151,6 @@ class Puppet::Transaction
             end
         end
 
-        unless children.empty?
-            @changes[changecount..-1].each { |change| change.proxy = resource }
-        end
-
         # Keep track of how long we spend in each type of resource
         @timemetrics[resource.class.name] += seconds
     end
@@ -203,7 +187,7 @@ class Puppet::Transaction
             Puppet::Util::Log.close(@report)
         end
 
-        Puppet.debug "Finishing transaction #{object_id} with #{@changes.length} changes"
+        Puppet.debug "Finishing transaction #{object_id}"
     end
 
     def events
@@ -316,9 +300,6 @@ class Puppet::Transaction
         # Metrics for distributing times across the different types.
         @timemetrics = Hash.new(0)
 
-        # The changes we're performing
-        @changes = []
-
         # The resources that have failed and the number of failures each.  This
         # is used for skipping resources because of failed dependencies.
         @failures = Hash.new do |h, key|
@@ -404,33 +385,6 @@ class Puppet::Transaction
         report.resource_statuses[resource.to_s]
     end
 
-    # Roll all completed changes back.
-    def rollback
-        @changes.reverse.collect do |change|
-            begin
-                event = change.backward
-            rescue => detail
-                Puppet.err("%s rollback failed: %s" % [change,detail])
-                if Puppet[:trace]
-                    puts detail.backtrace
-                end
-                next
-                # at this point, we would normally do error handling
-                # but i haven't decided what to do for that yet
-                # so just record that a sync failed for a given resource
-                #@@failures[change.property.parent] += 1
-                # this still could get hairy; what if file contents changed,
-                # but a chmod failed?  how would i handle that error? dern
-            end
-
-            # And queue the events
-            event_manager.queue_event(change.resource, event)
-
-            # Now check to see if there are any events for this child.
-            event_manager.process_events(change.property.resource)
-        end
-    end
-
     # Is the resource currently scheduled?
     def scheduled?(resource)
         self.ignoreschedules or resource.scheduled?
diff --git a/spec/unit/transaction.rb b/spec/unit/transaction.rb
index e2ab007..3fcbcca 100755
--- a/spec/unit/transaction.rb
+++ b/spec/unit/transaction.rb
@@ -256,6 +256,28 @@ describe Puppet::Transaction do
             @transaction.prefetch
         end
     end
+
+    describe "when determining changed resources" do
+        before :each do
+            @catalog = Puppet::Resource::Catalog.new
+            @transaction = Puppet::Transaction.new(@catalog)
+        end
+
+        it "should return all resources for which the resource status indicates the resource has changed" do
+            names = []
+            2.times do |i|
+                name = "/my/file#{i}"
+                resource = Puppet::Type.type(:file).new :path => name
+                names << resource.to_s
+                @catalog.add_resource resource
+                @transaction.add_resource_status Puppet::Resource::Status.new(resource)
+            end
+
+            @transaction.resource_status(names[0]).changed = true
+
+            @transaction.changed?.should == [@catalog.resource(names[0])]
+        end
+    end
 end
 
 describe Puppet::Transaction, " when determining tags" do

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list