changeset 38325:7e34fc78701a

merge: use context manager for config override Differential Revision: https://phab.mercurial-scm.org/D3739
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 14 Jun 2018 15:45:45 -0700
parents 79dcaad9d145
children ff9694ea3852
files mercurial/commands.py
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Jun 14 15:45:16 2018 -0700
+++ b/mercurial/commands.py	Thu Jun 14 15:45:45 2018 -0700
@@ -3684,15 +3684,13 @@
         displayer.close()
         return 0
 
-    try:
-        # ui.forcemerge is an internal variable, do not document
-        repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
+    # ui.forcemerge is an internal variable, do not document
+    overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
+    with ui.configoverride(overrides, 'merge'):
         force = opts.get('force')
         labels = ['working copy', 'merge rev']
         return hg.merge(repo, node, force=force, mergeforce=force,
                         labels=labels, abort=abort)
-    finally:
-        ui.setconfig('ui', 'forcemerge', '', 'merge')
 
 @command('outgoing|out',
     [('f', 'force', None, _('run even when the destination is unrelated')),