<?xml version='1.0' encoding='utf-8' ?>
<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'>
  <channel>
    <title>Wolfmans Howlings: Allow a different local and remote subversion repository path for Capistrano</title>
    <link>http://blog.wolfman.com/articles/2006/11/15/allow-a-different-local-and-remote-subversion-repository-path-for-capistrano</link>
    <description>A programmers Blog about Ruby, Rails and a few other issue</description>
    <language>en-us</language>
    <ttl>40</ttl>
    <item>
      <title>Allow a different local and remote subversion repository path for Capistrano</title>
      <description>
        &lt;p&gt;One of the things that bugs me about Capistrano is the requirement
        that access to the remote subversion repository have the same path
        from the local machine and the remote machine. This is never the case
        in my experience.&lt;/p&gt;
        
        &lt;p&gt;I have been getting around it by setting the path to
        svn://localhost/... and running ssh locally to port forward the SVN
        port to the remote host. This sucks as I usually forget to run ssh in
        another window first.&lt;/p&gt;
        
        &lt;p&gt;So I added an optional configuration variable to be set in deploy.rb
        called &lt;code&gt;local_repository_path&lt;/code&gt;, so now you set the repository path as
        normal, which is the path the remote server uses to access the SVN
        repository, and you set the path that the local machine (your
        workstation) uses to access the same repository...&lt;/p&gt;
        
        &lt;pre&gt;&lt;code&gt;set :repository, &quot;svn://localhost/#{application}/trunk&quot;
        set :local_repository_path, &quot;svn+ssh://myremotehost.com/path/to/repostitory/#{application}/trunk&quot;
        &lt;/code&gt;&lt;/pre&gt;
        
        &lt;p&gt;Ideally one would patch the Capistrano distribution to achieve this,
        but thanks to the magic of ruby you can patch it from your own
        setup so I put the following into &lt;code&gt;lib/tasks/patch_capistrano.rb&lt;/code&gt;&lt;/p&gt;
        
        &lt;pre&gt;
        &lt;span class=&quot;comment&quot;&gt;# Patch the svn scm to allow a local svn repository path as well as&lt;/span&gt;
        &lt;span class=&quot;comment&quot;&gt;# the remote one as most systems I use have a different path depending&lt;/span&gt;
        &lt;span class=&quot;comment&quot;&gt;# on whether you access svn from the local machine or remote machine&lt;/span&gt;
        
          &lt;span class=&quot;keyword&quot;&gt;module &lt;/span&gt;&lt;span class=&quot;module&quot;&gt;Capistrano&lt;/span&gt;
        
            &lt;span class=&quot;comment&quot;&gt;# override the two scm methods that access svn from the local machine&lt;/span&gt;
            &lt;span class=&quot;keyword&quot;&gt;module &lt;/span&gt;&lt;span class=&quot;module&quot;&gt;SCM&lt;/span&gt;
        
              &lt;span class=&quot;keyword&quot;&gt;class &lt;/span&gt;&lt;span class=&quot;class&quot;&gt;Subversion&lt;/span&gt;
                &lt;span class=&quot;comment&quot;&gt;# Return an integer identifying the last known revision in the svn&lt;/span&gt;
                &lt;span class=&quot;comment&quot;&gt;# repository. (This integer is currently the revision number.)&lt;/span&gt;
                &lt;span class=&quot;keyword&quot;&gt;def &lt;/span&gt;&lt;span class=&quot;method&quot;&gt;latest_revision&lt;/span&gt;
                  &lt;span class=&quot;attribute&quot;&gt;@latest_revision&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;begin&lt;/span&gt;
                    &lt;span class=&quot;ident&quot;&gt;configuration&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;logger&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;debug&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;querying latest revision...&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;
                    &lt;span class=&quot;ident&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;svn_log&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;configuration&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:local_repository_path&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;scan&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(/&lt;/span&gt;&lt;span class=&quot;regex&quot;&gt;r(&lt;span class=&quot;escape&quot;&gt;\d&lt;/span&gt;+)&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;/).&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;first&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;or&lt;/span&gt;
                    &lt;span class=&quot;keyword&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;Could not determine latest revision&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;
                    &lt;span class=&quot;ident&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;first&lt;/span&gt;
                  &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
                &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
        
                &lt;span class=&quot;comment&quot;&gt;# Return a string containing the diff between the two revisions. +from+&lt;/span&gt;
                &lt;span class=&quot;comment&quot;&gt;# and +to+ may be in any format that svn recognizes as a valid revision&lt;/span&gt;
                &lt;span class=&quot;comment&quot;&gt;# identifier. If +from+ is +nil+, it defaults to the last deployed&lt;/span&gt;
                &lt;span class=&quot;comment&quot;&gt;# revision. If +to+ is +nil+, it defaults to HEAD.&lt;/span&gt;
                &lt;span class=&quot;keyword&quot;&gt;def &lt;/span&gt;&lt;span class=&quot;method&quot;&gt;diff&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;constant&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;constant&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;)&lt;/span&gt;
                  &lt;span class=&quot;ident&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;current_revision&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;)&lt;/span&gt;
                  &lt;span class=&quot;ident&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;HEAD&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;
                  `&lt;span class=&quot;ident&quot;&gt;svn&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;diff&lt;/span&gt; &lt;span class=&quot;comment&quot;&gt;#{configuration[:local_repository_path]}@#{from} #{configuration[:local_repository_path]}@#{to}`&lt;/span&gt;
                &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
        
              &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
            &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
        
          &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
        &lt;/pre&gt;
        
        &lt;p&gt;Then simply add this line to your config/deploy.rb...&lt;/p&gt;
        
        &lt;pre&gt;&lt;code&gt;require 'lib/tasks/patch_capistrano'
        &lt;/code&gt;&lt;/pre&gt;
        
        &lt;p&gt;and everything works fine now.&lt;/p&gt;
        
        &lt;p&gt;Note there are only two scm methods that access SVN from the local
        machine, &lt;code&gt;latest_revision&lt;/code&gt; and &lt;code&gt;diff&lt;/code&gt;. I have patched both.&lt;/p&gt;
        
        &lt;p&gt;I'll tidy this up, make the default for &lt;code&gt;local_repository_path&lt;/code&gt; be
        &lt;code&gt;repository&lt;/code&gt;, and submit the patch to the Capistrano folks, who will
        hopefully commit it to the source code, as it won't affect existing
        users, but will make the rest of us a little happier.&lt;/p&gt;
        
        &lt;p&gt;&lt;a href=&quot;http://technorati.com/tag/capistrano+local+svn&quot; rel=&quot;tag&quot;&gt;&lt;/a&gt;
        &lt;a href=&quot;http://technorati.com/tag/capistrano+local+repository&quot; rel=&quot;tag&quot;&gt;&lt;/a&gt;&lt;/p&gt;
      </description>
      <author>Jim Morris</author>
      <pubDate>Wed, 15 Nov 2006 14:04:28 -0800</pubDate>
      <link>http://blog.wolfman.com/articles/2006/11/15/allow-a-different-local-and-remote-subversion-repository-path-for-capistrano</link>
      <guid isPermaLink='false'>urn:uuid:7e0dc63c-7ef2-49d9-bb32-bdadb8069799</guid>
    </item>
    <item>
      <title>"Allow a different local and remote subversion repository path for Capistrano" by Marcelo</title>
      <description>Thanks a lot!</description>
      <pubDate>Wed, 14 Feb 2007 10:13:11 -0800</pubDate>
      <link>http://blog.wolfman.com/posts/17#comment-58</link>
      <guid isPermaLink='false'>urn:uuid:55cd5ead-a68d-445b-813a-9b5637a59950</guid>
    </item>
    <item>
      <title>"Allow a different local and remote subversion repository path for Capistrano" by Rob Dupuis</title>
      <description>When reading variable xxx In capistrano 2.1 (poss 2.0 too?) the scm recipes check for a` local_xxx` equivalent. So you can just use `:local_repository` if you need to configure a different local repo url.</description>
      <pubDate>Tue, 16 Oct 2007 06:48:17 -0700</pubDate>
      <link>http://blog.wolfman.com/posts/17#comment-59</link>
      <guid isPermaLink='false'>urn:uuid:bafa04b4-40f0-496d-8c9b-7dce7de08411</guid>
    </item>
    <item>
      <title>"Allow a different local and remote subversion repository path for Capistrano" by jxh</title>
      <description>
        To clarify that bit about &quot;local&quot;:
        
        For the case where your desktop needs to reach svn with ssh, but the svn repository happens to be on the same machine where you're deploying your app, your `deploy.rb` needs to look something like this:
        
            set :repository, &quot;file:///home/svn/main/rails/myapp&quot;
            set :local_repository, &quot;svn+ssh://myserver.my.domain/main/rails/myapp&quot;
        
        Note the underscore needed after &quot;local&quot;.
      </description>
      <pubDate>Sun, 11 Jan 2009 20:42:55 -0800</pubDate>
      <link>http://blog.wolfman.com/posts/17#comment-60</link>
      <guid isPermaLink='false'>urn:uuid:0e83c5bc-1caf-4c0d-b090-1fe41ec40340</guid>
    </item>
    <item>
      <title>"Allow a different local and remote subversion repository path for Capistrano" by wolfmanjm</title>
      <description>I fixed it in the Dupuis comment. Please note that Capistrano 2 has a completely different way of doing things.</description>
      <pubDate>Sun, 11 Jan 2009 20:57:56 -0800</pubDate>
      <link>http://blog.wolfman.com/posts/17#comment-61</link>
      <guid isPermaLink='false'>urn:uuid:8c974d96-fa71-4f3a-8436-6e611425c801</guid>
    </item>
  </channel>
</rss>
