How to make your mozilla-central Mercurial clone work faster
I like Mercurial. I also like Git, but recently, I’ve gotten pretty used to Mercurial.
One complaint I hear over and over (and I’m guilty of it myself sometimes), is that “Mercurial is slow”. I’ve even experienced that slowness during some of my Joy of Coding episodes.
This document did not exist when I first started working with Mercurial – back then, I was using mq or sometimes pbranch, and grumbling about how I missed Git.
But there is some gold in this document.
gps has been doing some killer work documenting best practices with Mercurial, and this document is one of the results of his labour.
watchman is a tool that some folks at Facebook wrote to monitor changes in a folder. hgwatchman is an extension for Mercurial that takes advantage of watchman for a repository, smartly precomputing a bunch of stuff when the folder changes so that when you fire a command, like
It takes a fraction of the time it’d take without hgwatchman. A fraction.
Here’s how I set hgwatchman up on my MacBook (though you should probably go by the Mercurial for Mozillians doc as the official reference):
- Install watchman with brew:
brew install watchman
- Clone the hgwatchman extension to some folder that you can easily remember and build it:
hg clone https://bitbucket.org/facebook/hgwatchman cd hgwatchman make local
- Add the following lines to my user .hgrc:
[extensions] hgwatchman = cloned-in-dir/hgwatchman/hgwatchman
- Make sure the extension is properly installed by running:
hg help extensions
- hgwatchman should be listed under “enabled extensions”. If it didn’t work, keep in mind that you want to target the hgwatchman directory
- And then in my mozilla-central .hg/.hgrc:
[watchman] mode = on
- Boom, you’re done!
Congratulations, hg should feel snappier now!