<?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>Technology Blog of Peter Manis &#187; Version Control</title>
	<atom:link href="http://pyverted.com/category/version-control/feed/" rel="self" type="application/rss+xml" />
	<link>http://pyverted.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 20 Mar 2010 22:51:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Mercurial on your home directory</title>
		<link>http://pyverted.com/version-control/using-mercurial-on-your-home-directory/2009/08/</link>
		<comments>http://pyverted.com/version-control/using-mercurial-on-your-home-directory/2009/08/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 00:34:30 +0000</pubDate>
		<dc:creator>Peter Manis</dc:creator>
				<category><![CDATA[Version Control]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mercurial]]></category>

		<guid isPermaLink="false">http://pyverted.com/?p=353</guid>
		<description><![CDATA[This is a follow up to my previous post, Setting Up Version Control On Your Home Directory.  This post will cover using Mercurial instead of Git to store the files in your home directory.
To start this off you need to install Mercurial
sudo [yum or apt-get] install mercurial

The next step is initializing the repository in [...]]]></description>
			<content:encoded><![CDATA[<p>This is a follow up to my previous post, <a href="http://pyverted.com/linux/setting-up-version-control-on-your-home-directory/2009/08/" target="_blank">Setting Up Version Control On Your Home Directory</a>.  This post will cover using Mercurial instead of Git to store the files in your home directory.</p>
<p>To start this off you need to install Mercurial</p>
<pre><code>sudo [yum or apt-get] install mercurial</code></pre>
<p><span id="more-353"></span><br />
The next step is initializing the repository in your home directory and protect others from being able to read files.</p>
<pre><code>$ cd ~
$ hg init
$ chmod 700 .hg/</code></pre>
<p>In my previous post a commenter pointed out something I was not aware of.  When using git if you were to run &#8216;git clean&#8217; all files not under version control would get deleted.  You should be doing regular backups anyway, but that is certainly something we do not want to be able to do on accident.  The hg equivalent is &#8216;hg purge&#8217;, but purge is a bundled extension that must be enabled, and because it might be enabled we want to explicitly disable that plugin from being able to work in our repository.  To do so you put the following line in ~/.hg/hgrc, because that file will take precedence over conf files in etc and your ~/.hgrc file.</p>
<pre><code>[extensions]
hgext.purge = !</code></pre>
<p>You can store anything you would like to in this repository, but there is most likely going to be some files, and very large files at that, that you do not want to store.  To fix that we are going to start off by ignoring everything in your home directory and selectively removing files from the list that we want to store.  The following commands are going to list all non-hidden files, but listing directories first, the second command lists everything except for &#8216;.&#8217; and &#8216;..&#8217; directory references and greps for all hidden files and lists them directories first.  One thing to note is that the &#8211;group-directories-first option is not available on CentOS and the only distro I can confirm it exists in is Ubuntu.</p>
<pre><code>$ ls -1 --group-directories-first &gt; .hgignore
$ ls -1 --group-directories-first -A | grep '^\.' &gt;&gt; .hgignore
$ cat .hgignore
Applications
bin
Desktop
...
.cache
.checkbox
.compiz
...
.bash_aliases
.bash_history
.bash_logout
...
.xsession-errors</code></pre>
<p>Go through the list and either comment out (prepend with #) or remove from .hgignore any file/directory names that you DO want to store in version control, any file listed in .hgignore will be ignored by mercurial, unless you &#8216;hg add&#8217; the file or directory.</p>
<p>If you want to see what files will be picked up by an &#8216;hg add&#8217; you can run &#8216;hg status&#8217;</p>
<pre><code>$ hg status
? .bash_history
? .bash_logout
? .bash_profile
? .bashrc
? .hgignore
? .hgrc
? .mysql_history
? .screenrc
? bin/mysqltuner.pl</code></pre>
<p>If that is satisfactory you can now run &#8216;hg add&#8217; to add the files listed here.</p>
<pre><code>$ hg add
adding .bash_history
adding .bash_logout
adding .bash_profile
adding .bashrc
adding .hgignore
adding .hgrc
adding .mysql_history
adding .screenrc
adding bin/mysqltuner.pl</code></pre>
<p>And you can verify it by again running &#8216;hg status&#8217;</p>
<pre><code>$ hg status
A .bash_history
A .bash_logout
A .bash_profile
A .bashrc
A .hgignore
A .hgrc
A .mysql_history
A .screenrc
A bin/mysqltuner.pl</code></pre>
<p>So go ahead now and run &#8216;hg commit&#8217; and we can deal with individual files under ignored directories afterwards.  Running &#8216;hg commit&#8217; should be default use vi as your editor so after writing your description his Esc, then type :wq and it will commit.</p>
<pre><code>Initial commit of home directory files.

Contains mostly bash dot files, but also a script in my bin directory

HG: Enter commit message.  Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: Peter Manis &lt;manis@pyverted.com&gt;
HG: branch 'default'
HG: added .bash_history
HG: added .bash_logout
HG: added .bash_profile
HG: added .bashrc
HG: added .hgignore
HG: added .hgrc
HG: added .mysql_history
HG: added .screenrc
HG: added bin/mysqltuner.pl</code></pre>
<p>So there were a couple directories I had in my .hgignore file that I would like to store certain files in version control.  The first is .ssh and the second is .irssi.  So to do this we run &#8216;hg add&#8217; and then &#8216;hg commit&#8217;</p>
<pre><code>$ hg add .ssh/config
$ hg add .irssi/config
$ hg status
A .irssi/config
A .ssh/config
$ hg commit
Adding files that are under ignored directories

HG: Enter commit message.  Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: Peter Manis &lt;manis@pyverted.com&gt;
HG: branch 'default'
HG: added .irssi/config
HG: added .ssh/config</code></pre>
<p>Let us now take a look at the local commits that we have.</p>
<pre><code>$ hg log
changeset:   1:5ca5d6d283fe
tag:         tip
user:        Peter Manis &lt;manis@pyverted.com&gt;
date:        Thu Aug 13 19:48:16 2009 -0400
summary:     Adding files that are under ignored directories

changeset:   0:d0e3d9042208
user:        Peter Manis &lt;manis@pyverted.com&gt;
date:        Thu Aug 13 19:43:06 2009 -0400
summary:     Initial commit of home directory files.</code></pre>
<p>We now need to prepare to push these local commits to our bitbucket private repository.  To do this we need to setup ssh keys</p>
<pre><code>$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mercurialguide/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/mercurialguide/.ssh/id_rsa.
Your public key has been saved in /home/mercurialguide/.ssh/id_rsa.pub.
The key fingerprint is:
c5:fc:5b:3e:06:2c:3f:f9:17:51:bf:78:f8:60:ac:cb mercurialguide@hostname</code></pre>
<p>Now sign up for a bitbucket account, create your first private repository, I called mine homedir.  After you do that you need to go into your &#8220;Account&#8221; page and add your ssh public key to the list of ssh keys.</p>
<pre><code>$ cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwRewbcXoot9nUUZzonryDYKBhxapI69JRW5TNsxfJQEAw4l7VoA681sgHVA2B8T876Tn9uZrzMBgcEz4GMGVsrU31wVNa9p/HtBJCyp1zWKoitoR1wu2FdNRSgsjFOdlMJ6BIxchmG58/hwA88FZXdYgcKMe2WWQP7pDInhHIJhLKPoctXURr6kSM7TWLh4eO81amSE2GB77mCRIoqxI6Y0uQGqO6JDhFUQAPuErCJcfXSkO+Lv9XIyCwhclki2oZUMwvDyYYrHVHWCNZ/azY1C4Ea722CFSWQjAUI9ljA8yaYmLaI4tbgWu9bNQdNy7v9x9EMtq8Q828BF9LGb+tw== mercurialguide@hostname</code></pre>
<p>You will also need to edit your .ssh/config file for bitbucket.</p>
<pre><code>Host bitbucket.org
  User hg
  Compression yes</code></pre>
<p>Now we can push changes to bitbucket</p>
<pre><code>$ hg push ssh://bitbucket.org/manis/homedir/
pushing to ssh://bitbucket.org/manis/homedir/
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 12 changes to 12 files
remote: bb/acl: manis is allowed. accepted payload.
remote: quota: 103.6 MB in use, 500.0 MB available (20.72% used)</code></pre>
<p>And you&#8217;re done!  You just setup a remote repository with your home directory files.  Now that you have that setup remember that until you &#8216;hg push&#8217; your changes they are only local.</p>
]]></content:encoded>
			<wfw:commentRss>http://pyverted.com/version-control/using-mercurial-on-your-home-directory/2009/08/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>My Move to Mercurial</title>
		<link>http://pyverted.com/version-control/my-move-to-mercurial/2009/08/</link>
		<comments>http://pyverted.com/version-control/my-move-to-mercurial/2009/08/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 22:00:08 +0000</pubDate>
		<dc:creator>Peter Manis</dc:creator>
				<category><![CDATA[Version Control]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Mercurial]]></category>

		<guid isPermaLink="false">http://pyverted.com/?p=330</guid>
		<description><![CDATA[My recent post about using Git/Mercurial on my home directory really pushed me to figure out which DVCS I wanted to move to long term.  I wanted to share with you the reasons why I switched, not to try to convince you to switch to Mercurial, but to share with you things you may [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://pyverted.com/linux/setting-up-version-control-on-your-home-directory/2009/08/" target="_blank">recent post</a> about using <a href="http://git-scm.com/" target="_blank">Git</a>/<a href="http://mercurial.selenic.com/wiki/" target="_blank">Mercurial</a> on my home directory really pushed me to figure out which DVCS I wanted to move to long term.  I wanted to share with you the reasons why I switched, not to try to convince you to switch to Mercurial, but to share with you things you may not have known about it.  These observations were primarily over the last week, but I had interacted with both git and mercurial prior to taking the time to learn more about them.  I will also mention that there are going to be things about Mercurial and Git that I cannot comment on.  I do not deal with distributed version control as much as I do centralized so I am unable to comment on features that are more DVCS specific.<br />
<span id="more-330"></span><br />
As I was writing the post about using DVCS on my home directory, I couldn&#8217;t resist using both Mercurial and Git side by side.  With the structure being similar, but different it was much easier than it would have been doing Subversion and a DVCS.  I already had a Git environment setup so pushing my home directory and really interacting with Git wasn&#8217;t a problem, but with Mercurial I didn&#8217;t really want to take the time to set everything up only to ditch it all later.  I then remembered that <a href="http://bitbucket.org/" target="_blank">bitbucket</a> offered 1 private repository with the free account, something that <a href="http://github.com" target="_blank">GitHub</a> does not do.  I created an account and started to play with it a bit and felt more comfortable with the actions of Mercurial than I ever did with Git.  This is when I really started to get a good feel for using Mercurial and how natural it felt to me.</p>
<p>I never liked the status output of Git, the Mercurial output was much closer to Subversion, which is what I was used to.  A quick side note, I have read that most feel Mercurial is an easier move for Subversion users.  With my first real Mercurial involvement needing a lot of adds and removes it was nice to have an &#8216;addremove&#8217; command that quickly took care of this for me.  With Git you had to run add on the files, which was not fun if you added a large number of new files.  Before anything is said about adding files I will say that yes, if you are adding a lot of new files it is probably from adding a directory, which is more easily added, but I found a number of instances where I had to add a lot of files where it wasn&#8217;t that easy and writing out a one liner to do it just isn&#8217;t enjoyable.</p>
<p>The ability to serve a web interface straight from the command line was a feature I found very interesting, again being able to setup a complete environment it wasn&#8217;t something I really needed, but it was certainly a nice feature to have.  Setting up a Mercurial/Apache environment is also much easier than doing it with Git.  I love Trac, I use it for everything I can, but it was very difficult to use with Git for a couple reasons.  The first was that the versions of software needed for the Trac plugin didn&#8217;t mesh well with the CentOS 5 environment it would be hosted on.  The 2nd, which is one of my biggest gripes about Git is the revision id Git uses.  Git uses full hashes like &#8220;b3ef65139dea83be5965a972159aa628847b763c&#8221; while Mercurial will use a number and a short hash like &#8220;0:3f7766464126&#8243; and revisions can be referenced by either.  Here is a visual comparison of the two.</p>
<ul>
<li>Git: <a href="http://labs.ohloh.net/ohcount/browser" target="_blank">OhLoh Labs</a></li>
<li>Mercurial: <a href="http://pylonshq.com/project/pylonshq/browser" target="_blank">Pylons</a></li>
</ul>
<p>I&#8217;m sure you can see what a difference that makes, the Mercurial revision id is 1/3 the length of the Git.</p>
<p>Mercurial itself is written in Python, and it is pointed out in some of the pages I link to later that this allows the developers to concentrate on adding features and paying more attention to creating the best version control system instead of having to deal with all the issues that can be involved in maintaining more low level code like C/C++.  When you don&#8217;t have to spend time on garbage collection and finding memory leaks you have more time to add in features like Mercurial&#8217;s archiving option.  I can simple link to http://webaddress.com/repository/archive/tip.<a href="http://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html" target="_blank">{zip,tar.gz,tar.bz2}</a> and it will create an archive version of the tip, or what is also known as the last revision, but you can also link to tags and create archives based on that.  It also allows me to very easily add autogenerated links to my Trac project index as well, seen below.</p>
<p><img src="http://static.pyverted.com/for/posts/20090808/mercurial_trac.png" /></p>
<p>I think that Mercurial being written in Python influences my decision more than I may realize.  I like to have the power to add and change things and considering that I write Python more than I do anything else these days that fits in very nicely.  It means that if I want a feature I can write it, I don&#8217;t need to know C or C++ and with the design of Python the features can be more easily added and shared with others.  An example of a quick and easy extension is the <a href="http://mercurial.selenic.com/wiki/InfoExtension" target="_blank">InfoExtension</a>, which if you are used to Subversion will look very much like &#8217;svn info&#8217;.</p>
<p>Back in April, <a href="http://googlecode.blogspot.com/2009/04/mercurial-support-for-project-hosting.html" target="_blank">Google added support for Mercurial</a> to their project hosting service, which you can see even has <a href="http://code.google.com/p/android-health-tracker/source/list" target="_blank">integrated branch graphing</a>.  More recently Python creator <a href="http://mail.python.org/pipermail/python-dev/2009-March/087931.html" target="_blank">Guido van Rossum announced</a> they will be moving from Subversion to Mercurial along with a <a href="http://sayspy.blogspot.com/2009/03/why-python-is-switching-to-mercurial.html" target="_blank">followup from Brett Cannon</a> about the decision.  There is also a <a href="http://www.python.org/dev/peps/pep-0374/" target="_blank">detailed PEP</a> about the selection of a distributed VCS.</p>
<p>These are just some of the things that I really liked about Mercurial, you can read a little more on the following pages:</p>
<ul>
<li><a href="http://nubyonrails.com/articles/five-features-from-mercurial-that-would-make-git-suck-less" target="_blank">Five Features from Mercurial That Would Make Git Suck Less</a></li>
<li><a href="http://blog.zacharyvoase.com/post/147813314/why-mercurial-git-or-how-i-learned-to-stop-censoring" target="_blank">Why Mercurial > Git, or How I Learned To Stop Censoring Myself and Participate in Flamewars.</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://pyverted.com/version-control/my-move-to-mercurial/2009/08/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
