Patchwork D3739: merge: use context manager for config override

login
register
mail settings
Submitter phabricator
Date June 15, 2018, 12:48 p.m.
Message ID <7a33dd577260db842896b8f13be86228@localhost.localdomain>
Download mbox | patch
Permalink /patch/32167/
State Not Applicable
Headers show

Comments

phabricator - June 15, 2018, 12:48 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG7e34fc78701a: merge: use context manager for config override (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3739?vs=9068&id=9083

REVISION DETAIL
  https://phab.mercurial-scm.org/D3739

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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')),