[PATCH] cmdutil: display changeset diff in commit editor if verbose

Olle Lundberg olle.lundberg at gmail.com
Wed Dec 18 19:08:30 CST 2013


# HG changeset patch
# User Olle Lundberg <olle.lundberg at gmail.com>
# Date 1387414111 -3600
#      Thu Dec 19 01:48:31 2013 +0100
# Node ID daae1fe7a8ec64b7b7a385d4c11ca2833f62c91f
# Parent  04036798ebed0c6d7062517bb49b308a15e4345e
cmdutil: display changeset diff in commit editor if verbose

This adds the ability to display the changeset of what is
currently being commited. This feature exists in other VCSes
and might ease the transition for new users of mercurial.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1864,10 +1864,16 @@
     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 not added and not modified and not removed:
         edittext.append(_("HG: no files changed"))
+    else:
+        if repo.ui.verbose and util.safehasattr(ctx, 'diff'):
+            edittext.append("HG: --")
+            edittext.append(_("HG: changeset diff:"))
+            edittext.extend(["HG: %s" % line for diff in ctx.diff()
+                             for line in diff.splitlines()])
     edittext.append("")
     # run editor in the repository root
     olddir = os.getcwd()
     os.chdir(repo.root)
     text = repo.ui.edit("\n".join(edittext), ctx.user())


More information about the Mercurial-devel mailing list