How to Install Mercurial with Google Code on OpenSUSE 12.3

Many of us like to code and program. It’s an awesome and very satisfying hobby. Yet keeping track of your progress and different versions of files and what modifications have been made to those files is no easy task when you have them spread right across your hard drive in various locations. Thankfully there is an easy way to manage your software development projects using Google Code and version control software Mercurial.

Google Code

Google Code is a project hosting service operated by Google. It’s a fantastic service and very popular among the development community. And for good reason. It provides the user with access to a source code repository and gives you three options for your version control management. You can use the popular Git, Mercurial or Subversion.

Google Code also gives users a Wiki page for their project, Downloads directory, Bug reporting and tracking. The essentials to get your project running is all there. There are many other services on the internet that you might like to try. I am choosing to show you Google Code because it’s very simple to use and setup, even for beginners.

So head over to Google Code and set yourself up a new project to work on. And when prompted, ensure you choose Mercurial for your source code version control system.

Mercurial

Once you have your Google Code project page up and running, it’s now time to get writing some code and upload them to your new project.

I use zsh in the following tutorial, but you will probably be using Bash. The commands remain the same regardless of which shell you use.

The first thing we need to install is Mercurial. You can easily install Mercurial in OpenSUSE 12.3 by opening up a terminal and running the following command:

chris@suse:~> sudo zypper in mercurial

zypper will download and install the Mercurial package and required packages.

The first thing you will want to do is clone your Google Code source code repository to your home directory ~/

For the next command, you need to go to your Google Code project page and click on the Source tab. This will present you with the correct details to enter in to your terminal to clone your Mercurial repository to your own system.

This is easily done by punching the correct command in to your terminal. But make sure you enter the correct repository details for this to work correctly:

Now we are ready to upload your source code files to your Google Code project. Once you have the files ready to upload, you need to copy them in to your local repository directory. Here is my own example:

chris@suse:~/project-name> cp ../LICENCE.txt .

chris@suse:~/project-name> lsLICENCE.txt file_1.txt file_2.txt

LICENCE.txt is the new file that I have copied in to the local repository directory. So now we need to tell Mercurial there is something new that has been added.

chris@suse:~/project-name> hg addadding LICENCE.txt

And now we need to commit the changes. The following command launches vim. This is where you can enter your changes and notes for the commit you are performing:

chris@suse:~/project-name> hg commit

Once you’ve entered your notes, exit vim by entering:

:exit

Your commit details are now saved. Now we need to push the changes to the Google Code source code repository. This is easily done by doing the following and entering your password when prompted:

It’s very important to remember your Google Code Mercurial password is different to that of your usual Google Account password. This is something that always causes confusion with new users to Google Code. Your Mercurial password to be used for Google Code can be found by logging in to your Google Code project and in the upper right-hand corner of the page, you will see Profile next to your username. Click on Profile. And then click on the Settings tab. You should now see your Mercurial password you need to use for pushing changes to your project.

Once you have entered the correct password, you should see the following confirmation message:

remote: Success.

That’s it. You now have a running Google Code and Mercurial source code version control system running successfully.