[PATCH] chistedit: use context manager to set verbose ui

Jordi GutiƩrrez Hermoso jordigh at octave.org
Tue Apr 16 13:13:45 EDT 2019

# HG changeset patch
# User Jordi GutiƩrrez Hermoso <jordigh at octave.org>
# Date 1555434741 14400
#      Tue Apr 16 13:12:21 2019 -0400
# Node ID f64bbdc70aaa1ca8c504c2d909f6012927a27cb8
# Parent  a362b0b95e42c8f7d46d7e3a0eb4cc531fa5f2d6
chistedit: use context manager to set verbose ui

I'm still not exactly sure why this is necessary -- perhaps setting it
unconditionally would leak this setting in chg invocations.
Regardless, this would have looked very out of place as compared to
how this setting is done everywhere else, so at least for the sake of
style, let's be consistent with the rest of the codebase.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1230,12 +1230,13 @@ def addln(win, y, x, line, color=None):
 def patchcontents(state):
     repo = state['repo']
     rule = state['rules'][state['pos']]
-    repo.ui.verbose = True
     displayer = logcmdutil.changesetdisplayer(repo.ui, repo, {
         "patch": True,  "template": "status"
     }, buffered=True)
-    displayer.show(rule.ctx)
-    displayer.close()
+    overrides = {('ui',  'verbose'): True}
+    with repo.ui.configoverride(overrides, source='histedit'):
+        displayer.show(rule.ctx)
+        displayer.close()
     return displayer.hunk[rule.ctx.rev()].splitlines()
 def _chisteditmain(repo, rules, stdscr):

More information about the Mercurial-devel mailing list