What do different VCSs do when a file changes?

2007-10-11 15:05:11 -08:00

Here’s the scenario:

  1. You change a file.
  2. You invoke your-vcs-here commit file.txt (or equivalent).
  3. You write a commit message in the editor.
  4. 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.)
  5. 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.

4 Responses to “What do different VCSs do when a file changes?”

  1. Jack Says:

    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.

  2. Peter Hosey Says:

    Jack: Cool. I’ve edited the post. Thanks.

  3. jpc Says:

    From my experience Mercurial silently commits the version from the time when the editor started. (unlike svn)

  4. Peter Hosey Says:

    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.

Leave a Reply

Do not delete the second sentence.