Patchwork D3738: graft: use context manager for config override

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3738?vs=9067&id=9082

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

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
@@ -2358,14 +2358,9 @@ 
         # we don't merge the first commit when continuing
         if not cont:
             # perform the graft merge with p1(rev) as 'ancestor'
-            try:
-                # ui.forcemerge is an internal variable, do not document
-                repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
-                                  'graft')
-                stats = mergemod.graft(repo, ctx, ctx.p1(),
-                                       ['local', 'graft'])
-            finally:
-                repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
+            overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
+            with ui.configoverride(overrides, 'graft'):
+                stats = mergemod.graft(repo, ctx, ctx.p1(), ['local', 'graft'])
             # report any conflicts
             if stats.unresolvedcount > 0:
                 # write out state for --continue