comparison mercurial/cmdutil.py @ 34098:5dc6ac6555e6

amend: use context manager for config override Differential Revision: https://phab.mercurial-scm.org/D639
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 06 Sep 2017 10:41:13 -0700
parents 4059b10d7490
children 08346a8fa65f
comparison
equal deleted inserted replaced
34097:4059b10d7490 34098:5dc6ac6555e6
33 graphmod, 33 graphmod,
34 match as matchmod, 34 match as matchmod,
35 obsolete, 35 obsolete,
36 patch, 36 patch,
37 pathutil, 37 pathutil,
38 phases,
39 pycompat, 38 pycompat,
40 registrar, 39 registrar,
41 revlog, 40 revlog,
42 revset, 41 revset,
43 scmutil, 42 scmutil,
3160 # anyway because of the amend_source noise. 3159 # anyway because of the amend_source noise.
3161 # 3160 #
3162 # This not what we expect from amend. 3161 # This not what we expect from amend.
3163 return old.node() 3162 return old.node()
3164 3163
3165 ph = repo.ui.config('phases', 'new-commit', phases.draft) 3164 if opts.get('secret'):
3166 try: 3165 commitphase = 'secret'
3167 if opts.get('secret'): 3166 else:
3168 commitphase = 'secret' 3167 commitphase = old.phase()
3169 else: 3168 overrides = {('phases', 'new-commit'): commitphase}
3170 commitphase = old.phase() 3169 with ui.configoverride(overrides, 'amend'):
3171 repo.ui.setconfig('phases', 'new-commit', commitphase, 'amend')
3172 newid = repo.commitctx(new) 3170 newid = repo.commitctx(new)
3173 finally:
3174 repo.ui.setconfig('phases', 'new-commit', ph, 'amend')
3175 3171
3176 # Reroute the working copy parent to the new changeset 3172 # Reroute the working copy parent to the new changeset
3177 repo.setparents(newid, nullid) 3173 repo.setparents(newid, nullid)
3178 mapping = {old.node(): (newid,)} 3174 mapping = {old.node(): (newid,)}
3179 if node: 3175 if node: