Mercurial 101 as an Umbraco developer

Mercurial 101 as an Umbraco developer

You may have read the post that the Umbraco codebase is being moved from a CodePlex TFS server to CodePlex Mercurial (link) but what does that mean as an Umbraco community member?

First up, a Mercurial primer

While there are fancy GUI tools for working with Mercurial (such as TortoiseHg) I'm going to do a quick run down on what you need to be able to use from the command line to work with Mercurial. Personally I find it easier (and quicker) to work on the command line, but if you'd prefer to learn about TortoiseHg jump over to their doco, or read Shannon's guide to using TortoiseHg :).

Commands you need

There are three things you need to be able to do if you're grabbing the code from Mercurial, clone, update and view history: (Note: This is not covering doing changes, just how to get the code and navigate around it)

  • hg clone https://hg01.codeplex.com/umbraco
    • This how you get a copy of the codeplex repository onto your machine. This may take a little while, we've got a lot of history (sic) in there that you'll be getting
  • hg update
    • This is how you'll get to the release that you want to view the code for. Say you want to work with v4.5.2 then you want to do hg update Release-4.5.2
  • hg serve
    • This is an interesting command as it'll spin up a webserver (http://localhost:8000 by default) which allows you to view the repository history. You can hit the url in your browser and browse change sets, commits, etc. This is a handy way to find out what you want to update to without having to go to CodePlex

A command line tip

One of the really nice things about the Mercurial command line tools is that you can use shorthand to execute a command. Basically when you type a command in shorthand Mercurial will try and find the command that matches it, so for example if I was to type hg up Release-4.5.2 Mercurial will see that I've typed up and that up only matches the update command.

If you don't supply enough characters, ie: hg c https://hg01.codeplex.com/umbraco then Mercurial will tell you that it doesn't know what you were trying to execute.

Named branches as awesome

Anyone who's tried to bugfix Umbraco or wanted to compile a version themselves will appreciate the pain which the TFS structure was causing (this isn't a bash at TFS, it wasn't entirely TFSs fault that it was hard, it was a combination of different factors, so don't take this as a diss at TFS). Now with the migration it should be a whole lot easier.

Say you find a bug in your 4.5.2 install and you want to try and debug it yourself. Here's how you'd go about it:

  1. Open up your favorite console (cmd.exe, powershell, etc) and navigate to a folder you want to put the Umbraco source
  2. Execute: hg cl https://hg01.codeplex.com/umbraco; hg up Release-4.5.2;
  3. Open the .sln file in Visual Studio

Yes, it's just that easy! Now you can debug the code to your hearts content.

Conclusion

This was just a quick walkt through of how the move to Mercurial with Umbraco is going to make it simpler for developers to interact with the Umbraco source code.

Happy Hacking :)

umbracomercurial
Posted by: Aaron Powell
Last revised: 23 Dec, 2010 12:47 AM History

Comments

Stephen
Stephen
15 Dec, 2010 02:40 PM

Quick questions,

  • Is there a list of existing branches and tags? Eg from what I can see, current Juno developement takes place in the "4.6.0" branch, but what is the "4.6.0-wip" branch? Some sort of reference list might be handy.

  • Browsing the code with Tortoise Repository Explorer, I see strange ordering of changesets... Eg Release-4.5.2 (changeset 647) appears after Release-4.5.0 (changeset 668) although the dates are correct. Is it a glitch in the import, or am I missing something?

Stephen - getting ready to publish all my patches in a fork

15 Dec, 2010 10:44 PM

The 4.6.0 branch is what was released as the Alpha where as the 4.6.0-wip is the current unstable (ie - where latest dev is going on).

The ordering might just be a bug from the migration from TFS, it isn't a simple task to do what they had to do and yes there may be bugs.

If you want to do fixes for the next release they should go into the tip tag.

16 Dec, 2010 09:17 AM

For more info on Mercurial try the obvious places, and try www.hginit.com. Also, StackOverflow.com and http://kiln.stackexchange.com/ (Kiln is Fogbugz's hosted Mercurial service) are good resources.

Rob Conery made a video on Tekpub about using Mercurial on Codeplex too.

blog comments powered by Disqus