# Thursday, May 24, 2012
« Getting started with Mercurial for a sma... | Main | Getting started with Mercurial for a sma... »

This is the fourth stop in this series.

I’m first going to mention using the command line and Nuget Package Restore.

To command line or not.  That is the question...

First time users, especially Windows heavy users such as myself have likely used Tortoise* at some point in our development to interact with a repository.  I started with TortoiseHg to help get the basics down but after Rob's challenge I gave the command line a shot and discovered two things.

  1. I was faster
  2. I understood Mercurial much better and what Tortoise was doing for me.

I still use Tortoise for a few things but for the most part I use the command line now for most operations. If you think this is the way for you have a look at posh-hg to add even more productivity.

Nuget Package Restore

Feel free to move on to the next section if your not using .Net.

Dependencies are something we must deal with in our version control story.  Nuget eases a developer’s life for managing dependencies but with Nuget Package Restore we can more cleanly keep our dependencies out of the source control but have an automated way of getting them into your project. 

Without Package Restore we would have to put the dependent libraries (dll's) in source control.  Usually one would create a library folder and have everything in this folder source controlled. 

With Package Restore we source control the configuration settings of the dependent libraries we are using with Nuget.  When we pull down a repository for the first time and build it Nuget will read the configuration and download all of the libraries in use.  We get a source control environment with the knowledge of what libraries we need but we don’t have to store the libraries in the source tree. 

To use it we’ll need to tell Mercurial to ignore the packages folder. The last item in the hgignore file in the third post has this covered. 

If you don’t like this idea, no problem.  You don’t have to use it.

Setting up a repository on your local machine

I do this with Tortoise although you can use the hg init command at the command line.

To use Nuget Package restore follow the instructions from David Ebbo’s post.

With TortoiseHg installed right-click on the root project folder.

Select TortoiseHg, Create Repository Here.


Keep the defaults and press Create.


Overwrite the hgignore file.

Either copy an hgignore file from another existing project in another folder OR copy over the text in the hgignore file with the text in the Ingore file section above.

Commit your project's initial state.

I do this with TortoiseHg as well.

Right-Click your root folder and Select HG Commit.


1. Check of the Check box in the upper left hand corner.  This tells Mercurial to add everything in the list.

2. Add a commit message.

3. Press Commit.


When prompted to add select add


Adding Nuget.exe (http://blog.davidebbo.com/2011/08/easy-way-to-set-up-nuget-to-restore.html)

Since we are using Nuget Package Restore we have to add the Nuget.exe to the repository.  Normally we don't want to save Dll's and/or Exe's to the repository.  The ignore file specifies this as the default.  As such we have to add it manually.  The same is true if down the line you need to use a 3rd party library that isn't available on NuGet.  In this case I would create a lib folder in the root of the project and place my library files in this folder.  From this folder I would add it to the repository and add a reference in VS.

Go to the .nuget folder in the root of your project directory.

Right-click nuget.exe, select TortoiseHg, Add Files... 

Keep the defaults and press Add


Notice the Icon changed to a plus sign for the file.

Select the Nuget.Exe file again and select Hg Commit


Add a comment and commit.


Your project is ready to go.

The next in the series will go into the commands for working in default.

Please login with either your OpenID above, or your details below.
(will show your gravatar icon)
Home page

Comment (Some html is allowed: b, blockquote@cite, em, i, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

[Captcha]Enter the code shown (prevents robots):

Live Comment Preview