<?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>Outside the Rabbitt Hole &#187; branching</title>
	<atom:link href="http://www.tranquillo.net/tag/branching/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tranquillo.net</link>
	<description>Currently adventuring in Norwalk, CT (USA)</description>
	<lastBuildDate>Fri, 05 Mar 2010 00:30:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Better Branching in Subversion</title>
		<link>http://www.tranquillo.net/2010/03/04/better-branching-in-subversion/</link>
		<comments>http://www.tranquillo.net/2010/03/04/better-branching-in-subversion/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 00:30:33 +0000</pubDate>
		<dc:creator>Rabbitt</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[branching]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://www.tranquillo.net/?p=14</guid>
		<description><![CDATA[There are many perils involved with grafting your toes to your armpits. First of all, toes are meant to be connected to your feet - not placed in your armpits where it is both uncomfortable, and smelly. Aside from the olfactory stink, you also lose the benefit of being able to maintain good balance while walking. What might have seemed like a good idea at first is obviously a bad bio-engineering decision.]]></description>
			<content:encoded><![CDATA[<p>There are many perils involved with grafting your toes to your  armpits. First of all, toes are meant to be connected to your feet &#8211; not  placed in your armpits where it is both uncomfortable, and smelly.  Aside from the olfactory stink, you also lose the benefit of being able  to maintain good balance while walking. What might have seemed like a  good idea at first is obviously a bad bio-engineering decision.</p>
<p>Grafting another arm onto your torso might have some merit as it  isn’t just a sub-subsection of a given trunk (read: your leg); it’s  actually a full trunk unto itself, which means you get more use out of  it. About now you might be wondering what grafting of toes and arms has  to do with tech. Besides the nifty bio-tech opportunities, it serves as a  good metaphor for branching practices in Subversion.</p>
<p>I’m sure by now most of you have had an opportunity to create a  branch and work with it. It’s a pretty simple affair; nothing more than a  copy of one directory in subversion to another. For example:</p>
<p><code>svn copy trunk branches/branch-name</code></p>
<p>Subversion branches are great because they are <em><strong>cheap</strong></em>.  Not cheap like the US Dollar; we’re talking practically free. Whether  you are branching a deep tree or a shallow tree, it’s all the same (<em>cheap</em>)  operation to subversion.</p>
<h3>Branching Correctly and Why it Matters</h3>
<p>The temptation with using branches is to only branch the directory  that you are going to be working in instead of the complete trunk  directory. While that might seem like a great idea, it really isn’t. By  doing so, you make it much more difficult to merge safely. More  importantly, you lose valuable contextual data.</p>
<p>Let’s say you want to work only in the <em>/baz</em> sub-directory  of <em>../trunk/foo/bar</em> (i.e., <em>../trunk/foo/bar/baz</em>). If you branch only that directory,  you have created two problems:</p>
<ol>
<li><em>/baz</em> loses its context within the <em>/trunk/foo/bar</em> codebase. This means that it would not be immediately clear to someone  looking at your branch <em>where</em> it was branched <em>from</em>. (note: there are means of figuring it out, but that&#8217;s not the point)</li>
<li>if you find you need to make changes above <em>/baz</em>,  you’ll have to create a new, independent branch.</li>
</ol>
<p>This is where the value of cheap branching becomes clear. When you  branch, subversion doesn’t actually copy any files, all it does is note a  new directory in the branches directory and that it should contain the  same data as the directory you branched from (effectively, it&#8217;s like a symlink in unix land). From there on out any  change you make is stored against that branch, but only just changes.  This is why branching is cheap; it doesn’t take up physical space until  you make changes.</p>
<p>Perhaps you’re thinking, “I don’t care about how much space it takes  up &#8211; I just don’t need to deal with the extra directories under trunk!”  While that is a valid argument, keep in mind that what you gain in  perceived simplicity, you lose in both flexibility and context.</p>
<h3>Making Branches Work For <em>You</em></h3>
<p>We know it’s probably not a good idea to branch a sub-directory of  the trunk; but, that still doesn’t help us when we only want that  sub-directory. Have no fear; there is a simple solution: After branching  off of the trunk directory, checkout the sub-directory you want from  the branch.</p>
<p>As an example, say we want to create a branch of <em>/trunk</em> called “<em>foo-widget</em>”  but we only want the <em>/trunk/foo/bar</em> sub-directory to work in.  Here’s how you would do that:</p>
<blockquote>
<pre><code>svn copy https://domain.tld/svn/trunk https://domain.tld/svn/branches/foo-widget
svn co https://domain.tld/svn/branches/foo-widget/foo/bar bar</code></pre>
</blockquote>
<p>This would first create a branch of the trunk directory called  “<em>foo-widget</em>” and then checkout the sub-directory <em>/foo/bar</em> from the “<em>foo-widget</em>” branch into a local directory called  ‘bar’. This  allows maximum flexibility to switch gears and work on a different path  in the branch should the need arise, while maintaining the simplicity  you are looking for; and, more importantly, the desired consistent contextual path information for everyone who might look at this branch.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tranquillo.net/2010/03/04/better-branching-in-subversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
