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

Matt Mackall mpm at selenic.com
Mon Nov 23 11:58:30 CST 2009


On Sun, 2009-11-22 at 13:11 -0500, Greg Ward wrote:
> # HG changeset patch
> # User Greg Ward <greg-hg at gerg.ca>
> # Date 1258913378 18000
> # Node ID 6ea4ff1d9cc2992d7fd7ee69f4597b1ba015b3b7
> # Parent  ac73cd788853749074dfcddbc1f66ac2432f898e
> commit: save commit message so it's not destroyed by rollback.
> (issue1635)
> 
> Rationale: if a pretxncommit hook rejects this commit, the transaction
> is rolled back and the user's commit message is irrevocably lost.
> So save a copy in .hg/message, just in case.  Also handy if the user
> deliberately rolls back a commit in order to amend it.
> 
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -829,6 +829,12 @@
>                      state[s] = (state[s][0], sr)
>                  subrepo.writestate(self, state)
>  
> +            # 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.

-- 
http://selenic.com : development and support for Mercurial and Linux




More information about the Mercurial-devel mailing list