<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Mercurial</title>
        <link>http://nimblecoder.com/blog/category/23.aspx</link>
        <description>Mercurial</description>
        <language>en-US</language>
        <copyright>Ryan Van Slooten</copyright>
        <generator>Subtext Version 2.1.1.1</generator>
        <item>
            <title>Using Mercurial with Virtual Machines</title>
            <link>http://nimblecoder.com/blog/archive/2010/01/21/using-mercurial-with-virtual-machines.aspx</link>
            <description>&lt;p&gt;Recently I have started using &lt;a title="Mercurial" href="http://mercurial.selenic.com/"&gt;Mercurial&lt;/a&gt; (also known as ‘hg’ which is the command line tool) for &lt;a href="http://en.wikipedia.org/wiki/Source_Control_Management"&gt;source control management&lt;/a&gt; (also known as version control system) for some of my projects. Most of the projects I deal with use &lt;a href="http://subversion.tigris.org/"&gt;Subversion&lt;/a&gt; which is sufficient for most needs. My first exposure to &lt;a href="http://en.wikipedia.org/wiki/Distributed_revision_control"&gt;distributed source control management&lt;/a&gt; was &lt;a href="http://en.wikipedia.org/wiki/Linus_Torvalds"&gt;Linus Torvald’s&lt;/a&gt; &lt;a href="http://www.youtube.com/watch?v=4XpnKHJAok8"&gt;presentation on git&lt;/a&gt; at Google. In a nutshell, he rails on CVS (his initial intention was to design a system as “What Would CVS Never Do” [WWCCVSND] and he considers &lt;a href="http://en.wikipedia.org/wiki/Tarball"&gt;tarballs&lt;/a&gt; and patches as superior to &lt;a href="http://en.wikipedia.org/wiki/Concurrent_Versions_System"&gt;CVS&lt;/a&gt;) and also sees Subversion as “the most pointless project ever started.” &lt;/p&gt;  &lt;h2&gt;Popular Open Source Distributed SCMs / DVCSs&lt;/h2&gt;  &lt;p&gt;There are several popular open source distributed SCMs/DVCSs include Darcs, Bazaar, Mercurial, and Git. Currently, it seems that Git is the most “popular” of the bunch (at least in the blogs and tweets that I’ve seen) due to the &lt;a href="http://github.com/"&gt;github&lt;/a&gt; and projects like the &lt;a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary"&gt;Linux kernel&lt;/a&gt; and others. A quick comparison from &lt;a href="http://stackoverflow.com/"&gt;stackoverflow&lt;/a&gt; also verifies popularity in terms of the number of tags related to the respective systems (I listed the main tag only although there were quite a few subtags for Git and Mercurial):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/stackoverflowscmpopularity.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="stackoverflow-scm-popularity" border="0" alt="stackoverflow-scm-popularity" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/stackoverflowscmpopularity_thumb.png" width="260" height="199" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h2&gt;Why Mercurial?&lt;/h2&gt;  &lt;p&gt;I believe Mercurial, Git, and other DVCSs will work great for most cases. There are several analyses on the web with varying results, but the all of the available open source DVCSs are strengths and weaknesses and are capable. That being said, there are several reasons why Mercurial is a good choice.&lt;/p&gt;  &lt;h3&gt;1. Portability&lt;/h3&gt;  &lt;p&gt;Mercurial is written primarily in Python with small portions written in C for speed. This makes it extremely portable to almost every architecture. While Git is available on &lt;a href="http://en.wikipedia.org/wiki/Posix"&gt;POSIX&lt;/a&gt; systems, there are basically two Windows versions with one requiring Cygwin and the other is called &lt;a href="http://code.google.com/p/msysgit/"&gt;msysGit&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;2. TortoiseHG&lt;/h3&gt;  &lt;p&gt;Another reason is &lt;a href="http://bitbucket.org/tortoisehg/stable/wiki/Home"&gt;TortoiseHg&lt;/a&gt; which is a shell extension primarily for Windows, although there is a Gnome/Nautilus CLI extension and a Mac OS X version is in the works. TortoiseHg is written with gtk/tkinter so that makes it easier to port to other systems than TortoiseSVN or TortoiseGit (both are Windows only) although I wish TortoiseHg used wxPython instead. I’ve also used QGit and GitGUI the experience with Tortoise* is generally better in my opinion.&lt;/p&gt;  &lt;h3&gt;3. “Smart” HTTP&lt;/h3&gt;  &lt;p&gt;Mercurial has built-in “smart” HTTP which leads to more efficient transfer when using HTTP. There is &lt;a href="http://kerneltrap.org/mailarchive/git/2008/8/3/2795094/thread"&gt;discussion&lt;/a&gt; of Git implementing smart HTTP. The reason HTTP is important is it is a universal common denominator. Some corporations block the ports used for native git or git+ssh access. Also, I have done work with people in foreign countries where the native protocols didn’t work, or we could use ssh, and HTTP was the only option.&lt;/p&gt;  &lt;p&gt;'hg serve' is an extremely easy way to start the Mercurial internal web server. As &lt;a href="http://stackoverflow.com/questions/35837/what-is-the-difference-between-mercurial-and-git/892688#892688"&gt;one person noted&lt;/a&gt;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;I chose Mercurial since it feels clean and elegant -- I was put off by the shell/Perl/Ruby scripts I got with Git. Try taking a peek at the &lt;a href="http://repo.or.cz/w/git.git?a=blob;f=git-instaweb.sh;hb=HEAD"&gt;&lt;code&gt;git-instaweb.sh&lt;/code&gt; file&lt;/a&gt; if you want to know what I mean: it is a &lt;strong&gt;shell&lt;/strong&gt; script which generates a &lt;strong&gt;Ruby&lt;/strong&gt; script, which I think runs a webserver. The shell script generates another shell script to launch the first Ruby script. There is also a bit of &lt;strong&gt;Perl&lt;/strong&gt;, for good measure.&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;4. Google support&lt;/h3&gt;  &lt;p&gt;Google &lt;a href="http://googlecode.blogspot.com/2009/04/mercurial-support-for-project-hosting.html"&gt;officially supported Mercurial for project hosting&lt;/a&gt; in Google Code on Friday, April 24, 2009. Google also released a report on their internal &lt;a href="http://code.google.com/p/support/wiki/DVCSAnalysis"&gt;DVCS analysis&lt;/a&gt; with the following summary:&lt;/p&gt;  &lt;blockquote&gt;   &lt;h4&gt;&lt;a name="Summary"&gt;Summary&lt;/a&gt;&lt;/h4&gt;    &lt;p&gt;In terms of implementation effort, Mercurial has a clear advantage due to its efficient HTTP transport protocol. &lt;/p&gt;    &lt;p&gt;In terms of features, Git is more powerful, but this tends to be offset by it being more complicated to use. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I personally doubt Google’s support of Mercurial will sway the DVCS competition significantly towards Mercurial as I believe Git is powerful, robust, and here-to-stay. Google’s support does give significant credence to Mercurial though. I expect improvement in both Git and Mercurial in the future which will probably blur the lines even more.&lt;/p&gt;  &lt;h2&gt;Using Mercurial with VMs&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/virtualmachinenetworksettinghostonly.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="virtual-machine-network-setting-host-only" border="0" alt="virtual-machine-network-setting-host-only" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/virtualmachinenetworksettinghostonly_thumb.png" width="244" height="188" /&gt;&lt;/a&gt; The primary benefit of using a DVCS with virtual machines is that the VM does not need to be connected to the outside world but instead only needs access to the host. Most of my VMs use “Host only” networking which allows the VM to connect to the host, but not the outside network or Internet. Thanks to the easy Mercurial built-in web server, it is easy to share a repository from the host to the VM.&lt;/p&gt;  &lt;h3 style="clear: left"&gt;Step 1: Create or Clone repository on Host&lt;/h3&gt;  &lt;p&gt;For example, if we take the 'hello' repository from the &lt;a href="http://mercurial.selenic.com/wiki/TutorialClone"&gt;Mercurial tutorial&lt;/a&gt;, we can clone an existing repository on the host environment:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgclonemyhello.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="tortoisehg-clone-my-hello" border="0" alt="tortoisehg-clone-my-hello" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgclonemyhello_thumb.png" width="244" height="172" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;Step 2: Starting the Mercurial Web Server&lt;/h3&gt;  &lt;p&gt;You can either start the web server by using 'hg serve' from the repository directory, or use TortoiseHg Web Server:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgcontextmenuwebserver.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="tortoisehg-context-menu-web-server" border="0" alt="tortoisehg-context-menu-web-server" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgcontextmenuwebserver_thumb.png" width="205" height="244" /&gt;&lt;/a&gt; &lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgservemyhello.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="tortoisehg-serve-my-hello" border="0" alt="tortoisehg-serve-my-hello" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgservemyhello_thumb.png" width="244" height="160" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you are going to be pushing repository changes from the VM back using HTTP, then don’t forget to &lt;a href="http://mercurial.selenic.com/wiki/PublishingRepositories#push"&gt;enable pushing via HTTP&lt;/a&gt; in the host '$(repository)/.hg/hgrc' file:&lt;/p&gt;  &lt;pre&gt;[web]
allow_push = *
push_ssl = false&lt;/pre&gt;

&lt;h3&gt;Step 3: Cloning the Repository from the VM&lt;/h3&gt;

&lt;p&gt;This step is similar to Step 1, except change the source to the repository on the host, e.g. &lt;a href="http://&amp;lt;yourmachinename&amp;gt;:8000/"&gt;:8000/"&amp;gt;http://&amp;lt;yourmachinename&amp;gt;:8000/&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Then modify the source as necessary on the VM and commit your changes to the local repository.&lt;/p&gt;

&lt;h3&gt;Step 4 – Option A: Pushing Changes back to the Host&lt;/h3&gt;

&lt;p&gt;Once you are ready, you can push your changes back to the repository on the host:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgrepoexploremyhello.png" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="tortoisehg-repoexplore-my-hello" border="0" alt="tortoisehg-repoexplore-my-hello" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgrepoexploremyhello_thumb.png" width="244" height="144" /&gt;&lt;/a&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgpushsuccess.png" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="tortoisehg-push-success" border="0" alt="tortoisehg-push-success" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgpushsuccess_thumb.png" width="244" height="198" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you get a failure, then check the [web] settings in Step 2 and restart the web server if you change the 'hgrc' file.&lt;/p&gt;

&lt;h3&gt;Step 4 – Option B: Pulling the Changes back to the Host&lt;/h3&gt;

&lt;p&gt;Alternatively, you could start the Mercurial Web Server on the VM and pull the changes from the host. This just requires you to start the web server on the VM, and also make sure the specified port, e.g. 8000, is not used by another web server and is open. You can add a sync alias for the VM(s) which makes it easy to switch to different sources/repositories with the Repository Explorer:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgsettingssync.png" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="tortoisehg-settings-sync" border="0" alt="tortoisehg-settings-sync" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgsettingssync_thumb.png" width="191" height="244" /&gt;&lt;/a&gt; &lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgrepoexplorevmmyhello.png" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="tortoisehg-repoexplore-vm-my-hello" border="0" alt="tortoisehg-repoexplore-vm-my-hello" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/UsingMercurialwithVirtualMachines_8112/tortoisehgrepoexplorevmmyhello_thumb.png" width="244" height="131" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;It is easy to use Mercurial, or Git for that matter, in combination with development on virtual machines to allow developers to commit and experience a real SCM/VCS experience.&lt;/p&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/79.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2010/01/21/using-mercurial-with-virtual-machines.aspx</guid>
            <pubDate>Thu, 21 Jan 2010 21:31:19 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/79.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2010/01/21/using-mercurial-with-virtual-machines.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/79.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/79.aspx</trackback:ping>
        </item>
    </channel>
</rss>