<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dagolden &#187; subversion</title>
	<atom:link href="http://www.dagolden.com/index.php/tag/subversion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dagolden.com</link>
	<description>Whatever comes to mind</description>
	<lastBuildDate>Mon, 23 Jan 2012 03:43:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Applying git patch emails to subversion</title>
		<link>http://www.dagolden.com/index.php/492/applying-git-patch-emails-to-subversion/</link>
		<comments>http://www.dagolden.com/index.php/492/applying-git-patch-emails-to-subversion/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 19:29:14 +0000</pubDate>
		<dc:creator>dagolden</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[perl programming]]></category>
		<category><![CDATA[ironman]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.dagolden.com/?p=492</guid>
		<description><![CDATA[I prefer git, but have been spending a lot with subversion working on Module::Build. To give myself local version control when offline (I was on an airplane), I layered a local git repository on top of the subversion checkout. (Yes, there might be better ways to do this with "git svn" but not as easily [...]]]></description>
			<content:encoded><![CDATA[<p>I prefer <a href="http://git-scm.org/">git</a>, but have been spending a lot with <a href="http://subversion.tigris.org/">subversion</a> working on <a href="http://search.cpan.org/dist/Module-Build/">Module::Build</a>.  To give myself local version control when offline (I was on an airplane), I layered a local git repository on top of the subversion checkout.  (Yes, there might be better ways to do this with "git svn" but not as easily once <strong>already</strong> offline!)</p>
<p>Once I had taught git to ignore .svn directories and taught svn to ignore .git and .gitignore, I imported the whole project to git and proceeded with my normal workflow, creating separate branches for different things I was working on.</p>
<p>Once I was back online, I wanted to merge my work back to the subversion tree, while still preserving the commit history from when I was offline.  A short bit of Perl programming later and I was done.  For each of the git branches I had created, I generated a series of patch emails with "git format-patch".   Then, after having subversion revert all files back to the latest commit, I passed the patches on the command line to this program:</p>
<pre class="brush: perl; title: ; notranslate">
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Email::Simple;
use Path::Class;
use File::Temp;

die &quot;$0: This is not an svn repo\n&quot;
  unless -d '.svn';

for my $f (sort @ARGV) {
  say &quot;*** $f ***&quot;;
  # try to apply patch
  system(&quot;patch -p1 &lt; $f&quot;);
  die &quot;Patch failed!  Aborting!\n&quot; if $?;

  # extract commit info
  my $email = Email::Simple-&gt;new( scalar file($f)-&gt;slurp );
  my $subject = $email-&gt;header(&quot;Subject&quot;);
  $subject =~ s{^\[PATCH[^\]]*\]\s+}{};
  my $body = $email-&gt;body;
  $body =~ s{\A(.*?)---.*$}{$1}ms;

  # write commit info to tempfile and commit it
  my $temp = File::Temp-&gt;new;
  say {$temp} $subject;
  print {$temp} &quot;\n$body&quot; if $body;

  system(&quot;svn commit -F $temp&quot;);
  die &quot;Commit failed!  Aborting!\n&quot; if $?;
}
</pre>
<p>I wouldn't want this kind of hybrid VCS to be part of my regular workflow, but in a pinch when I wanted offline version control, it worked remarkably well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dagolden.com/index.php/492/applying-git-patch-emails-to-subversion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

