[PATCH 07 of 19] transplant: use "getcommiteditor()" instead of explicit editor choice
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Sat May 10 16:08:42 UTC 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 2bd458f23c2d86e82555d7868918d4a349a04c18
# Parent 611e742f78c712701f6ba6c98d99f7c0c92dabf9
transplant: use "getcommiteditor()" instead of explicit editor choice
This patch also enhances "test-transplant.t", because "hg transplant"
hasn't been explicitly tested around editor invocation and "--edit"
option.
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -80,13 +80,13 @@
self.dirty = True
class transplanter(object):
- def __init__(self, ui, repo):
+ def __init__(self, ui, repo, opts):
self.ui = ui
self.path = repo.join('transplant')
self.opener = scmutil.opener(self.path)
self.transplants = transplants(self.path, 'transplants',
opener=self.opener)
- self.editor = None
+ self.editor = cmdutil.getcommiteditor(**opts)
def applied(self, repo, node, parent):
'''returns True if a node is already an ancestor of parent
@@ -599,9 +599,7 @@
if not opts.get('filter'):
opts['filter'] = ui.config('transplant', 'filter')
- tp = transplanter(ui, repo)
- if opts.get('edit'):
- tp.editor = cmdutil.commitforceeditor
+ tp = transplanter(ui, repo, opts)
cmdutil.checkunfinished(repo)
p1, p2 = repo.dirstate.parents()
diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -43,8 +43,9 @@
1 files updated, 0 files merged, 3 files removed, 0 files unresolved
rebase b onto r1
-
- $ hg transplant -a -b tip
+(this also tests that editor is not invoked if '--edit' is not specified)
+
+ $ HGEDITOR=cat hg transplant -a -b tip
applying 37a1297eb21b
37a1297eb21b transplanted to e234d668f844
applying 722f4667af76
@@ -85,13 +86,26 @@
test destination() revset predicate with a transplant of a transplant; new
clone so subsequent rollback isn't affected
+(this also tests that editor is invoked if '--edit' is specified)
+
$ hg clone -q . ../destination
$ cd ../destination
$ hg up -Cq 0
$ hg branch -q b4
$ hg ci -qm "b4"
- $ hg transplant 7
+ $ hg status --rev "7^1" --rev 7
+ A b3
+ $ HGEDITOR=cat hg transplant --edit 7
applying ffd6818a3975
+ b3
+
+
+ HG: Enter commit message. Lines beginning with 'HG:' are removed.
+ HG: Leave message empty to abort commit.
+ HG: --
+ HG: user: test
+ HG: branch 'b4'
+ HG: added b3
ffd6818a3975 transplanted to 502236fa76bb
More information about the Mercurial-devel
mailing list