hg commit doesn't catch changes made during editing of commit messages

Matt Mackall mpm at selenic.com
Wed Aug 24 16:11:13 CDT 2005

On Wed, Aug 24, 2005 at 06:56:56PM +0200, Michal Kvasnica wrote:
> Hello,
> I have noticed following problem:
> $ hg init hgtest
> $ cd hgtest
> $ echo line 1 > a
> $ hg add a
> $ hg commit
> here my editor (jmacs) starts and I can enter the commit message. While
> still in the editor, I modify file "a" in second shell:
> $ echo line 2 >> a
> after this I quit the editor, commiting the changes.
> $ hg cat a
> line 1
> so "hg commit" using the external editor didn't catch the changes made
> during editing the commit message. Is this the desired behavior? If it
> is, then the following:
> $ hg diff
> [nothing]
> should certainly show the second modification. But it doesn't.
> I am using the latest tip:
> Mercurial Distributed SCM (version 31dcaf9123ba)

Ok, there are two distinct things going on here:

1) Mercurial doesn't launch $EDITOR until everything except the
changeset description itself is committed.

2) Mercurial doesn't update the dirstate of files until it's
completely finished the commit, so files changed while in the commit
are marked clean though not committed

The first is a little peculiar and suboptimal. The reason is mostly to
do with signing. To sign, we need to have calculated the manifest
hash, which means we need to have calculated the file hashes, which
means we need to have committed everything. Then we can pass the
manifest hash off to $EDITOR and get things signed. 

This has the downside that the repo is locked longer while you're
composing your message, but since repos are mostly private, this
doesn't matter. It also has the confusing side effect of not
committing changes you make while in $EDITOR.

The second is perhaps a bug. Getting rid of the race entirely will be

Mathematics is the supreme nostalgia of our time.

More information about the Mercurial mailing list