[PATCH 4 of 8] record: get rid of ui.backupconfig

Jun Wu quark at fb.com
Thu Mar 16 17:56:59 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1489700075 25200
#      Thu Mar 16 14:34:35 2017 -0700
# Node ID 4ff0515eaa03cf3fdd2b19a3444eb9c2cebdbcea
# Parent  01931210cd8d62aa56447843c096ea57bdf03889
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 4ff0515eaa03
record: get rid of ui.backupconfig

diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -69,10 +69,7 @@ def record(ui, repo, *pats, **opts):
 
     opts["interactive"] = True
-    backup = ui.backupconfig('experimental', 'crecord')
-    try:
-        ui.setconfig('experimental', 'crecord', False, 'record')
+    override = {('experimental', 'crecord'): False}
+    with ui.configoverride(override, 'record'):
         return commands.commit(ui, repo, *pats, **opts)
-    finally:
-        ui.restoreconfig(backup)
 
 def qrefresh(origfn, ui, repo, *pats, **opts):
@@ -118,11 +115,8 @@ def _qrecord(cmdsuggest, ui, repo, patch
         mq.new(ui, repo, patch, *pats, **opts)
 
-    backup = ui.backupconfig('experimental', 'crecord')
-    try:
-        ui.setconfig('experimental', 'crecord', False, 'record')
+    override = {('experimental', 'crecord'): False}
+    with ui.configoverride(override, 'record'):
         cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False,
                          cmdutil.recordfilter, *pats, **opts)
-    finally:
-        ui.restoreconfig(backup)
 
 def qnew(origfn, ui, repo, patch, *args, **opts):


More information about the Mercurial-devel mailing list