Mercurial > hg-stable
changeset 31471:d1ce2124ec83
shelve: get rid of ui.backupconfig
author | Jun Wu <quark@fb.com> |
---|---|
date | Thu, 16 Mar 2017 14:27:41 -0700 |
parents | f255b1811f5e |
children | 55df8fa15b09 |
files | hgext/shelve.py |
diffstat | 1 files changed, 24 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/shelve.py Thu Mar 16 14:40:34 2017 -0700 +++ b/hgext/shelve.py Thu Mar 16 14:27:41 2017 -0700 @@ -314,17 +314,16 @@ hasmq = util.safehasattr(repo, 'mq') if hasmq: saved, repo.mq.checkapplied = repo.mq.checkapplied, False - backup = repo.ui.backupconfig('phases', 'new-commit') + overrides = {('phases', 'new-commit'): phases.secret} try: - repo.ui.setconfig('phases', 'new-commit', phases.secret) editor_ = False if editor: editor_ = cmdutil.getcommiteditor(editform='shelve.shelve', **opts) - return repo.commit(message, shelveuser, opts.get('date'), match, - editor=editor_, extra=extra) + with repo.ui.configoverride(overrides): + return repo.commit(message, shelveuser, opts.get('date'), + match, editor=editor_, extra=extra) finally: - repo.ui.restoreconfig(backup) if hasmq: repo.mq.checkapplied = saved @@ -850,9 +849,7 @@ oldquiet = ui.quiet lock = tr = None - forcemerge = ui.backupconfig('ui', 'forcemerge') try: - ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'unshelve') lock = repo.lock() tr = repo.transaction('unshelve', report=lambda x: None) @@ -866,31 +863,33 @@ # and shelvectx is the unshelved changes. Then we merge it all down # to the original pctx. - tmpwctx, addedbefore = _commitworkingcopychanges(ui, repo, opts, - tmpwctx) - - repo, shelvectx = _unshelverestorecommit(ui, repo, basename, oldquiet) - _checkunshelveuntrackedproblems(ui, repo, shelvectx) - branchtorestore = '' - if shelvectx.branch() != shelvectx.p1().branch(): - branchtorestore = shelvectx.branch() + overrides = {('ui', 'forcemerge'): opts.get('tool', '')} + with ui.configoverride(overrides, 'unshelve'): + tmpwctx, addedbefore = _commitworkingcopychanges(ui, repo, opts, + tmpwctx) - shelvectx = _rebaserestoredcommit(ui, repo, opts, tr, oldtiprev, - basename, pctx, tmpwctx, shelvectx, - branchtorestore) - mergefiles(ui, repo, pctx, shelvectx) - restorebranch(ui, repo, branchtorestore) - _forgetunknownfiles(repo, shelvectx, addedbefore) + repo, shelvectx = _unshelverestorecommit(ui, repo, basename, + oldquiet) + _checkunshelveuntrackedproblems(ui, repo, shelvectx) + branchtorestore = '' + if shelvectx.branch() != shelvectx.p1().branch(): + branchtorestore = shelvectx.branch() - shelvedstate.clear(repo) - _finishunshelve(repo, oldtiprev, tr) - unshelvecleanup(ui, repo, basename, opts) + shelvectx = _rebaserestoredcommit(ui, repo, opts, tr, oldtiprev, + basename, pctx, tmpwctx, + shelvectx, branchtorestore) + mergefiles(ui, repo, pctx, shelvectx) + restorebranch(ui, repo, branchtorestore) + _forgetunknownfiles(repo, shelvectx, addedbefore) + + shelvedstate.clear(repo) + _finishunshelve(repo, oldtiprev, tr) + unshelvecleanup(ui, repo, basename, opts) finally: ui.quiet = oldquiet if tr: tr.release() lockmod.release(lock) - ui.restoreconfig(forcemerge) @command('shelve', [('A', 'addremove', None,