<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,7 @@
 *unreleased*
 
+* Make sure triggers defined as a block inherit the scope of the task they are attached to, instead of the task they were called from [Jamis Buck]
+
 * Make deploy:upload use the upload() helper for more efficient directory processing [Jamis Buck]
 
 * Make deploy:upload accept globs [Mark Imbriaco]</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ module Capistrano
   class Configuration
     module Callbacks
       def self.included(base) #:nodoc:
-        %w(initialize execute_task).each do |method|
+        %w(initialize invoke_task_directly).each do |method|
           base.send :alias_method, &quot;#{method}_without_callbacks&quot;, method
           base.send :alias_method, method, &quot;#{method}_with_callbacks&quot;
         end
@@ -18,13 +18,13 @@ module Capistrano
         @callbacks = {}
       end
 
-      def execute_task_with_callbacks(task) #:nodoc:
+      def invoke_task_directly_with_callbacks(task) #:nodoc:
         before = find_hook(task, :before)
         execute_task(before) if before
 
         trigger :before, task
 
-        result = execute_task_without_callbacks(task)
+        result = invoke_task_directly_without_callbacks(task)
 
         trigger :after, task
 </diff>
      <filename>lib/capistrano/configuration/callbacks.rb</filename>
    </modified>
    <modified>
      <diff>@@ -72,12 +72,12 @@ module Capistrano
         task_call_frames.last.task
       end
 
-      # Executes the task with the given name, including the before and after
-      # hooks.
+      # Executes the task with the given name, without invoking any associated
+      # callbacks.
       def execute_task(task)
         logger.debug &quot;executing `#{task.fully_qualified_name}'&quot;
         push_task_call_frame(task)
-        task.namespace.instance_eval(&amp;task.body)
+        invoke_task_directly(task)
       ensure
         pop_task_call_frame
       end
@@ -121,6 +121,11 @@ module Capistrano
       def pop_task_call_frame
         task_call_frames.pop
       end
+
+      # Invokes the task's body directly, without setting up the call frame.
+      def invoke_task_directly(task)
+        task.namespace.instance_eval(&amp;task.body)
+      end
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/capistrano/configuration/execution.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,9 +12,15 @@ class ConfigurationCallbacksTest &lt; Test::Unit::TestCase
     end
 
     def execute_task(task)
-      @called &lt;&lt; task
+      invoke_task_directly(task)
     end
 
+    protected
+
+      def invoke_task_directly(task)
+        @called &lt;&lt; task
+      end
+
     include Capistrano::Configuration::Callbacks
   end
 </diff>
      <filename>test/configuration/callbacks_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0d415c677dc7f13c2b4c74ed6ebe65a08c1a2339</id>
    </parent>
  </parents>
  <author>
    <name>Jamis Buck</name>
    <email>jamis@37signals.com</email>
  </author>
  <url>http://github.com/jamis/capistrano/commit/2ac1906a3ab0bda997ca3b028b9b20d222faf3fe</url>
  <id>2ac1906a3ab0bda997ca3b028b9b20d222faf3fe</id>
  <committed-date>2008-06-05T20:00:19-07:00</committed-date>
  <authored-date>2008-06-05T20:00:19-07:00</authored-date>
  <message>Make block-triggers scope to the task they are attached to.

Prior to this, if you defined (e.g.) a before task using a block,
like this:

  before :foo do
    puts &quot;current task is #{current_task.name}&quot;
  end

And then, you invoked :foo like this:

  task :bar do
    run &quot;something&quot;
    foo
  end

You'd see the before-foo block print &quot;bar&quot; as the name of the
current task. This meant that any commands run in the foo before
block would be scoped to the servers of :bar, when it really
makes more sense to scope them to the servers of :foo. This
commit makes it so that the before-foo block, above, would show
&quot;foo&quot; as the name of the current task, rather than &quot;bar&quot;.</message>
  <tree>7a296725662fbfe233f1d84045e6e8df02281cb1</tree>
  <committer>
    <name>Jamis Buck</name>
    <email>jamis@37signals.com</email>
  </committer>
</commit>
