Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHG64ed405dd342: commit: respect --no-edit in combination with --amend
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
pulkit |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/cmdutil.py (12 lines) | |||
M | tests/test-commit-amend.t (10 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
543ce40dda94 | 71663b51586b | Kyle Lippincott | May 30 2019, 4:57 PM |
except KeyError: | except KeyError: | ||||
return None | return None | ||||
# See if we got a message from -m or -l, if not, open the editor with | # See if we got a message from -m or -l, if not, open the editor with | ||||
# the message of the changeset to amend. | # the message of the changeset to amend. | ||||
message = logmessage(ui, opts) | message = logmessage(ui, opts) | ||||
editform = mergeeditform(old, 'commit.amend') | editform = mergeeditform(old, 'commit.amend') | ||||
editor = getcommiteditor(editform=editform, | |||||
**pycompat.strkwargs(opts)) | |||||
if not message: | if not message: | ||||
editor = getcommiteditor(edit=True, editform=editform) | |||||
message = old.description() | message = old.description() | ||||
# Default if message isn't provided and --edit is not passed is to | |||||
# invoke editor, but allow --no-edit. If somehow we don't have any | |||||
# description, let's always start the editor. | |||||
doedit = not message or opts.get('edit') in [True, None] | |||||
else: | |||||
# Default if message is provided is to not invoke editor, but allow | |||||
# --edit. | |||||
doedit = opts.get('edit') is True | |||||
editor = getcommiteditor(edit=doedit, editform=editform) | |||||
pureextra = extra.copy() | pureextra = extra.copy() | ||||
extra['amend_source'] = old.hex() | extra['amend_source'] = old.hex() | ||||
new = context.memctx(repo, | new = context.memctx(repo, | ||||
parents=[base.node(), old.p2().node()], | parents=[base.node(), old.p2().node()], | ||||
text=message, | text=message, | ||||
files=files, | files=files, |
before anything happens | before anything happens | ||||
$ HGEDITOR=cat hg commit --amend --no-edit -m "editor should be suppressed" | $ HGEDITOR=cat hg commit --amend --no-edit -m "editor should be suppressed" | ||||
$ hg parents --template "{desc}\n" | $ hg parents --template "{desc}\n" | ||||
editor should be suppressed | editor should be suppressed | ||||
(We need a file change here since we won't have a message change) | (We need a file change here since we won't have a message change) | ||||
$ cp foo foo.orig | $ cp foo foo.orig | ||||
$ echo hi >> foo | $ echo hi >> foo | ||||
FIXME: This shouldn't start the editor. | |||||
$ HGEDITOR=cat hg commit --amend --no-edit | $ HGEDITOR=cat hg commit --amend --no-edit | ||||
editor should be suppressed | |||||
HG: Enter commit message. Lines beginning with 'HG:' are removed. | |||||
HG: Leave message empty to abort commit. | |||||
HG: -- | |||||
HG: user: test | |||||
HG: branch 'silliness' | |||||
HG: added foo | |||||
$ hg parents --template "{desc}\n" | $ hg parents --template "{desc}\n" | ||||
editor should be suppressed | editor should be suppressed | ||||
$ hg status -mar | $ hg status -mar | ||||
(Let's undo adding that "hi" so later tests don't need to be adjusted) | (Let's undo adding that "hi" so later tests don't need to be adjusted) | ||||
$ mv foo.orig foo | $ mv foo.orig foo | ||||
$ hg commit --amend --no-edit | $ hg commit --amend --no-edit | ||||
Test that "diff()" in committemplate works correctly for amending | Test that "diff()" in committemplate works correctly for amending |