<?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>Hey, it&#039;s OPOWER! &#187; Jeff Kolesky</title>
	<atom:link href="http://www.heyitsopower.com/author/jeff-kolesky/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.heyitsopower.com</link>
	<description>Energy Efficiency Starts at /usr/home</description>
	<lastBuildDate>Thu, 26 Aug 2010 23:12:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Subversion Branching &#8220;Good&#8221; Practice</title>
		<link>http://www.heyitsopower.com/development/subversion-branching-good-practice/</link>
		<comments>http://www.heyitsopower.com/development/subversion-branching-good-practice/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 00:56:52 +0000</pubDate>
		<dc:creator>Jeff Kolesky</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[branching]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.heyitsopower.com/?p=18</guid>
		<description><![CDATA[I am relatively new to Subversion — well, two years into using it now, but this is the first project I have used it on.  Subversion, like any tool, has its quirks and works best when you really know how to use it.  When I started, I treated the "trunk/branches/tags" directory structure exactly like a directory structure.  It took me a little playing around until I stumbled on what I would call a best practice.  When I checkout a new project, I do it like so:

svn co http://domain.com/svnroot/project/trunk project

That way, when I go to the project directory, I do not have to then go into the trunk directory to get to my files.]]></description>
			<content:encoded><![CDATA[<p>I am relatively new to Subversion — well, two years into using it now, but this is the first project I have used it on.  Subversion, like any tool, has its quirks and works best when you really know how to use it.  When I started, I treated the &#8220;trunk/branches/tags&#8221; directory structure exactly like a directory structure.  It took me a little playing around until I stumbled on what I would call a best practice.  When I checkout a new project, I do it like so:</p>
<p><code>svn co http://domain.com/svnroot/project/trunk project</code></p>
<p>That way, when I go to the <code>project</code> directory, I do not have to then go into the <code>trunk</code> directory to get to my files.  Saving an extra directory level is not the best benefit though.  When I set up my IDE (yes, I use an IDE), I put the IDE files in that one directory and do not have to recreate them for each branch or tag that I might check out.  I essentially treat the &#8220;trunk/branches/tags&#8221; part of the directory as pure metadata, which makes perfect sense to me.</p>
<p>When I switched over to this system, there was one big drawback.  I could not easily tell where I am just by looking at my prompt.  I had to run <code>svn info | grep URL</code> to see if I was on a branch.  So instead of letting my prompt handicap me, I decided to get smart about my prompt.  Using bash, my prompt used to look like this:</p>
<p><code>jeff:/opt/pose/main/report/src/main/java</code></p>
<p>but now it looks like this (supercharged with Subversion metadata):</p>
<p><code>jeff:/opt/pose/main/report/src/main/java [SVN: /main/report/trunk]</code></p>
<p>I&#8217;m no bash expert, so I dug around on the web and learned a bit about how <code>PROMPT_COMMAND</code> works.  Here is what I have in my <code>.bash_profile</code> now:</p>
<p><code><br />
function spwd ()<br />
{<br />
    stat .svn > /dev/null 2>&#038;1;<br />
    if [ "$?" == "0" ]; then<br />
        SURL=`svn info | grep URL | perl -pe 's/URL: (.*)/\1/'`;<br />
        if [ `echo ${SURL} | grep -E "branches|tags"` ]; then<br />
            SVER=`echo ${SURL} | perl -pe 's{.*/(branches|tags)/(.*)}{\1/\2}' | cut -d/ -f1-2`;<br />
            SPTH=`echo ${SURL} | perl -pe 's{.*svnroot/(.*)/(branches|tags)/.*}{/\1}'`;<br />
            SPWD="${SPTH}/${SVER}";<br />
        else<br />
            SPWD=`echo ${SURL} | perl -pe 's{.*svnroot/(.*)/trunk(.*)}{/\1/trunk}'`;<br />
        fi;<br />
        export PS1="\u:\w [SVN: $SPWD]\n$ ";<br />
    else<br />
        export PS1="\u:\w $ ";<br />
    fi<br />
}<br />
export PROMPT_COMMAND=spwd<br />
</code></p>
<p>It may not be the most efficient way to do it, but it sure works well and lets me know in an instant what trunk, branch or tag I happen to be working on at that very moment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heyitsopower.com/development/subversion-branching-good-practice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
