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

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date July 16, 2013, 8:57 p.m.
Message ID <ef066d1bb2a746832648.1374008264@Iris>
Download mbox | patch
Permalink /patch/1909/
State Superseded
Headers show

Comments

Jordi Gutiérrez Hermoso - July 16, 2013, 8:57 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 ef066d1bb2a746832648e03c021233d0a58b4b5d
# Parent  8667e65a39e117b7b6d9dbaf6f922be97314ee80
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 21, 2013, 11:51 p.m.
2013/7/17 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 ef066d1bb2a746832648e03c021233d0a58b4b5d
> # Parent  8667e65a39e117b7b6d9dbaf6f922be97314ee80
> 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.
>
> 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])
> +    if repo.ui.config("ui","verbosecommit"):
> +        edittext.append("HG: ")
> +        diff = ctx.diff()
> +        edittext.extend([_("HG: %s") % l
> +                         for f in diff for l in f.split("\n")])

This shows full diff when only some changes are selected with crecord.

>      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,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``
>  -------
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Matt Mackall - July 22, 2013, 8:25 p.m.
On Mon, 2013-07-22 at 03:51 +0400, Alexander Plavin wrote:
> 2013/7/17 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 ef066d1bb2a746832648e03c021233d0a58b4b5d
> > # Parent  8667e65a39e117b7b6d9dbaf6f922be97314ee80
> > 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.
> >
> > 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])
> > +    if repo.ui.config("ui","verbosecommit"):
> > +        edittext.append("HG: ")
> > +        diff = ctx.diff()
> > +        edittext.extend([_("HG: %s") % l
> > +                         for f in diff for l in f.split("\n")])
> 
> This shows full diff when only some changes are selected with crecord.

Does it affect any extensions distributed with hg? If not, you're
reporting this to the wrong people. We reserve the right to break our
internals at our whim.

If so, it'll probably want a BTS report.
Alexander Plavin - July 22, 2013, 9:08 p.m.
2013/7/23 Matt Mackall <mpm@selenic.com>:
> On Mon, 2013-07-22 at 03:51 +0400, Alexander Plavin wrote:
>> 2013/7/17 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 ef066d1bb2a746832648e03c021233d0a58b4b5d
>> > # Parent  8667e65a39e117b7b6d9dbaf6f922be97314ee80
>> > 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.
>> >
>> > 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])
>> > +    if repo.ui.config("ui","verbosecommit"):
>> > +        edittext.append("HG: ")
>> > +        diff = ctx.diff()
>> > +        edittext.extend([_("HG: %s") % l
>> > +                         for f in diff for l in f.split("\n")])
>>
>> This shows full diff when only some changes are selected with crecord.
>
> Does it affect any extensions distributed with hg? If not, you're
> reporting this to the wrong people. We reserve the right to break our
> internals at our whim.

Okay, for extensions bundled with hg it affects 'record' same way as I
wrote about crecord. Also, at least for me, running 'hg ci --amend'
when this config option is enabled gives "AttributeError: 'memctx'
object has no attribute 'diff'".

>
> If so, it'll probably want a BTS report.

Why? This is not in official hg yet.

>
> --
> Mathematics is the supreme nostalgia of our time.
>
>
Matt Mackall - July 22, 2013, 10:50 p.m.
On Tue, 2013-07-23 at 01:08 +0400, Alexander Plavin wrote:
> 2013/7/23 Matt Mackall <mpm@selenic.com>:
> > On Mon, 2013-07-22 at 03:51 +0400, Alexander Plavin wrote:
> >> 2013/7/17 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 ef066d1bb2a746832648e03c021233d0a58b4b5d
> >> > # Parent  8667e65a39e117b7b6d9dbaf6f922be97314ee80
> >> > 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.
> >> >
> >> > 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])
> >> > +    if repo.ui.config("ui","verbosecommit"):
> >> > +        edittext.append("HG: ")
> >> > +        diff = ctx.diff()
> >> > +        edittext.extend([_("HG: %s") % l
> >> > +                         for f in diff for l in f.split("\n")])
> >>
> >> This shows full diff when only some changes are selected with crecord.
> >
> > Does it affect any extensions distributed with hg? If not, you're
> > reporting this to the wrong people. We reserve the right to break our
> > internals at our whim.
> 
> Okay, for extensions bundled with hg it affects 'record' same way as I
> wrote about crecord. Also, at least for me, running 'hg ci --amend'
> when this config option is enabled gives "AttributeError: 'memctx'
> object has no attribute 'diff'".
> 
> >
> > If so, it'll probably want a BTS report.
> 
> Why? This is not in official hg yet.

<rhetorical>
Is it more acceptable to lose track of an issue in soon-to-be-released
code than in already-released code?
</rhetorical>

If it breaks commit --amend, it needs to be marked urgent.
Pierre-Yves David - April 14, 2014, 4:17 a.m.
This V2 seems to have never been queued.

Augie, do we still want to queue this?

On 07/16/2013 04:57 PM, 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 ef066d1bb2a746832648e03c021233d0a58b4b5d
> # Parent  8667e65a39e117b7b6d9dbaf6f922be97314ee80
> 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.
>
> 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])
> +    if repo.ui.config("ui","verbosecommit"):
> +        edittext.append("HG: ")
> +        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,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``
>   -------
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Augie Fackler - April 14, 2014, 2:53 p.m.
On Apr 14, 2014, at 12:17 AM, Pierre-Yves David <pierre-yves.david@ens-lyon.org> wrote:

> This V2 seems to have never been queued.
> 
> Augie, do we still want to queue this?

I'm inclined to say "no" if it really misbehaves with record. That'd confuse the dickens out of me.

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])
+    if repo.ui.config("ui","verbosecommit"):
+        edittext.append("HG: ")
+        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,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``
 -------