changeset 38324:79dcaad9d145

graft: use context manager for config override Differential Revision: https://phab.mercurial-scm.org/D3738
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 14 Jun 2018 15:45:16 -0700
parents 565074cc9ac6
children 7e34fc78701a
files mercurial/commands.py
diffstat 1 files changed, 3 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Jun 14 11:49:10 2018 -0400
+++ b/mercurial/commands.py	Thu Jun 14 15:45:16 2018 -0700
@@ -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