[PATCH] commit: add --reuse-message for keeping the old commit message during amend
Brodie Rao
brodie at sf.io
Sun Feb 10 05:45:06 CST 2013
On Sat, Feb 9, 2013 at 11:35 AM, Durham Goode <durham at fb.com> wrote:
> # HG changeset patch
> # User Durham Goode <durham at 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 at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list