Monday, December 10, 2012

Mercurial, tortoiseHg for Windows

By popular request

I have a lot of readers using Windows, and many who would like to develop on their PC, and then move the code to their Raspberry Pi (if they have a Pi) once they are ready to run. Before we get any further, if you plan on using a PC to develop applications for the Raspberry Pi, I would suggest you click on the menu above named "Sidekick". This is a tutorial to set up SSH and optionally X-Forwarding. Be sure to read through the end of the Sidekic tutorial, there is a link to Sidekick 2 (more advanced options).

Back to Hg

One question that has come up more than a few times (since I keep posting Python code on the blog and keep giving a Mercurial URL on bitbucket.org) is the following: how do I get and use Mercurial?

Mercurial is written in Python with platform independence in mind. It is available for Unix (OpenIndiana, Solaris) and Unix like systems (Linux, Mac OS/X). I've already posted the instructions for Raspbian (and hence all debian derived Linux versions) and Fedora. Today, I'm covering Windows.

Mercurial from the command line

A quick link to download any version of Mercurial:

mercurial.selenic.com/downloads/

32 bit windows with no admin rights required: Mercurial-2.4.1.exe
For the 64 bit windows version: Mercurial-2.4.1-x64.exe

After the download, run the program, and you are guided through an installation wizard. You now need to add the Mercurial path to the system's PATH. Once that is done, you have access to the hg command at the console.

Mercurial integrated in File Manager

Most Windows users will prefer the fully integrated version of Mercurial, through TortoiseHg: You can download TortoiseHg from: tortoisehg.bitbucket.org

The big green button on the right should download the right version for your operating system (Windows 32 or 64 bit, Linux with Gnome or Mac OS/X). After the download, run the program, and you are guided through an installation wizard.

Not only do you get mercurial in file manager, but you also get a command line mercurial: thg, so you don't have to install the console mercurial.




Example

Let's clone my Fablocker repository that is on bitbucket. From the command line that would be hg clone https://bitbucket.org/fdion/fablocker (or thg using the command line TortoiseHg).

But let's try this from File Manager.

From File Manager, create a folder where you will store your repositories. Let's call it bitbucket. Inside that folder, create a new one called fablocker. Right click the folder. You now have a few menu entries for Mercurial. Hg Workbench and TortoiseHg. Select TortoiseHg, then select clone. A dialog appears:



Change the source to read like the image:
source: https://bitbucket.org/fdion/fablocker

Destination should be to your bitbucket\fablocker directory already.

Now click the clone button. You are done!

PyHack Workshop 02 test.py program in Visual Studio
If you use Visual Studio to edit your Python code, you will probably want the Visual Hg plugin for Visual Studio available at:

visualhg.codeplex.com

It is also possible to get Mercurial integration in other IDEs. I'll cover those in a follow up article

No comments:

Post a Comment