[PATCH 1 of 2] commit: save commit message so it's not destroyed by rollback
Matt Mackall
mpm at selenic.com
Mon Nov 23 21:32:05 CST 2009
On Mon, 2009-11-23 at 22:14 -0500, Greg Ward wrote:
> 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? ;-)
Why not simply 'wb'? And keep the commit message exactly as we got it?
Text mode just shouldn't exist and we should avoid it on principle.
> 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
I suppose.
> 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".
Great.
--
http://selenic.com : development and support for Mercurial and Linux
More information about the Mercurial-devel
mailing list