Patchwork commit: add --reuse-message for keeping the old commit message during amend

login
register
mail settings
Submitter Durham Goode
Date Feb. 9, 2013, 11:35 a.m.
Message ID <96e2d74e5f7b32221480.1360409715@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/858/
State Changes Requested
Headers show

Comments

Durham Goode - Feb. 9, 2013, 11:35 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1360352769 28800
# Node ID 96e2d74e5f7b32221480fc7932c9555c84f10670
# Parent  e2b176cf28e374eb146c3e131871631ab9ace537
commit: add --reuse-message for keeping the old commit message during amend

When people do 'hg commit --amend', most of the time they don't want to change
the commit message.  This adds a flag to do that without prompting the user.

I imagine most people will use it in an alias such as:

  amend=commit --amend --reuse-message
Brodie Rao - Feb. 10, 2013, 11:45 a.m.
On Sat, Feb 9, 2013 at 11:35 AM, Durham Goode <durham@fb.com> wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1360352769 28800
> # Node ID 96e2d74e5f7b32221480fc7932c9555c84f10670
> # Parent  e2b176cf28e374eb146c3e131871631ab9ace537
> commit: add --reuse-message for keeping the old commit message during amend
>
> When people do 'hg commit --amend', most of the time they don't want to change
> the commit message.  This adds a flag to do that without prompting the user.
>
> I imagine most people will use it in an alias such as:
>
>   amend=commit --amend --reuse-message

What happens if you specify --reuse-message without --amend? Should
that raise an error?

>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1702,7 +1702,7 @@
>                  date = opts.get('date') or old.date()
>              editmsg = False
>              if not message:
> -                editmsg = True
> +                editmsg = not opts.get('reuse_message')
>                  message = old.description()
>
>              pureextra = extra.copy()
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -1241,6 +1241,8 @@
>      ('', 'close-branch', None,
>       _('mark a branch as closed, hiding it from the branch list')),
>      ('', 'amend', None, _('amend the parent of the working dir')),
> +    ('', 'reuse-message', None,
> +      _('used with amend to reuse the previous commit message')),
>      ] + walkopts + commitopts + commitopts2 + subrepoopts,
>      _('[OPTION]... [FILE]...'))
>  def commit(ui, repo, *pats, **opts):
> diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
> --- a/tests/test-commit-amend.t
> +++ b/tests/test-commit-amend.t
> @@ -518,3 +518,14 @@
>    date:        Thu Jan 01 00:00:00 1970 +0000
>    summary:     babar
>
> +
> +Test amend with reuse-message flag
> +---------------------------------------------------------------------
> +Verify that the editor doesn't appear
> +  $ hg rm a
> +  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --reuse-message
> +  $ hg log -r . --template "Description: {desc}\n" --stat
> +  Description: a''
> +   a |  7 -------
> +   1 files changed, 0 insertions(+), 7 deletions(-)
> +
> diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
> --- a/tests/test-debugcomplete.t
> +++ b/tests/test-debugcomplete.t
> @@ -197,7 +197,7 @@
>    add: include, exclude, subrepos, dry-run
>    annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude
>    clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
> -  commit: addremove, close-branch, amend, include, exclude, message, logfile, date, user, subrepos
> +  commit: addremove, close-branch, amend, reuse-message, include, exclude, message, logfile, date, user, subrepos
>    diff: rev, change, text, git, nodates, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos
>    export: output, switch-parent, rev, text, git, nodates
>    forget: include, exclude
> diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
> --- a/tests/test-qrecord.t
> +++ b/tests/test-qrecord.t
> @@ -61,6 +61,7 @@
>        --close-branch        mark a branch as closed, hiding it from the branch
>                              list
>        --amend               amend the parent of the working dir
> +      --reuse-message       used with amend to reuse the previous commit message
>     -I --include PATTERN [+] include names matching the given patterns
>     -X --exclude PATTERN [+] exclude names matching the given patterns
>     -m --message TEXT        use text as commit message
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Pierre-Yves David - Feb. 12, 2013, 1:38 p.m.
On Sun, Feb 10, 2013 at 11:45:06AM +0000, Brodie Rao wrote:
> On Sat, Feb 9, 2013 at 11:35 AM, Durham Goode <durham@fb.com> wrote:
> > # HG changeset patch
> > # User Durham Goode <durham@fb.com>
> > # Date 1360352769 28800
> > # Node ID 96e2d74e5f7b32221480fc7932c9555c84f10670
> > # Parent  e2b176cf28e374eb146c3e131871631ab9ace537
> > commit: add --reuse-message for keeping the old commit message during amend
> >
> > When people do 'hg commit --amend', most of the time they don't want to change
> > the commit message.  This adds a flag to do that without prompting the user.
> >
> > I imagine most people will use it in an alias such as:
> >
> >   amend=commit --amend --reuse-message
> 
> What happens if you specify --reuse-message without --amend? Should
> that raise an error?

Pinging the question.
Pierre-Yves David - Feb. 12, 2013, 2:17 p.m.
On Sat, Feb 09, 2013 at 03:35:15AM -0800, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1360352769 28800
> # Node ID 96e2d74e5f7b32221480fc7932c9555c84f10670
> # Parent  e2b176cf28e374eb146c3e131871631ab9ace537
> commit: add --reuse-message for keeping the old commit message during amend
> 
> When people do 'hg commit --amend', most of the time they don't want to change
> the commit message.  This adds a flag to do that without prompting the user.
> 
> I imagine most people will use it in an alias such as:
> 
>   amend=commit --amend --reuse-message

the git --reuse-measage have a different semantic. we *NEED* another name.
Angel Ezquerra - Feb. 12, 2013, 2:40 p.m.
On Feb 12, 2013 3:17 PM, "Pierre-Yves David" <pierre-yves.david@logilab.fr>
wrote:
>
> On Sat, Feb 09, 2013 at 03:35:15AM -0800, Durham Goode wrote:
> > # HG changeset patch
> > # User Durham Goode <durham@fb.com>
> > # Date 1360352769 28800
> > # Node ID 96e2d74e5f7b32221480fc7932c9555c84f10670
> > # Parent  e2b176cf28e374eb146c3e131871631ab9ace537
> > commit: add --reuse-message for keeping the old commit message during
amend
> >
> > When people do 'hg commit --amend', most of the time they don't want to
change
> > the commit message.  This adds a flag to do that without prompting the
user.
> >
> > I imagine most people will use it in an alias such as:
> >
> >   amend=commit --amend --reuse-message
>
> the git --reuse-measage have a different semantic. we *NEED* another name.
>
> --
> Pierre-Yves David

What about "--keepmessage"?

Angel
Durham Goode - Feb. 12, 2013, 9:02 p.m.
I've added code locally that will abort with a message if they use it
without --amend.  It'll be part of the V2 patch.

On 2/12/13 1:38 PM, "Pierre-Yves David" <pierre-yves.david@logilab.fr>
wrote:

>On Sun, Feb 10, 2013 at 11:45:06AM +0000, Brodie Rao wrote:
>> On Sat, Feb 9, 2013 at 11:35 AM, Durham Goode <durham@fb.com> wrote:
>> > # HG changeset patch
>> > # User Durham Goode <durham@fb.com>
>> > # Date 1360352769 28800
>> > # Node ID 96e2d74e5f7b32221480fc7932c9555c84f10670
>> > # Parent  e2b176cf28e374eb146c3e131871631ab9ace537
>> > commit: add --reuse-message for keeping the old commit message during
>>amend
>> >
>> > When people do 'hg commit --amend', most of the time they don't want
>>to change
>> > the commit message.  This adds a flag to do that without prompting
>>the user.
>> >
>> > I imagine most people will use it in an alias such as:
>> >
>> >   amend=commit --amend --reuse-message
>> 
>> What happens if you specify --reuse-message without --amend? Should
>> that raise an error?
>
>Pinging the question.
>
>-- 
>Pierre-Yves David
>
>http://www.logilab.fr/
>
Durham Goode - Feb. 12, 2013, 9:16 p.m.
>>  
>>  the git --reuse-measage have a different semantic. we *NEED* another
>>name.
>>  
>>  --
>>  Pierre-Yves David
>  
>  What about "--keepmessage"?
>  Angel

--keep-message was what I had in mind originally, but others thought using
git's flag might make it easier for git refugees.  I don't think the
slightly different semantic means we can't use the same name.

Both names are descriptive enough and both are long, so I don't think
there's any real difference.

-Durham

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1702,7 +1702,7 @@ 
                 date = opts.get('date') or old.date()
             editmsg = False
             if not message:
-                editmsg = True
+                editmsg = not opts.get('reuse_message')
                 message = old.description()
 
             pureextra = extra.copy()
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1241,6 +1241,8 @@ 
     ('', 'close-branch', None,
      _('mark a branch as closed, hiding it from the branch list')),
     ('', 'amend', None, _('amend the parent of the working dir')),
+    ('', 'reuse-message', None,
+      _('used with amend to reuse the previous commit message')),
     ] + walkopts + commitopts + commitopts2 + subrepoopts,
     _('[OPTION]... [FILE]...'))
 def commit(ui, repo, *pats, **opts):
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -518,3 +518,14 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     babar
   
+
+Test amend with reuse-message flag
+---------------------------------------------------------------------
+Verify that the editor doesn't appear
+  $ hg rm a
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --reuse-message
+  $ hg log -r . --template "Description: {desc}\n" --stat
+  Description: a''
+   a |  7 -------
+   1 files changed, 0 insertions(+), 7 deletions(-)
+  
diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t
+++ b/tests/test-debugcomplete.t
@@ -197,7 +197,7 @@ 
   add: include, exclude, subrepos, dry-run
   annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude
   clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
-  commit: addremove, close-branch, amend, include, exclude, message, logfile, date, user, subrepos
+  commit: addremove, close-branch, amend, reuse-message, include, exclude, message, logfile, date, user, subrepos
   diff: rev, change, text, git, nodates, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos
   export: output, switch-parent, rev, text, git, nodates
   forget: include, exclude
diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
--- a/tests/test-qrecord.t
+++ b/tests/test-qrecord.t
@@ -61,6 +61,7 @@ 
       --close-branch        mark a branch as closed, hiding it from the branch
                             list
       --amend               amend the parent of the working dir
+      --reuse-message       used with amend to reuse the previous commit message
    -I --include PATTERN [+] include names matching the given patterns
    -X --exclude PATTERN [+] exclude names matching the given patterns
    -m --message TEXT        use text as commit message