[PATCH 14 of 19] tag: use the editor gotten by "getcommiteditor()" instead of "ui.edit()"

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat May 10 11:08:49 CDT 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1399736976 -32400
#      Sun May 11 00:49:36 2014 +0900
# Node ID 3a4c7b9f7ae1c785cd6a9ee35af99065e6eb088d
# Parent  76ac94ee25a1f40f12acaf4b6f0677439a918dac
tag: use the editor gotten by "getcommiteditor()" instead of "ui.edit()"

This patch also enhances "test-tag.t", because "hg tag" hasn't been
explicitly tested around editor invocation and "--edit" option.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5695,11 +5695,7 @@
         if date:
             date = util.parsedate(date)
 
-        if opts.get('edit'):
-            def editor(repo, ctx, subs):
-                return ui.edit(ctx.description() + "\n", ctx.user())
-        else:
-            editor = False
+        editor = cmdutil.getcommiteditor(**opts)
 
         # don't allow tagging the null rev
         if (not opts.get('remove') and
diff --git a/tests/test-tag.t b/tests/test-tag.t
--- a/tests/test-tag.t
+++ b/tests/test-tag.t
@@ -16,7 +16,10 @@
   abort: tag names cannot consist entirely of whitespace
   [255]
 
-  $ hg tag "bleah"
+(this tests also that editor is not invoked, if '--edit' is not
+specified)
+
+  $ HGEDITOR=cat hg tag "bleah"
   $ hg history
   changeset:   1:d4f0d2909abc
   tag:         tip
@@ -219,6 +222,9 @@
 test custom commit messages
 
   $ cat > editor.sh << '__EOF__'
+  > echo "==== before editing"
+  > cat "$1"
+  > echo "===="
   > echo "custom tag message" > "$1"
   > echo "second line" >> "$1"
   > __EOF__
@@ -250,8 +256,22 @@
   > pretxncommit.unexpectedabort = false
   > __EOF__
 
+(this tests also that editor is invoked, if '--edit' is specified,
+regardless of '--message')
+
   $ rm -f .hg/last-message.txt
-  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e -m "foo bar"
+  ==== before editing
+  foo bar
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'tag-and-branch-same-name'
+  HG: changed .hgtags
+  ====
   transaction abort!
   rollback completed
   note: commit message saved in .hg/last-message.txt
@@ -272,6 +292,17 @@
 then, test custom commit message itself
 
   $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e
+  ==== before editing
+  Added tag custom-tag for changeset 75a534207be6
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'tag-and-branch-same-name'
+  HG: changed .hgtags
+  ====
   $ hg log -l1 --template "{desc}\n"
   custom tag message
   second line


More information about the Mercurial-devel mailing list