Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to use inotify extension for Mercurial

📅 2015-Feb-10 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ hgwatchman, inotify, mercurial ⬩ 📚 Archive

hg status is the slowest command in Mercurial and can take several seconds on repositories with thousands of files. This is because it needs to check every single file and directory in your repository to see if it has changed. One method to speed up this command is to use the inotify extension for Mercurial.

Note: This extension is reported to be buggy and using the alternate hgwatchman extension is recommended. Note: This extension only works in Mercurial 2.x. It has been explicitly disabled in Mercurial 3.x and will not work.

This extension ships with the mercurial-common package and so it will already be installed on your system if you have Mercurial. It relies on the inotify subsystem of the Linux kernel and any kernel later than 2.6.13 will have it. It uses the filesystem to watch for changes and reports these to applications. Using this Mercurial can check the status of gigantic repositories quickly.

To enable this extension, just add these lines to your hgrc:

inotify =

That is it! I noticed a speedup on a large repository with 500K files, but it was not as much as I wanted.

Tried with: Mercurial 2.8.2, Linux 3.13.0 and Ubuntu 14.04

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧