##// END OF EJS Templates
amend: invoke editor forcibly when "--edit" option is specified...
FUJIWARA Katsunori -
r21036:a1a1bd09 default
parent child Browse files
Show More
@@ -1948,6 +1948,8 b' def amend(ui, repo, commitfunc, old, ext'
1948 if not message:
1948 if not message:
1949 editmsg = True
1949 editmsg = True
1950 message = old.description()
1950 message = old.description()
1951 elif opts.get('edit'):
1952 editmsg = True
1951
1953
1952 pureextra = extra.copy()
1954 pureextra = extra.copy()
1953 extra['amend_source'] = old.hex()
1955 extra['amend_source'] = old.hex()
@@ -1403,23 +1403,12 b' def commit(ui, repo, *pats, **opts):'
1403 if (not obsolete._enabled) and old.children():
1403 if (not obsolete._enabled) and old.children():
1404 raise util.Abort(_('cannot amend changeset with children'))
1404 raise util.Abort(_('cannot amend changeset with children'))
1405
1405
1406 e = cmdutil.commiteditor
1407 if forceeditor:
1408 e = cmdutil.commitforceeditor
1409
1410 # commitfunc is used only for temporary amend commit by cmdutil.amend
1406 # commitfunc is used only for temporary amend commit by cmdutil.amend
1411 def commitfunc(ui, repo, message, match, opts):
1407 def commitfunc(ui, repo, message, match, opts):
1412 editor = e
1413 # message contains text from -m or -l, if it's empty,
1414 # open the editor with the old message
1415 if not message:
1416 message = old.description()
1417 editor = cmdutil.commitforceeditor
1418 return repo.commit(message,
1408 return repo.commit(message,
1419 opts.get('user') or old.user(),
1409 opts.get('user') or old.user(),
1420 opts.get('date') or old.date(),
1410 opts.get('date') or old.date(),
1421 match,
1411 match,
1422 editor=editor,
1423 extra=extra)
1412 extra=extra)
1424
1413
1425 current = repo._bookmarkcurrent
1414 current = repo._bookmarkcurrent
@@ -827,3 +827,25 b' Test that amend with --secret creates ne'
827 $ hg phase '.^::.'
827 $ hg phase '.^::.'
828 35: draft
828 35: draft
829 38: secret
829 38: secret
830
831 Test that amend with --edit invokes editor forcibly
832 ---------------------------------------------------
833
834 $ hg parents --template "{desc}\n"
835 amend as secret
836 $ HGEDITOR=cat hg commit --amend -m "editor should be suppressed"
837 $ hg parents --template "{desc}\n"
838 editor should be suppressed
839
840 $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit
841 editor should be invoked
842
843
844 HG: Enter commit message. Lines beginning with 'HG:' are removed.
845 HG: Leave message empty to abort commit.
846 HG: --
847 HG: user: test
848 HG: branch 'silliness'
849 HG: changed obs.py
850 $ hg parents --template "{desc}\n"
851 editor should be invoked
General Comments 0
You need to be logged in to leave comments. Login now