[PATCH 02 of 19] fetch: use "getcommiteditor()" instead of explicit editor choice

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


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1399736975 -32400
#      Sun May 11 00:49:35 2014 +0900
# Node ID 717664fb5de2eda1c566c9b14844721ae878ddee
# Parent  b482c1575fdf145f03285a6a846b7f07a753b8a2
fetch: use "getcommiteditor()" instead of explicit editor choice

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

diff --git a/hgext/fetch.py b/hgext/fetch.py
--- a/hgext/fetch.py
+++ b/hgext/fetch.py
@@ -142,10 +142,9 @@
             message = (cmdutil.logmessage(ui, opts) or
                        ('Automated merge with %s' %
                         util.removeauth(other.url())))
-            editor = cmdutil.commiteditor
-            if opts.get('force_editor') or opts.get('edit'):
-                editor = cmdutil.commitforceeditor
-            n = repo.commit(message, opts['user'], opts['date'], editor=editor)
+            editopt = opts.get('edit') or opts.get('force_editor')
+            n = repo.commit(message, opts['user'], opts['date'],
+                            editor=cmdutil.getcommiteditor(edit=editopt))
             ui.status(_('new changeset %d:%s merges remote changes '
                         'with local\n') % (repo.changelog.rev(n),
                                            short(n)))
diff --git a/tests/test-fetch.t b/tests/test-fetch.t
--- a/tests/test-fetch.t
+++ b/tests/test-fetch.t
@@ -68,8 +68,9 @@
   $ cat a/hg.pid >> "$DAEMON_PIDS"
 
 fetch over http, no auth
-
-  $ hg --cwd d fetch http://localhost:$HGPORT/
+(this also tests that editor is invoked if '--edit' is specified)
+
+  $ HGEDITOR=cat hg --cwd d fetch --edit http://localhost:$HGPORT/
   pulling from http://localhost:$HGPORT/
   searching for changes
   adding changesets
@@ -80,13 +81,29 @@
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   merging with 1:d36c0562f908
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  Automated merge with http://localhost:$HGPORT/
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch merge
+  HG: branch 'default'
+  HG: changed c
   new changeset 3:* merges remote changes with local (glob)
   $ hg --cwd d tip --template '{desc}\n'
   Automated merge with http://localhost:$HGPORT/
+  $ hg --cwd d status --rev 'tip^1' --rev tip
+  A c
+  $ hg --cwd d status --rev 'tip^2' --rev tip
+  A b
 
 fetch over http with auth (should be hidden in desc)
-
-  $ hg --cwd e fetch http://user:password@localhost:$HGPORT/
+(this also tests that editor is not invoked if '--edit' is not
+specified, even though commit message is not specified explicitly)
+
+  $ HGEDITOR=cat hg --cwd e fetch http://user:password@localhost:$HGPORT/
   pulling from http://user:***@localhost:$HGPORT/
   searching for changes
   adding changesets


More information about the Mercurial-devel mailing list