[PATCH] cmdutil: show diffs in commit message with ui.verbosecommit option

Martin Geisler martin at geisler.net
Sat Jan 18 09:16:56 CST 2014


Jordi Gutiérrez Hermoso <jordigh at octave.org> writes:

> On Sat, 2014-01-11 at 15:20 -0600, Martin Geisler wrote:
>> Jordi Gutiérrez Hermoso <jordigh at octave.org> writes:
>> 
>> > # HG changeset patch
>> > # User Jordi Gutiérrez Hermoso <jordigh at octave.org>
>> > # Date 1373469596 14400
>> > #      Wed Jul 10 11:19:56 2013 -0400
>> > # Node ID b40695568db84a43b24cffb4c32583a759d96b09
>> > # Parent  01bdccfeb9d98ae85388d06c9c694b946f346edf
>> > cmdutil: show diffs in commit message with ui.verbosecommit option
>> 
>> I know people have been asking for this, but I've never really
>> understood why: I simply run 'hg diff' in another terminal or take a
>> peek in TortoiseHg.
>
> It would be convenient to be able to look at the diff as one is
> writing a commit message about it. Indeed, since lines beginning with
> HG: are ignored, it is even possible to even annotate the diff inline
> in the commit message. It seems useful to me.

What I tried to say is that I think we'll be in one of two situations:

a) the diff is small enough that I can understand it when I read it in
   the commit editor

b) the diff is large and complicated (spanning multiple files with
   larger changes in each file)

In the first case I would prefer to refer back to my (colored!) 'hg
diff' output in the terminal -- in the second case I would need to use a
real diff tool anyway to get a sense of what's going on. That is why I
don't see the utility of adding a ton of 'HG:' prefixed lines to the
commit editor message.

Maybe my logic is wrong for you, maybe you like to run 'hg commit'
without having run 'hg diff' first? That would seem odd to me, but maybe
that's how you work :)

Maybe a better approach would be to work on having Mercurial include
some good wrapper scripts that would inject this information into the
commit message template before opening the normal editor.

That way you don't have to change core Mercurial -- you set ui.editor to
"inject-diff-editor" and you're done. You could even create a
third-party project to developer and distribute such editor wrappers. If
they're installed in the user's PATH, enabling a particular editor
wrapper would be just as easy as setting

  [ui]
  show-me-diffs-in-the-commit-msg-template = yes

Just a thought.

> Another use case is as a final reminder of what's about to be
> committed if using hg (c)record. In that case, you want to see what
> you're about to commit, "hg diff" or thg will be no help. I thought
> this patch helped with the case of (c)record, but testing it again, I
> see that it doesn't. I'll fix this.

So me, that sounds like a better motivation.

-- 
Martin Geisler


More information about the Mercurial-devel mailing list