record: get rid of ui.backupconfig
authorJun Wu <quark@fb.com>
Thu, 16 Mar 2017 14:34:35 -0700
changeset 31458 2017b5a5685b
parent 31457 707f9fd2dcad
child 31459 f84fbd27b6d3
record: get rid of ui.backupconfig
hgext/record.py
--- a/hgext/record.py	Thu Mar 16 14:23:49 2017 -0700
+++ b/hgext/record.py	Thu Mar 16 14:34:35 2017 -0700
@@ -68,12 +68,9 @@
                          'commit')
 
     opts["interactive"] = True
-    backup = ui.backupconfig('experimental', 'crecord')
-    try:
-        ui.setconfig('experimental', 'crecord', False, 'record')
+    overrides = {('experimental', 'crecord'): False}
+    with ui.configoverride(overrides, 'record'):
         return commands.commit(ui, repo, *pats, **opts)
-    finally:
-        ui.restoreconfig(backup)
 
 def qrefresh(origfn, ui, repo, *pats, **opts):
     if not opts['interactive']:
@@ -117,13 +114,10 @@
         opts['checkname'] = False
         mq.new(ui, repo, patch, *pats, **opts)
 
-    backup = ui.backupconfig('experimental', 'crecord')
-    try:
-        ui.setconfig('experimental', 'crecord', False, 'record')
+    overrides = {('experimental', 'crecord'): False}
+    with ui.configoverride(overrides, 'record'):
         cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False,
                          cmdutil.recordfilter, *pats, **opts)
-    finally:
-        ui.restoreconfig(backup)
 
 def qnew(origfn, ui, repo, patch, *args, **opts):
     if opts['interactive']: