<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -22,8 +22,15 @@
 #  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 class AbstractDownloadStrategy
-  def initialize url, name, version
+  def initialize url, name, version, specs
     @url=url
+    case specs
+    when Hash
+      @spec = specs.keys.first # only use first spec
+      @ref = specs.values.first
+    else
+      spec = nil
+    end
     @unique_token=&quot;#{name}-#{version}&quot; unless name.to_s.empty? or name == '__UNKNOWN__'
   end
 end
@@ -131,8 +138,17 @@ class GitDownloadStrategy &lt;AbstractDownloadStrategy
     end
   end
   def stage
-    dst=Dir.getwd
+    dst = Dir.getwd
     Dir.chdir @clone do
+      if @spec and @ref
+        ohai &quot;Checking out #{@spec} #{@ref}&quot;
+        case @spec
+        when :branch
+          safe_system 'git', 'checkout', '-b', @ref, &quot;origin/#{@ref}&quot;
+        when :tag
+          safe_system 'git', 'checkout', @ref
+        end
+      end
       # http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
       safe_system 'git', 'checkout-index', '-af', &quot;--prefix=#{dst}/&quot;
     end
@@ -200,7 +216,14 @@ class MercurialDownloadStrategy &lt;AbstractDownloadStrategy
   def stage
     dst=Dir.getwd
     Dir.chdir @clone do
-      safe_system 'hg', 'archive', '-y', '-t', 'files', dst
+      if @spec and @ref
+        ohai &quot;Checking out #{@spec} #{@ref}&quot;
+        Dir.chdir @clone do
+          safe_system 'hg', 'archive', '-y', '-r', @ref, '-t', 'files', dst
+        end
+      else
+        safe_system 'hg', 'archive', '-y', '-t', 'files', dst
+      end
     end
   end
 end</diff>
      <filename>Library/Homebrew/download_strategy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -46,6 +46,7 @@ class Formula
   def initialize name='__UNKNOWN__'
     set_instance_variable 'url'
     set_instance_variable 'head'
+    set_instance_variable 'specs'
 
     if @head and (not @url or ARGV.flag? '--HEAD')
       @url=@head
@@ -85,7 +86,7 @@ class Formula
     self.class.path name
   end
 
-  attr_reader :url, :version, :homepage, :name
+  attr_reader :url, :version, :homepage, :name, :specs
 
   def bin; prefix+'bin' end
   def sbin; prefix+'sbin' end
@@ -281,7 +282,7 @@ private
   end
 
   def stage
-    ds=download_strategy.new url, name, version
+    ds=download_strategy.new url, name, version, specs
     HOMEBREW_CACHE.mkpath
     dl=ds.fetch
     verify_download_integrity dl if dl.kind_of? Pathname
@@ -380,7 +381,14 @@ private
       end
     end
 
-    attr_rw :url, :version, :homepage, :head, :deps, *CHECKSUM_TYPES
+    attr_rw :url, :version, :homepage, :specs, :deps, *CHECKSUM_TYPES
+
+    def head val=nil, specs=nil
+      if specs
+        @specs = specs
+      end
+      val.nil? ? @head : @head = val
+    end
 
     def depends_on name, *args
       @deps ||= []</diff>
      <filename>Library/Homebrew/formula.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0d076d2ca6535568bf979979c7e6a4bc7fc1b1dc</id>
    </parent>
  </parents>
  <author>
    <name>Jannis Leidel</name>
    <email>jannis@leidel.info</email>
  </author>
  <url>http://github.com/aanand/homebrew/commit/96d166ef01cdedf375bc83e63e57871ff49d8912</url>
  <id>96d166ef01cdedf375bc83e63e57871ff49d8912</id>
  <committed-date>2009-10-18T20:02:48-07:00</committed-date>
  <authored-date>2009-10-17T05:35:24-07:00</authored-date>
  <message>Fix #52: Add ability to checkout a branch or tag.

GitDownloadStrategy and MercurialDownloadStrategy
now can be used like this:

  head 'git://server/repo.git', :branch =&gt; 'stable'
  head 'hg://server/repo/', :tag =&gt; '1.0.4'</message>
  <tree>4e3c559968a493036be51007d63e78ccff54d80a</tree>
  <committer>
    <name>Max Howell</name>
    <email>max@methylblue.com</email>
  </committer>
</commit>
