You might have noticed that I had no “Things I’ve Learned This Week” post last week. Sorry about that – by the end of the week, I looked at my Evernote of “lessons from the week”, and it was empty. I’m certain I’d learned stuff, but I just failed to write it down. So I guess the lesson I learned last week was, always write down what you learn.
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 past week, I was helping my awesome new intern get set up to tear into some e10s bugs, and at some point we went through this document to get her .hgrc all set up.
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.
The part that’s really made the difference for me is the hgwatchman bit.
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
- Add the following lines to my user .hgrc:
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:
mode = on
- Boom, you’re done!
Congratulations, hg should feel snappier now!
Next step is to try out this chg thing – though I’m having some issues still.