How to use hgwatchman extension for Mercurial

hg status command can be very slow on a repository with thousands of files. This is because it has to explicitly check the status of every file. A great method to speed it up is the hgwatchman extension for Mercurial. It uses the Watchman tool which relies on the inotify mechanism of the Linux kernel to be notified directly of only the changes that occurred to the files in a directory. There are no packages of hgwatchman and Watchman for Ubuntu, so we need to build them from source. But it is pretty easy to do:

  • Install the Watchman tool as described here.

  • Download the hgwatchman source code:

$ hg clone
  • Build the code:
$ cd hgwatchman
$ make local

If you forget this step, everything seems to be fine until you start seeing this error:

$ hg status
abort: No module named bser! is a module that is built by this step.

  • Add these lines to your hgrc:
hgwatchman = /path/to/hgwatchman/hgwatchman

mode = on
  • That is it! You should see a nice improvement in the performance of hg status after using hgwatchman.

Tried with: Watchman 3.0.0, Mercurial. 2.8.3 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s