Google Code and Mercurial Tutorial for Eclipse Users
This post is a short introduction to using the Eclipse IDE and the HgEclipse plugin for projects hosted at Google Code Mercurial repositories.
HgEclipse is a free and open source Eclipse plugin that supports the Mercurial Distributed Version Control System right within the IDE, thus making these two a very convenient and efficient toolset for Java and C/C++ development. It is important to note that HgEclipse is absolutely not limited to Google Code's Mercurial repositories, it works with any Mercurial repository. We use Google Code merely because of its immediate availability and easy use.
What is Google Code? It is a popular hosting service for open source projects. It provides revision control, a rudimentary wiki, a basic issue tracker and file downloads. As for revision control, since April 2009 Google Code offers the Mercurial Distributed Version Control System as an option besidesSubversion. (Git is still unsupported by Google Code. If you are a Git user, codeBeamer Managed Repositories is a compelling option for you!)
We recommend watching the guided video first, then reading the explanatory notes below. First, here is the video tutorial. Watch it in full-screen HD:
1 - Installing HgEclipseYou can easily install the plugin with the Eclipse Update Manager. Read here how.
2 - Cloning a repository from Google CodeYou start by making a local copy (or clone according to the right DVCS terminology) of the repository hosted at the Google servers, and import that to Eclipse as a new project.
Luckily, HgEclipse offers a dedicated wizard for cloning and it makes the whole process very easy. The only thing you will need is the repository URL that is visible at the Command-line access section, under the Source tab in Google Code. You don't even need to authenticate with user name and password, since the Google Code repositories can be cloned anonymously.
3 - Working locally and committing your changesYou can add, delete and modify files just as you do it without Mercurial. The small grey stars over the regular file icons always indicate the files which have uncommitted changes.
When you decide you want to commit some changes, the most convenient way to do that is switching to the Syncronization View. This view shows three types of changes:
- Uncomitted: your local changes that are waiting to be committed to your local repo.
- Outgoing: changes committed to the local repo, but not pushed to Google Code yet.
- Incoming: changes that were pushed to Google Code by other developers, but are not pulled into your local repo yet.
Don't forget that, unlike in centralized version control systems, at this point these changes are still only in your local repo, and not in Google Code! The distributed approach also has the advantage that you can commit even offline. You need to be online only when pushing to Google Code.