How can I make "commit" abort if there are uncommitted subrepo changes in Mercurial?

mercurial, mercurial-subrepos

Solution

You have two options:

- Upgrade your Mercurial instalation to 2.0 or later

Edit your `~/.hgrc` file and add the following option to the `[ui]` section:

commitsubrepos = false

Problem

This seems to happen all the time to me: I work on the parent repo. I find and fix a bug in a subrepo. I carry on with parent repo work. I commit the parent repo with a message like "Added feature X". I push. At this point I notice that the subrepo bugfix got committed and pushed too, with a commit message that has absolutely nothing to do with the subrepo. What’s the easiest way to make myself a "commit" replacement which would refuse to do anything in this situation, pointing out that a subrepo has uncommitted changes? Alternatively, perhaps there’s a setting I can put in my `.hgrc`?

Original source