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

login
register
mail settings
Submitter Jun Wu
Date March 16, 2017, 9:56 p.m.
Message ID <4ff0515eaa03cf3fdd2b.1489701419@localhost.localdomain>
Download mbox | patch
Permalink /patch/19406/
State Accepted
Headers show

Comments

Jun Wu - March 16, 2017, 9:56 p.m.
# HG changeset patch
# User Jun Wu <quark@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

Patch

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):