Patchwork cmdutil: show diffs in commit message with ui.verbosecommit option

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date July 10, 2013, 3:24 p.m.
Message ID <c1e50af1f27f672550f9.1373469867@Iris>
Download mbox | patch
Permalink /patch/1829/
State Superseded, archived
Headers show

Comments

Jordi Gutiérrez Hermoso - July 10, 2013, 3:24 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1373469596 14400
#      Wed Jul 10 11:19:56 2013 -0400
# Node ID c1e50af1f27f672550f9deca7c9983e1a93375a3
# Parent  83d0df2ddf3f2a07ed347afcfa30ddacc18b4c3d
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 once the commit message is written.
Alexander Plavin - July 15, 2013, 8:51 p.m.
2013/7/10 Jordi Gutiérrez Hermoso <jordigh@octave.org>:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1373469596 14400
> #      Wed Jul 10 11:19:56 2013 -0400
> # Node ID c1e50af1f27f672550f9deca7c9983e1a93375a3
> # Parent  83d0df2ddf3f2a07ed347afcfa30ddacc18b4c3d
> 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 once the commit message is written.

I'm not a patch reviewer, but like the idea and the patch. I've
applied it locally, as wanted to get this feature, and it works for
me. I'd like to see it accepted into hg upstream :)

>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1838,6 +1838,11 @@
>      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])
> +    edittext.append("HG: ")
> +    if repo.ui.config("ui","verbosecommit"):
> +        diff = ctx.diff()
> +        edittext.extend([_("HG: %s") % l
> +                         for f in diff for l in f.split("\n")])
>      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
> @@ -1244,6 +1244,10 @@
>  ``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.
> +
>
>  ``web``
>  -------
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Martin Geisler - July 16, 2013, 11:46 a.m.
Alexander Plavin <me@aplavin.ru> writes:

> 2013/7/10 Jordi Gutiérrez Hermoso <jordigh@octave.org>:
>> # HG changeset patch
>> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
>> # Date 1373469596 14400
>> #      Wed Jul 10 11:19:56 2013 -0400
>> # Node ID c1e50af1f27f672550f9deca7c9983e1a93375a3
>> # Parent  83d0df2ddf3f2a07ed347afcfa30ddacc18b4c3d
>> 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 once the commit message is written.
>
> I'm not a patch reviewer, 

We're all patch reviewers :) Helping crew by commenting on patches is
much appreciated -- that's how you help move Mercurial forward!
Augie Fackler - July 16, 2013, 3:10 p.m.
On Wed, Jul 10, 2013 at 11:24:27AM -0400, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1373469596 14400
> #      Wed Jul 10 11:19:56 2013 -0400
> # Node ID c1e50af1f27f672550f9deca7c9983e1a93375a3
> # Parent  83d0df2ddf3f2a07ed347afcfa30ddacc18b4c3d
> cmdutil: show diffs in commit message with ui.verbosecommit option

Queued, I like this well enough.

>
> 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 once the commit message is written.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1838,6 +1838,11 @@
>      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])
> +    edittext.append("HG: ")
> +    if repo.ui.config("ui","verbosecommit"):
> +        diff = ctx.diff()
> +        edittext.extend([_("HG: %s") % l
> +                         for f in diff for l in f.split("\n")])
>      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
> @@ -1244,6 +1244,10 @@
>  ``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.
> +
>
>  ``web``
>  -------
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - July 16, 2013, 4:06 p.m.
On Tue, Jul 16, 2013 at 11:10:51AM -0400, Augie Fackler wrote:
> On Wed, Jul 10, 2013 at 11:24:27AM -0400, Jordi Gutiérrez Hermoso wrote:
> > # HG changeset patch
> > # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> > # Date 1373469596 14400
> > #      Wed Jul 10 11:19:56 2013 -0400
> > # Node ID c1e50af1f27f672550f9deca7c9983e1a93375a3
> > # Parent  83d0df2ddf3f2a07ed347afcfa30ddacc18b4c3d
> > cmdutil: show diffs in commit message with ui.verbosecommit option
>
> Queued, I like this well enough.

Dropped this one, because it broke tests. Please send a fixed version
that passes the testsuite.

>
> >
> > 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 once the commit message is written.
> >
> > diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py
> > +++ b/mercurial/cmdutil.py
> > @@ -1838,6 +1838,11 @@
> >      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])
> > +    edittext.append("HG: ")
> > +    if repo.ui.config("ui","verbosecommit"):
> > +        diff = ctx.diff()
> > +        edittext.extend([_("HG: %s") % l
> > +                         for f in diff for l in f.split("\n")])
> >      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
> > @@ -1244,6 +1244,10 @@
> >  ``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.
> > +
> >
> >  ``web``
> >  -------
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel@selenic.com
> > http://selenic.com/mailman/listinfo/mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1838,6 +1838,11 @@ 
     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])
+    edittext.append("HG: ")
+    if repo.ui.config("ui","verbosecommit"):
+        diff = ctx.diff()
+        edittext.extend([_("HG: %s") % l
+                         for f in diff for l in f.split("\n")])
     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
@@ -1244,6 +1244,10 @@ 
 ``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.
+
 
 ``web``
 -------