Patchwork D3742: backout: use context manager for config override

login
register
mail settings
Submitter phabricator
Date June 15, 2018, 12:49 p.m.
Message ID <b9350ae185e622e930beefac4f282f1c@localhost.localdomain>
Download mbox | patch
Permalink /patch/32170/
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 rHG0d6d0aa3c4bf: backout: use context manager for config override (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3742?vs=9071&id=9086

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

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
@@ -619,18 +619,17 @@ 
     if not opts.get('merge') and op1 != node:
         dsguard = dirstateguard.dirstateguard(repo, 'backout')
         try:
-            ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
-                         'backout')
-            stats = mergemod.update(repo, parent, True, True, node, False)
+            overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
+            with ui.configoverride(overrides, 'backout'):
+                stats = mergemod.update(repo, parent, True, True, node, False)
             repo.setparents(op1, op2)
             dsguard.close()
             hg._showstats(repo, stats)
             if stats.unresolvedcount:
                 repo.ui.status(_("use 'hg resolve' to retry unresolved "
                                  "file merges\n"))
                 return 1
         finally:
-            ui.setconfig('ui', 'forcemerge', '', '')
             lockmod.release(dsguard)
     else:
         hg.clean(repo, node, show_stats=False)
@@ -667,12 +666,9 @@ 
         hg.clean(repo, op1, show_stats=False)
         ui.status(_('merging with changeset %s\n')
                   % nice(repo.changelog.tip()))
-        try:
-            ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
-                         'backout')
+        overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
+        with ui.configoverride(overrides, 'backout'):
             return hg.merge(repo, hex(repo.changelog.tip()))
-        finally:
-            ui.setconfig('ui', 'forcemerge', '', '')
     return 0
 
 @command('bisect',