<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,7 @@
 == (unreleased)
 
+* Make sure a task only uses the last on_rollback block, once, on rollback [Jamis Buck]
+
 * Add :shared_children variable to customize which subdirectories are created by deploy:setup [Jonathan Share]
 
 * Allow filename globbing in copy_exclude setting for the copy strategy [Jonathan Share]</diff>
      <filename>CHANGELOG.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -60,8 +60,9 @@ module Capistrano
       # hook will be executed.
       def on_rollback(&amp;block)
         if transaction?
+          # don't note a new rollback request if one has already been set
+          rollback_requests &lt;&lt; task_call_frames.last unless task_call_frames.last.rollback
           task_call_frames.last.rollback = block
-          rollback_requests &lt;&lt; task_call_frames.last
         end
       end
 </diff>
      <filename>lib/capistrano/configuration/execution.rb</filename>
    </modified>
    <modified>
      <diff>@@ -116,6 +116,22 @@ class ConfigurationExecutionTest &lt; Test::Unit::TestCase
     assert @config.state[:aaa]
   end
 
+  def test_on_rollback_called_twice_should_result_in_last_rollback_block_being_effective
+    aaa = new_task(@config, :aaa) do
+      transaction do
+        on_rollback { (state[:rollback] ||= []) &lt;&lt; :first }
+        on_rollback { (state[:rollback] ||= []) &lt;&lt; :second }
+        raise &quot;boom&quot;
+      end
+    end
+
+    assert_raises(RuntimeError) do
+      @config.execute_task(aaa)
+    end
+
+    assert_equal [:second], @config.state[:rollback]
+  end
+
   def test_find_and_execute_task_should_raise_error_when_task_cannot_be_found
     @config.expects(:find_task).with(&quot;path:to:task&quot;).returns(nil)
     assert_raises(Capistrano::NoSuchTaskError) { @config.find_and_execute_task(&quot;path:to:task&quot;) }</diff>
      <filename>test/configuration/execution_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e70fa828e61c837527ba17d4f3b11ce3f81798dd</id>
    </parent>
  </parents>
  <author>
    <name>Jamis Buck</name>
    <email>jamis@37signals.com</email>
  </author>
  <url>http://github.com/jamis/capistrano/commit/1923c120f58091e01e281628c7f37ef1f9463d4f</url>
  <id>1923c120f58091e01e281628c7f37ef1f9463d4f</id>
  <committed-date>2008-08-19T08:19:30-07:00</committed-date>
  <authored-date>2008-08-19T08:19:30-07:00</authored-date>
  <message>Make sure a task only uses the last on_rollback block, once, on rollback [#36 tagged:committed state:resolved]</message>
  <tree>0661ae00ad67520badfef6a59e72ee30d8ab2d60</tree>
  <committer>
    <name>Jamis Buck</name>
    <email>jamis@37signals.com</email>
  </committer>
</commit>
