[PATCH] commit: --edit/-e to force edit of otherwise-supplied commit message

Augie Fackler raf at durin42.com
Sun Sep 8 22:15:58 CDT 2013


On Sun, Sep 08, 2013 at 07:15:13PM -0400, Bradley M. Kuhn wrote:
> # HG changeset patch
> # User "Bradley M. Kuhn" <bkuhn at ebb.org>
> # Date 1378681328 14400
> # Node ID 3d6eba7684266bacc022dfb3f15ce242fd645aa7
> # Parent  1d07bf106c2ad1c7ef5e257e754ca8d858bd04b0
> commit: --edit/-e to force edit of otherwise-supplied commit message

I'm not quite sure I see the use case - is this so you can edit
something after a script specified a commit message?

Also, I'm hesitant to spend the '-e' short flag right away, I guess
that depends on the use case.

>
> The --edit/-e option for the 'commit' command forces editor, even when a
> commit message has been provided already by other means, such as by the -m or
> -l options.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -1289,6 +1289,8 @@
>       _('mark a branch as closed, hiding it from the branch list')),
>      ('', 'amend', None, _('amend the parent of the working dir')),
>      ('s', 'secret', None, _('use the secret phase for committing')),
> +    ('e', 'edit', None,
> +     _('Further edit commit message already specified')),
>      ] + walkopts + commitopts + commitopts2 + subrepoopts,
>      _('[OPTION]... [FILE]...'))
>  def commit(ui, repo, *pats, **opts):
> @@ -1327,6 +1329,8 @@
>
>      Returns 0 on success, 1 if nothing changed.
>      """
> +    forceeditor = opts.get('force_editor') or opts.get('edit')
> +
>      if opts.get('subrepos'):
>          if opts.get('amend'):
>              raise util.Abort(_('cannot amend with --subrepos'))
> @@ -1365,7 +1369,7 @@
>              raise util.Abort(_('cannot amend changeset with children'))
>
>          e = cmdutil.commiteditor
> -        if opts.get('force_editor'):
> +        if forceeditor:
>              e = cmdutil.commitforceeditor
>
>          def commitfunc(ui, repo, message, match, opts):
> @@ -1405,7 +1409,7 @@
>              newmarks.write()
>      else:
>          e = cmdutil.commiteditor
> -        if opts.get('force_editor'):
> +        if forceeditor:
>              e = cmdutil.commitforceeditor
>
>          def commitfunc(ui, repo, message, match, opts):
> diff --git a/tests/test-commit.t b/tests/test-commit.t
> --- a/tests/test-commit.t
> +++ b/tests/test-commit.t
> @@ -119,7 +119,18 @@
>    $ hg add
>    adding bar/bar (glob)
>    adding foo/foo (glob)
> -  $ hg ci -m commit-subdir-1 foo
> +  $ HGEDITOR=cat hg ci -e -m commit-subdir-1 foo
> +  commit-subdir-1
> +
> +
> +  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
> +  HG: Leave message empty to abort commit.
> +  HG: --
> +  HG: user: test
> +  HG: branch 'default'
> +  HG: added foo/foo
> +
> +
>    $ hg ci -m commit-subdir-2 bar
>
>  subdir log 1
> @@ -173,11 +184,23 @@
>  dot and subdir commit test
>
>    $ hg init test3
> +  $ echo commit-foo-subdir > commit-log-test
>    $ cd test3
>    $ mkdir foo
>    $ echo foo content > foo/plain-file
>    $ hg add foo/plain-file
> -  $ hg ci -m commit-foo-subdir foo
> +  $ HGEDITOR=cat hg ci --edit -l ../commit-log-test foo
> +  commit-foo-subdir
> +
> +
> +  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
> +  HG: Leave message empty to abort commit.
> +  HG: --
> +  HG: user: test
> +  HG: branch 'default'
> +  HG: added foo/plain-file
> +
> +
>    $ echo modified foo content > foo/plain-file
>    $ hg ci -m commit-foo-dot .
>
> diff --git a/tests/test-completion.t b/tests/test-completion.t
> --- a/tests/test-completion.t
> +++ b/tests/test-completion.t
> @@ -199,7 +199,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, secret, include, exclude, message, logfile, date, user, subrepos
> +  commit: addremove, close-branch, amend, secret, edit, 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
> @@ -62,6 +62,7 @@
>                              list
>        --amend               amend the parent of the working dir
>     -s --secret              use the secret phase for committing
> +   -e --edit                Further edit commit message already specified
>     -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