<?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>Erik's Weblog &#187; Technical</title>
	<atom:link href="http://erik.labianca.org/blog/category/technical/feed/" rel="self" type="application/rss+xml" />
	<link>http://erik.labianca.org/blog</link>
	<description>A blog. About stuff.</description>
	<lastBuildDate>Fri, 25 Jun 2010 00:15:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Get started using Mercurial source control in 5 minutes or less</title>
		<link>http://erik.labianca.org/blog/2009/05/get-started-using-mercurial-source-control-in-5-minutes-or-less/</link>
		<comments>http://erik.labianca.org/blog/2009/05/get-started-using-mercurial-source-control-in-5-minutes-or-less/#comments</comments>
		<pubDate>Tue, 12 May 2009 14:51:40 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[revision control]]></category>
		<category><![CDATA[source control]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.cto-at-large.com/?p=121</guid>
		<description><![CDATA[While, in a previous post I talked about how DVCS is the modern form of source control and promised I&#8217;d show you how to do it, quickly and easily. So let&#8217;s get started! I&#8217;m going to use Mercurial because, well, &#8230; <a href="http://erik.labianca.org/blog/2009/05/get-started-using-mercurial-source-control-in-5-minutes-or-less/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While, in a previous post I talked about how DVCS is the modern form of source control and promised I&#8217;d show you how to do it, quickly and easily. So let&#8217;s get started! I&#8217;m going to use Mercurial because, well, I am.</p>
<p>First, you need to download the Mercurial package for your system. If you use a mac with <a href="http://www.macports.org/">macports</a> you can just use type <code>sudo port install mercurial</code>. You could also use the very nice mac .dmg packages from <a href="http://mercurial.berkwood.com/">berkwood</a>. On Ubuntu, you should be able to <code>sudo apt-get install mercurial</code>. On windows, you&#8217;ll probably want to download and install <a href="http://bitbucket.org/tortoisehg/stable/wiki/Home">TortoiseHG</a>. BitBucket makes it complicated to find the download link so just click <a href="http://bitbucket.org/tortoisehg/stable/downloads/">this one</a> instead. You&#8217;ll want the file in the top of the list. Right now, that is <a href="http://bitbucket.org/tortoisehg/stable/downloads/TortoiseHg-0.7.5-hg-1.2.1.exe">TortoiseHg-0.7.5-hg-1.2.1.exe</a>.</p>
<p>So, you should now have a working mercurial command line executable. To try it out, open your shell of choice and type <code>hg</code>.You should get something like this:<br />
<code>
<pre>
loki:dtest erik$ hg
Mercurial Distributed SCM

basic commands:

 add        add the specified files on the next commit
 annotate   show changeset information per file line
 clone      make a copy of an existing repository
 commit     commit the specified files or all outstanding changes
 diff       diff repository (or selected files)
 export     dump the header and diffs for one or more changesets
 init       create a new repository in the given directory
 log        show revision history of entire repository or files
 merge      merge working directory with another revision
 parents    show the parents of the working dir or revision
 pull       pull changes from the specified source
 push       push changes to the specified destination
 remove     remove the specified files on the next commit
 serve      export the repository via HTTP
 status     show changed files in the working directory
 update     update working directory

use "hg help" for the full list of commands or "hg -v" for details
</pre>
<p></code></p>
<p>Now comes the fun part. Simply navigate to the directory you want to put under revision control and run
<pre><code>hg init</code></pre>
<p>. This will create the <code>.hg</code> directory which stores your local repository.</p>
<p>Your next step should be to create a <code>.hgignore</code> file. This file will tell mercurial which file types to ignore. It can use two syntaxes, standard shell globs and also regular expressions. This should give you enough flexibility to eliminate all those pesky auto-generated files, movies, etc from your project directory. Here&#8217;s what I&#8217;ve been using for drupal projects lately, it should give you a good idea of what sort of patterns you might use.</p>
<pre><code>
syntax: glob
*.pyc
*~
hostmeta.ini
Thumbs.db
.DS_Store
*.exe
*.flv
*.mov
*.zip
*.avi
*.wmv
*.dv
*.psd
*.LCK

syntax: regexp
.*\#.*\#$
^files.*
^web/files.*
.*CVS.*
</code></pre>
<p>Now that we&#8217;ve got an <code>.hgignore</code> file, let&#8217;s check it into revision control. Simply execute</p>
<pre><code>
hg add .hgignore
</code></pre>
<p> and then</p>
<pre><code>
hg commit -m 'added .hgignore file'
</code></pre>
<p>. The <code>add</code> tells mercurial to flag the file revision control. The <code>commit</code> command will actually push the contents of the file into the revision control repository.</p>
<p>Now, let&#8217;s put your files under revision control. At this point, since you have a <code>.hgignore</code> file that eliminates all the files you don&#8217;t want controlled, you can run the</p>
<pre><code>
hg status
</code></pre>
<p> command. It will show you all the status of all the files in the revision controlled tree. File which are checked in and already up to date or ignored will not show up on the listing. For a newly created <a href="http://www.djangoproject.org/">Django</a> project with a single app in it, you might see something like this:</p>
<pre><code>
loki:dtest erik$ hg status
? __init__.py
? manage.py
? myapp/__init__.py
? myapp/models.py
? myapp/tests.py
? myapp/views.py
? settings.py
? urls.py
loki:dtest eri
</code></pre>
<p>Now, if all the with ? in front of them are ones you want to add to revision control, simply execute
<pre><code>
hg addremove
</code></pre>
<p>. This will recurse the tree and add all the missing files, and mark any files that have disappeared from your local tree as deleted in the repository. Then, you just run</p>
<pre><code>
hg commit -m 'added first set of files'
</code></pre>
<p> in order check everything in.</p>
<p>If you had files with ? that you don&#8217;t want under revision control, you will need to add expressions to your <code>.hgignore</code> file to ignore them and re-run status. You can also just use add manually on your files, but in my opinion the addremove feature is such a nice addition and hg status is such a powerful feature you will be much better off taking the time to maintain an ignore file.</p>
<p>So, you&#8217;ve now got a copy of your code in revision control. A simple <code>hg status</code> should return blank, indicating that your working copy is in sync with the repository. So let&#8217;s check out that safety net.</p>
<p>Let&#8217;s make a random change to our urls.py.</p>
<pre><code>
echo "# this comment is really lame" >> urls.py
</code><code></code></pre>
<p>And now run <code>hg status</code> one more time. You should see something like this:</p>
<pre><code>
loki:dtest erik$ hg status
M urls.py
</code></pre>
<p>The <code>M</code> prefix indicates that the file has been modified. Now, let&#8217;s see what exactly was modified. Run <code>hg diff</code>. You should get a result like this:</p>
<pre><code>
loki:dtest erik$ hg diff
diff -r 7844b323276e urls.py
--- a/urls.py   Tue May 12 02:56:05 2009 -0400
+++ b/urls.py   Tue May 12 02:58:47 2009 -0400
@@ -15,3 +15,4 @@
     # Uncomment the next line to enable the admin:
     # (r'^admin/', include(admin.site.urls)),
 )
+# this comment is really lame
</code></pre>
<p>As you can see, we have a nicely unified diff indicating that we added a single line. If you installed a GUI package, you can probably use the GUI to bring up a much more nicely formatted GUI change viewer.</p>
<p>So, now we know what we changed. That&#8217;s pretty useful, but how do we get rid of that change? Again, really easy, simply use the
<pre><code>hg revert</code></pre>
<p> command. If you don&#8217;t want to revert all your changes, you can run
<pre><code>hg revert urls.py</code></pre>
<p> for instance, which will only revert changes to <code>urls.py</code>.</p>
<p>If you revert a file and then run hg status, you&#8217;ll note that the file is no longer marked as modified and there is a new <code>? urls.py.orig</code> file which mercurial has nicely decided to keep in case you change your mind. I guess .orig would be a good suffix to add to your <code>.hgnore</code> file!</p>
<p>Obviously we&#8217;ve just barely begun to scratch the surface of mercurial and DVCS&#8217;s in general, but there&#8217;s plenty of time for more learning. Even if you just use it for diffs and revert, you&#8217;re getting great value from your DVCS and are ready to add in more functionality as you need it. Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://erik.labianca.org/blog/2009/05/get-started-using-mercurial-source-control-in-5-minutes-or-less/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DVCS: Modern Source Control aka the Programmers Safety Net</title>
		<link>http://erik.labianca.org/blog/2009/05/dvcs-modern-source-control-aka-the-programmers-safety-net/</link>
		<comments>http://erik.labianca.org/blog/2009/05/dvcs-modern-source-control-aka-the-programmers-safety-net/#comments</comments>
		<pubDate>Mon, 04 May 2009 17:28:31 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Best Practices]]></category>

		<guid isPermaLink="false">http://www.cto-at-large.com/2009/05/dvcs-modern-source-control-aka-the-programmers-safety-net/</guid>
		<description><![CDATA[Revision control is a key tool for modern software engineers. It provides a safety net for the individual developer, and provides a collaborative framework that allows many developers to work on the same project without fear of stepping on each &#8230; <a href="http://erik.labianca.org/blog/2009/05/dvcs-modern-source-control-aka-the-programmers-safety-net/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Revision control is a key tool for modern software engineers. It provides a safety net for the individual developer, and provides a collaborative framework that allows many developers to work on the same project without fear of stepping on each others toes.</p>
<p><a href="http://www.flickr.com/photos/35545469@N06/3290184656/"><img height="300" border="0" width="450" style="margin: 5px;" class="" alt="" src="http://erik.labianca.org/blog/wp-content/uploads/2009/05/skydivers.jpg" title="Skydivers from The Passion Man" /></a>
<p>Revision control or isn&#8217;t a new idea. <a href="http://www.gnu.org/software/rcs/rcs.html">RCS</a> and it&#8217;s descendant, <a href="http://www.nongnu.org/cvs/">CVS</a>, date back to the early 80&#8242;s, and they in turn were based on even older systems. That said, many programmers still aren&#8217;t using it. Eric Sink blames it on <a href="http://www.ericsink.com/scm/scm_intro.html">lack of training</a>. Ben Collins-Sussman thinks it&#8217;s because <a href="http://blog.red-bean.com/sussman/?p=82">80% of programmers aren&#8217;t &quot;Alphas&quot;</a>. Andrew Smith (the number one hit on Google, I might add) thinks it&#8217;s because <a href="http://littlesvr.ca/grumble/2008/07/24/why-dont-people-use-version-control/">takes too long to learn and it&#8217;s hard to set up a server</a>. I&#8217;ll plead the fifth and say I hope I can be a part of the solution instead of the problem!</p>
<p>In any case, up until the last few years, revision control systems were centralized. That is, there was a single central repository of code to which contributors connected, checking out code and checkin in their changes. <a href="http://subversion.tigris.org/">Subversion</a> is the latest of these centralized systems. It was developed specifically to be CVS without the worst of the bugs, and to that end it is very successful. If you want great tools support, have a reasonable sized team, like non-mind-bending behavior, and you only work across a local network anyway, subversion is a great system. </p>
<p>However, many developers have become frustrated with centralized version control. Nobody wants to be accused of &#8216;breaking the build&#8217;, so naturally the frequency of checkins decreases. To the same end, to avoid newbies breaking the build, project administrators don&#8217;t give out commit access lightly. The end result is that developers lose the safety-net aspect revision control. I&#8217;ve been witness to developers making a copy of their source code, out of revision control, because they&#8217;re so afraid they might check in something bad.</p>
<p>In addition, since core contributors are the only ones with commit access to the revision control system, most contributions must come as patches. These patches can be tricky to create in the best of times, but with scale this problem becomes untenable. Just check out the linux kernel mailing list to get a sense of the problem.</p>
<p>The answer to these problems is called a <a href="http://en.wikipedia.org/wiki/Distributed_revision_control">Distributed Version Control System</a>, or DVCS. There are quite a few of these animals out there. Most recently, it seems as if the open source playing field is being dominated by three: <a href="http://bazaar-vcs.org/">Bazaar</a>, <a href="http://git-scm.com/">Git</a>, and <a href="http://www.selenic.com/mercurial/wiki/">Mercurial</a>. All of these systems have their plusses and minusses, but they are all open source and work well enough to get the job done.</p>
<p>Distributed version control systems share quite a few things in common. Instead of using a line or <a href="http://en.wikipedia.org/wiki/Tree_data_structure">tree</a> with named revision numbers to store the change history, distributed revision control systems use <a href="http://en.wikipedia.org/wiki/Directed_acyclic_graph">directed acyclic graphs</a>. This basically means that you can have multiple valid lines or trees at the same time. Hence, distributed.</p>
<p>What this means to you (the developer) is that you get a local copy of the entire repository available to you at all times. That means you can check in, revert, merge, create branches, etc without a network connection.</p>
<p>It also means that you always have access to that revision control sandbox. It allows you to &#8216;check in early, check in often&#8217;, and still not live in fear of breaking the build or disrupting somebody elses work with your bad code. When your code is good and ready, you can review it&#8217;s entire change history, merge in any changes, and submit the entire changeset directly to the central repository or to a core committer as a patch.</p>
<p>Having a local copy of the repository also means that you have a more complete copy of your source code at every developer location  with a DVCS than you would with a traditional VCS.</p>
<p>I&#8217;ll get into the nitty-gritty of how to actually start using DVCS (and how&#8217;s it&#8217;s arguably faster and easer than svn) in another post, but for now, just get out there and use something. Not using source control is like skydiving without a parachute.</p>
<p>References:</p>
<ul>
<li>James Golick has a friendly <a href="http://jamesgolick.com/tags/dvcs.html">introduction</a> to DVCS logic.</li>
<li>Eric Sink has some solid posts about <a href="http://www.ericsink.com/scm/source_control.html">Source Control</a> and <a href="http://www.ericsink.com/entries/dvcs_dag_1.html">DVCS and DAGs</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://erik.labianca.org/blog/2009/05/dvcs-modern-source-control-aka-the-programmers-safety-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
