How to get mercury to show diff during `hg com`?

Is there a way to configure hg com so that in the commit message file that pops up in an external editor, instead of just showing which files were modified (in the HG: lines), does this actually show full diff? I would rather look at the output and compose a commit message at the same time because of the comfort of my text editor, rather than doing hg diff on the command line separately in advance.

+6
mercurial diff
source share
3 answers

TortoiseHg does this out of the box: the top panel for the commit message and below it, the left panel that lists the affected files and the right panel showing the differences, one after the other.

+1
source share

Since 2016, you can do this using the committemplate configuration option. Adding the following to the hgrc file will include diff in the editor window when you type a commit message.

 [committemplate] changeset = {desc}\n\n HG: {extramsg} HG: user: {author}\n{ifeq(p2rev, "-1", "", "HG: branch merge\n") }HG: branch '{branch}'\n{if(currentbookmark, "HG: bookmark '{currentbookmark}'\n") }{subrepos % "HG: subrepo {subrepo}\n" } {splitlines(diff()) % 'HG: {line}\n'} 

For more information, see hg help hgrc and search for committemplate .

+5
source share

Mercurial does not have this as a built-in function, but it easily mimics in your editor (how commit is run).

Here is an example of using VIM: https://www.mercurial-scm.org/wiki/DiffsInCommitMessageInVIM

Below is a list of hgeditor script https://www.mercurial-scm.org/hg/hg-stable/raw-file/tip/hgeditor .

Basic meaning:

  • when you start the hg diff editor, redirect to a temporary file
  • load your editor both commit message file and diff file
+2
source share

All Articles