[PATCH 5 of 8] histedit: get rid of ui.backupconfig
Jun Wu
quark at fb.com
Thu Mar 16 17:57:00 EDT 2017
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1489700195 25200
# Thu Mar 16 14:36:35 2017 -0700
# Node ID 93772a7ad2c443b7c92d0d23e85405f5b0d1a800
# Parent 4ff0515eaa03cf3fdd2b19a3444eb9c2cebdbcea
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 93772a7ad2c4
histedit: get rid of ui.backupconfig
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -503,14 +503,10 @@ def commitfuncfor(repo, src):
phasemin = src.phase()
def commitfunc(**kwargs):
- phasebackup = repo.ui.backupconfig('phases', 'new-commit')
- try:
- repo.ui.setconfig('phases', 'new-commit', phasemin,
- 'histedit')
+ override = {('phases', 'new-commit'): phasemin}
+ with repo.ui.configoverride(override, 'histedit'):
extra = kwargs.get('extra', {}).copy()
extra['histedit_source'] = src.hex()
kwargs['extra'] = extra
return repo.commit(**kwargs)
- finally:
- repo.ui.restoreconfig(phasebackup)
return commitfunc
@@ -763,12 +759,9 @@ class fold(histeditaction):
extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex())
commitopts['extra'] = extra
- phasebackup = repo.ui.backupconfig('phases', 'new-commit')
- try:
- phasemin = max(ctx.phase(), oldctx.phase())
- repo.ui.setconfig('phases', 'new-commit', phasemin, 'histedit')
+ phasemin = max(ctx.phase(), oldctx.phase())
+ override = {('phases', 'new-commit'): phasemin}
+ with repo.ui.configoverride(override, 'histedit'):
n = collapse(repo, ctx, repo[newnode], commitopts,
skipprompt=self.skipprompt())
- finally:
- repo.ui.restoreconfig(phasebackup)
if n is None:
return ctx, []
More information about the Mercurial-devel
mailing list