Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 20700:b0153cb8b64e stable
commit: create new amend changeset as secret correctly for "--secret" option
Before this patch, "hg commit --amend --secret" doesn't create new
amend changeset as secret, even though the internal function
"commitfunc()" passed to "cmdutil.amend()" make "phases.new-commit"
configuration as "secret" temporarily.
"cmdutil.amend()" uses specified "commitfunc" only for temporary amend
commit, and creates the final amend commit changeset by
"localrepository.commitctx()" directly with memctx.
This patch creates new amend changeset as secret correctly for
"--secret" option, by changing "phases.new-commit" configuration
temporarily before "localrepository.commitctx()".
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Thu, 13 Mar 2014 19:48:41 +0900 |
parents | 2d183dd54384 |
children | 2764148aa088 bcfc4f625e57 |
comparison
equal
deleted
inserted
replaced
20699:58c32a9c8e7b | 20700:b0153cb8b64e |
---|---|
1395 | 1395 |
1396 e = cmdutil.commiteditor | 1396 e = cmdutil.commiteditor |
1397 if opts.get('force_editor'): | 1397 if opts.get('force_editor'): |
1398 e = cmdutil.commitforceeditor | 1398 e = cmdutil.commitforceeditor |
1399 | 1399 |
1400 # commitfunc is used only for temporary amend commit by cmdutil.amend | |
1400 def commitfunc(ui, repo, message, match, opts): | 1401 def commitfunc(ui, repo, message, match, opts): |
1401 editor = e | 1402 editor = e |
1402 # message contains text from -m or -l, if it's empty, | 1403 # message contains text from -m or -l, if it's empty, |
1403 # open the editor with the old message | 1404 # open the editor with the old message |
1404 if not message: | 1405 if not message: |
1405 message = old.description() | 1406 message = old.description() |
1406 editor = cmdutil.commitforceeditor | 1407 editor = cmdutil.commitforceeditor |
1407 try: | 1408 return repo.commit(message, |
1408 if opts.get('secret'): | 1409 opts.get('user') or old.user(), |
1409 ui.setconfig('phases', 'new-commit', 'secret') | 1410 opts.get('date') or old.date(), |
1410 | 1411 match, |
1411 return repo.commit(message, | 1412 editor=editor, |
1412 opts.get('user') or old.user(), | 1413 extra=extra) |
1413 opts.get('date') or old.date(), | |
1414 match, | |
1415 editor=editor, | |
1416 extra=extra) | |
1417 finally: | |
1418 ui.setconfig('phases', 'new-commit', oldcommitphase) | |
1419 | 1414 |
1420 current = repo._bookmarkcurrent | 1415 current = repo._bookmarkcurrent |
1421 marks = old.bookmarks() | 1416 marks = old.bookmarks() |
1422 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts) | 1417 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts) |
1423 if node == old.node(): | 1418 if node == old.node(): |