Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

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?

Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Pros and Cons of Bitbucket Pipelines

Recently I have been looking at our current test suite looking for ways to improve our own tests. As we use Bitbucket we have...
Kieran France
3 min read

WTF: What’s The Future and Why It’s Up To…

If you want to know what is going to happen in the future, the person to ask is Tim O’Reilly. As well as being...
Bethan Palmer
2 min read

Leave a Reply

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