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

Jordi Gutiérrez Hermoso jordigh at octave.org
Sat Jan 11 13:12:21 CST 2014


# 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

The following adds an option, ui.verbosecommit, which displays the
entire diff about to be committed in the text editor window, prefixed
with "HG:". This is useful as a final reminder of what's about to be
committed while writing the commit message.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1864,6 +1864,12 @@
     edittext.extend([_("HG: added %s") % f for f in added])
     edittext.extend([_("HG: changed %s") % f for f in modified])
     edittext.extend([_("HG: removed %s") % f for f in removed])
+    if repo.ui.config("ui","verbosecommit"):
+        edittext.append("HG: ")
+        diff = ctx.diff()
+        for f in diff:
+            for l in f.split("\n"):
+                edittext.extend([_("HG: %s") % l])
     if not added and not modified and not removed:
         edittext.append(_("HG: no files changed"))
     edittext.append("")
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1253,6 +1253,11 @@
 ``verbose``
     Increase the amount of output printed. True or False. Default is False.
 
+``verbosecommit``
+    Put more information prefixed with "HG: " in commit messages when
+    editing them, such as the diff that's about to be committed.
+    Default is False.
+
 
 ``web``
 -------


More information about the Mercurial-devel mailing list