changeset 21021:422981492ace

commit: --edit/-e to force edit of otherwise-supplied commit message 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.
author "Bradley M. Kuhn" <bkuhn@ebb.org>
date Sun, 08 Sep 2013 19:02:08 -0400
parents 5041163ee382
children 52e9e63f1495
files mercurial/commands.py tests/test-commit.t tests/test-completion.t tests/test-qrecord.t
diffstat 4 files changed, 33 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Apr 12 00:38:15 2014 -0400
+++ b/mercurial/commands.py	Sun Sep 08 19:02:08 2013 -0400
@@ -1324,6 +1324,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):
@@ -1362,6 +1364,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'))
@@ -1400,7 +1404,7 @@
             raise util.Abort(_('cannot amend changeset with children'))
 
         e = cmdutil.commiteditor
-        if opts.get('force_editor'):
+        if forceeditor:
             e = cmdutil.commitforceeditor
 
         # commitfunc is used only for temporary amend commit by cmdutil.amend
@@ -1435,7 +1439,7 @@
             newmarks.write()
     else:
         e = cmdutil.commiteditor
-        if opts.get('force_editor'):
+        if forceeditor:
             e = cmdutil.commitforceeditor
 
         def commitfunc(ui, repo, message, match, opts):
--- a/tests/test-commit.t	Sat Apr 12 00:38:15 2014 -0400
+++ b/tests/test-commit.t	Sun Sep 08 19:02:08 2013 -0400
@@ -120,7 +120,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
@@ -174,11 +185,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 .
 
--- a/tests/test-completion.t	Sat Apr 12 00:38:15 2014 -0400
+++ b/tests/test-completion.t	Sun Sep 08 19:02:08 2013 -0400
@@ -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
--- a/tests/test-qrecord.t	Sat Apr 12 00:38:15 2014 -0400
+++ b/tests/test-qrecord.t	Sun Sep 08 19:02:08 2013 -0400
@@ -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