Patchwork D3740: resolve: use context manager for config override

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

Comments

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3740?vs=9069&id=9084

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

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
@@ -4553,15 +4553,14 @@ 
 
                 try:
                     # preresolve file
-                    ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
-                                 'resolve')
-                    complete, r = ms.preresolve(f, wctx)
+                    overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
+                    with ui.configoverride(overrides, 'resolve'):
+                        complete, r = ms.preresolve(f, wctx)
                     if not complete:
                         tocomplete.append(f)
                     elif r:
                         ret = 1
                 finally:
-                    ui.setconfig('ui', 'forcemerge', '', 'resolve')
                     ms.commit()
 
                 # replace filemerge's .orig file with our resolve file, but only
@@ -4577,13 +4576,12 @@ 
         for f in tocomplete:
             try:
                 # resolve file
-                ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
-                             'resolve')
-                r = ms.resolve(f, wctx)
+                overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
+                with ui.configoverride(overrides, 'resolve'):
+                    r = ms.resolve(f, wctx)
                 if r:
                     ret = 1
             finally:
-                ui.setconfig('ui', 'forcemerge', '', 'resolve')
                 ms.commit()
 
             # replace filemerge's .orig file with our resolve file