rebase: use configoverride context manager for ui.forcemerge
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 09 Mar 2018 12:48:00 -0800
changeset 36930 36de8a3c429c
parent 36929 cc2bfc7d5362
child 36931 28f988093911
rebase: use configoverride context manager for ui.forcemerge Differential Revision: https://phab.mercurial-scm.org/D2761
hgext/rebase.py
--- a/hgext/rebase.py	Fri Mar 09 12:45:50 2018 -0800
+++ b/hgext/rebase.py	Fri Mar 09 12:48:00 2018 -0800
@@ -481,9 +481,8 @@
                 if len(repo[None].parents()) == 2:
                     repo.ui.debug('resuming interrupted rebase\n')
                 else:
-                    try:
-                        ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
-                                     'rebase')
+                    overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
+                    with ui.configoverride(overrides, 'rebase'):
                         stats = rebasenode(repo, rev, p1, base, self.collapsef,
                                            dest, wctx=self.wctx)
                         if stats and stats[3] > 0:
@@ -493,8 +492,6 @@
                                 raise error.InterventionRequired(
                                     _('unresolved conflicts (see hg '
                                       'resolve, then hg rebase --continue)'))
-                    finally:
-                        ui.setconfig('ui', 'forcemerge', '', 'rebase')
                 if not self.collapsef:
                     merging = p2 != nullrev
                     editform = cmdutil.mergeeditform(merging, 'rebase')