Patchwork [3,of,8] import: get rid of ui.backupconfig

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

Comments

Jun Wu - March 16, 2017, 9:56 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1489699429 25200
#      Thu Mar 16 14:23:49 2017 -0700
# Node ID 01931210cd8d62aa56447843c096ea57bdf03889
# Parent  7b575fd8a7a1e9a96cd79352351d87ac69479270
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 01931210cd8d
import: get rid of ui.backupconfig

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -972,11 +972,11 @@  def tryimportone(ui, repo, hunk, parents
                 else:
                     editor = getcommiteditor(editform=editform, **opts)
-                allowemptyback = repo.ui.backupconfig('ui', 'allowemptycommit')
                 extra = {}
                 for idfunc in extrapreimport:
                     extrapreimportmap[idfunc](repo, extractdata, extra, opts)
-                try:
-                    if partial:
-                        repo.ui.setconfig('ui', 'allowemptycommit', True)
+                override = {}
+                if partial:
+                    override[('ui', 'allowemptycommit')] = True
+                with repo.ui.configoverride(override, 'import'):
                     n = repo.commit(message, user,
                                     date, match=m,
@@ -984,6 +984,4 @@  def tryimportone(ui, repo, hunk, parents
                     for idfunc in extrapostimport:
                         extrapostimportmap[idfunc](repo[n])
-                finally:
-                    repo.ui.restoreconfig(allowemptyback)
         else:
             if opts.get('exact') or importbranch: