[PATCH 1 of 2] commit: save commit message so it's not destroyed by rollback

Greg Ward greg-hg at gerg.ca
Mon Nov 23 21:14:42 CST 2009


On Mon, Nov 23, 2009 at 12:58 PM, Matt Mackall <mpm at selenic.com> wrote:
>> +            # save commit message in case this transaction gets rolled
>> +            # back (e.g. by a pretxncommit hook)
>> +            msgfile = self.opener('message', 'wt')
>> +            msgfile.write(cctx._text.rstrip() + '\n')
>> +            msgfile.close()
>
> Text mode and additional processing both strike me as wrong.

Oops, I can never remember if "t" or "b" is the default.  My fopen()
man page says text mode is the default, and "b" means binary which of
course has no effect on posix systems.  So if I remove the "t" from
the mode, we're both happy, right?  ;-)

As for the strip() + '\n': that's so the file contents look the same
whether you do

  hg ci -m"precious message"

or

  hg ci

and enter the precious message in your editor.  In the former case,
it's nice to guarantee a trailing newline.  In the latter case, it's
nice to guarantee exactly one trailing newline.  But it's mainly so
"cat .hg/message" gives consistent results.  If you really don't want
it, I'll drop it.

As for the great filename debate: I went with "message" at Adrian's
request, 'cause I did not think very long and hard about the
interaction between this patch and his 'message' extension.  If
filename collision really renders his extension useless, then I vote
for ".hg/last-message.txt".  If the ".txt" is really important for
Windows users, by all means let's supply it: their lives are difficult
enough as it is already, deprived as they are of a decent command
line.  Let's not make them any harder.

(Why yes, I did spend much of this afternoon fighting with our Windows
build system at work... and no I'm not bitter!)

I'll let the filename debate subside a little and resend tomorrow.  If
you really hate ".hg/last-message.txt", now would be a good time to
speak up.  (Hey, it's still better than ".svn/COMMIT-MSG".  Why does
it have to shout at me? ;-)

Greg


More information about the Mercurial-devel mailing list