What do different VCSs do when a file changes?
Here’s the scenario:
- You change a file.
- You invoke your-vcs-here commit file.txt (or equivalent).
- You write a commit message in the editor.
- You suspend the editor with ^z and make another change to a file. (Perhaps you started the commit and a build at the same time, and the build failed because you forgot a comma.)
- You resume the editor, and issue :wq or ^x^c to save and exit.
What happens?
Subversion
svn commits the changed version of the file—in other words, the file as it existed when the editor exited.
Monotone
mtn notices that the file changed, tells you “you can’t do that”, and throws away saves the commit message.
More precisely, it says:
mtn: misuse: file 'Test.txt' modified during commit, aborting
darcs
darcs commits the file as it existed before it started the editor. (Presumably, it copies changed files to a staging area rather than simply committing them from the WC.)
Mercurial
hg commits the file as it existed before it started the editor, just as darcs does.
UPDATE 2008-03-05: Jack, in a comment below, corrected me on what Monotone does with the commit message. I have applied this correction above.
UPDATE 2008-03-26: jpc, in a comment below, corrected me on what Mercurial does with the commit message. I thought that that’s what I had written, but I wrote the wrong thing: that it acted like svn, rather than darcs. I apologize for the brainfart, and I have applied this correction above.
March 5th, 2008 at 08:39:22
Monotone doesn’t throw away your commit message, it stores it. When you commit again, it’ll pop up $EDITOR and you can edit your message again.
March 5th, 2008 at 10:14:25
Jack: Cool. I’ve edited the post. Thanks.
March 26th, 2008 at 07:24:16
From my experience Mercurial silently commits the version from the time when the editor started. (unlike svn)
March 26th, 2008 at 09:34:53
jpc: WTF? I thought that that’s what I said, but now I see that I wrote that it acted like svn. I don’t know what happened there.
I shall fix it immediately. Thank you.