mq: get rid of ui.backupconfig
authorJun Wu <quark@fb.com>
Thu, 16 Mar 2017 14:39:18 -0700
changeset 31469 03d99d08147b
parent 31468 f84fbd27b6d3
child 31470 f255b1811f5e
mq: get rid of ui.backupconfig
hgext/mq.py
--- a/hgext/mq.py	Thu Mar 16 14:36:35 2017 -0700
+++ b/hgext/mq.py	Thu Mar 16 14:39:18 2017 -0700
@@ -405,18 +405,12 @@
     if phase is None:
         if repo.ui.configbool('mq', 'secret', False):
             phase = phases.secret
+    overrides = {('ui', 'allowemptycommit'): True}
     if phase is not None:
-        phasebackup = repo.ui.backupconfig('phases', 'new-commit')
-    allowemptybackup = repo.ui.backupconfig('ui', 'allowemptycommit')
-    try:
-        if phase is not None:
-            repo.ui.setconfig('phases', 'new-commit', phase, 'mq')
+        overrides[('phases', 'new-commit')] = phase
+    with repo.ui.configoverride(overrides, 'mq'):
         repo.ui.setconfig('ui', 'allowemptycommit', True)
         return repo.commit(*args, **kwargs)
-    finally:
-        repo.ui.restoreconfig(allowemptybackup)
-        if phase is not None:
-            repo.ui.restoreconfig(phasebackup)
 
 class AbortNoCleanup(error.Abort):
     pass