<?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>Code Buddy &#187; svn</title>
	<atom:link href="http://www.codebuddy.co.uk/category/svn/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codebuddy.co.uk</link>
	<description>Ramblings from the Coding Trenches</description>
	<lastBuildDate>Wed, 23 Dec 2009 13:55:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>4 Steps to Painless SVN Branching</title>
		<link>http://www.codebuddy.co.uk/4-steps-to-painless-svn-branching/</link>
		<comments>http://www.codebuddy.co.uk/4-steps-to-painless-svn-branching/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 09:01:52 +0000</pubDate>
		<dc:creator>codebuddy</dc:creator>
				<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.codebuddy.co.uk/?p=258</guid>
		<description><![CDATA[Doing some work that can&#8217;t be done in trunk in small increments? Then it time to branch.
Say your working on bug &#8220;12345 Wibble&#8221;&#8230;
Step 1: Create the branch
Create a branch of trunk, making a note in the commit message of the revision of trunk the branch is being created from:

svn copy -r 20000
svn://svn/trunk
svn://svn/branches/trunk_wibble/
-m &#34;Bug 12345 Wibble [...]]]></description>
			<content:encoded><![CDATA[<p>Doing some work that can&#8217;t be done in trunk in small increments? Then it time to branch.</p>
<p>Say your working on bug &#8220;12345 Wibble&#8221;&#8230;</p>
<p><strong>Step 1: Create the branch</strong></p>
<p>Create a branch of trunk, making a note in the commit message of the revision of trunk the branch is being created from:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> copy <span style="color: #660033;">-r</span> <span style="color: #000000;">20000</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>svn<span style="color: #000000; font-weight: bold;">/</span>trunk
<span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>svn<span style="color: #000000; font-weight: bold;">/</span>branches<span style="color: #000000; font-weight: bold;">/</span>trunk_wibble<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Bug 12345 Wibble -
Creating branch for feature work 
svn copy -r 20000 
svn://svn/trunk 
svn://svn/branches/trunk_wibble/&quot;</span></pre></div></div>

<p>There are now two types of commits you&#8217;ll be doing to this branch: </p>
<p>1 &#8211; Work for the feature<br />
2 &#8211; Resyncing with trunk. </p>
<p><strong>Step 2: Doing the feature work</strong></p>
<p>The feature work should be tracked against a bug as normal:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Bug 12345 Wibble
- Added Foo for Wibble&quot;</span></pre></div></div>

<p><strong>Step 3: Merging changes from trunk into your branch</strong></p>
<p>The commit messages for the merges from trunk are crucial for the book keeping of your branch. Above we branched at revision 20000, suppose trunk is now at revision 30000. So to get those changes merged over in your branch, sit in trunk_wibble, with no other local changes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> merge <span style="color: #660033;">-r</span> <span style="color: #000000;">20000</span>:<span style="color: #000000;">30000</span> <span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>svn<span style="color: #000000; font-weight: bold;">/</span>trunk .</pre></div></div>

<p>Once this is compiling commit it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Bug 12345 Wibble
- svn merge -r 20000:30000 svn://svn/trunk .&quot;</span></pre></div></div>

<p>Now next time you want to sync your branch with changes that have happned in trunk, all you need to do is look down the list of changesets to see what revision you last synced too.</p>
<p><strong>Step 4: Merging back into trunk</strong></p>
<p>Now your feature is done and dusted, its time to merge to trunk. You need to know 2 things here:</p>
<p>1 &#8211; What revision of your branch that was last synced to trunk, typically this will be the last commit you did you your branch<br />
2 &#8211; What revision of trunk you last synced to, this will be in your commit message for that final commit.</p>
<p>Suppose these are 40000 and 5000.</p>
<p>Sit yourself in trunk at the revision you last synced to:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> merge 
<span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>svn<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/@</span><span style="color: #000000;">50000</span> 
<span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>svn<span style="color: #000000; font-weight: bold;">/</span>branches<span style="color: #000000; font-weight: bold;">/</span>trunk_wibble<span style="color: #000000; font-weight: bold;">/@</span><span style="color: #000000;">40000</span> .</pre></div></div>

<p>Depending on how many changes you&#8217;ve made this may take a while. Be sure to give the changes a check over to check that match what you think you&#8217;ve changed.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> commit <span style="color: #660033;">-m</span> 
<span style="color: #ff0000;">&quot;Bug 12345 Wibble
Merging feature work into trunk
svn merge 
svn://svn/trunk/@50000 
svn://svn/branches/trunk_wibble/@40000 .&quot;</span></pre></div></div>

<p>And your done!</p>
<p><strong>A final note about that last bit</strong></p>
<p>I&#8217;ve seen a <a href="http://designbygravity.wordpress.com/2009/10/19/what-mother-never-told-you-about-svn-branching-and-merging/">lot of confusion about this last step</a>. What your <em>not</em> trying to do is merge each of your feature work changesets into trunk. </p>
<p>You&#8217;re just after a delta between trunk and your branch so you can apply that to trunk to make it the same as your branch, thats it.</p>
<p>So, what happened exactly when we did the merge back into trunk? That merge was really a diff between trunk and your branch, followed by the application of that patch. You could actually achieve a similar result by doing</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">diff</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>svn<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/@</span><span style="color: #000000;">50000</span> 
<span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>svn<span style="color: #000000; font-weight: bold;">/</span>branches<span style="color: #000000; font-weight: bold;">/</span>trunk_wibble<span style="color: #000000; font-weight: bold;">/@</span><span style="color: #000000;">40000</span> <span style="color: #000000; font-weight: bold;">&gt;</span> wibble.patch</pre></div></div>

<p>And then applying the patch manually.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">patch</span> <span style="color: #660033;">-p0</span> <span style="color: #000000; font-weight: bold;">&lt;</span> wibble.patch</pre></div></div>

<p>However you&#8217;d end up with empty files for those that had been removed in your branch, and files that needed to be svn add&#8217;ed for those that had been added in your branch. Doing it the svn merge way does all the deleting and adding for you. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.codebuddy.co.uk/4-steps-to-painless-svn-branching/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

