Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Using Mercurial for Version Control with IDEA

1 min read

I have being working with Mercurial with IDEA on Linux for the last few weeks and thought it would make the basis of a useful article.

Setting up Mercurial

IDEA includes a plugin (hg4idea) to access Mercurial so the first thing is to ensure this is setup and enabled. There is also a Mercurial settings section but I did not need to alter anything here. The plugin uses Mercurial so make sure this is installed on your machine.

hg4ideaWhen I started committing from IDEA, I found that the commits appeared under the username test@local rather than my username  from other operations (this is slightly annoying as Eclipse picks this information up automatically).

The solution is to add the details to your Mercurial configuration file. You can either edit the global version (which is $HOME/.hgrc) or edit it for each project (in which case there is a hidden directory .hg in your IDEA project containing the file hgrc). This may already contain some details – I added the following lines to my copy. There is good documentation on this at the Mercurial site.

[ui]
username = mark stephens <markstephens@idrsolutions.com>

Setting up a project in IDEA

IDEA has a specific option Checkout from version control to setup a new project from Version control which allows you to import and setup a project. It is straight-foward to use and means that IDEA is setup correctly. It is less fiddly than creating a new project in Mercurial with Eclipse.

I did try manually cloning the Mercurial project from the command-line and do not recommend this.

checkout new projectMercurial in use

The update project option is very slick and performs all the background operations you need in Mercurial – I run it at the start of every session. Commit allows you to compare changes and commit them – you just need to remember to push the changes as well!

IDEA also seems to be much faster in use for pushes and pulls than Eclipse.

Lastly, there is a littile display in the status bar which tells you which branch and revision you are on.

Final thoughts

I have found that Mercurial works very well in IDEA. It is fast and well-integrated. And if you get stuck, the IDEA developers are pretty helpful on anwsering any questions posted. Do you have any tips for using it with IDEA?

IDRsolutions develop a Java PDF Viewer and SDK, an Adobe forms to HTML5 forms converter, a PDF to HTML5 converter and a Java ImageIO replacement. On the blog our team post anything interesting they learn about.

Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2019. All rights reserved.