Patchwork chistedit: use context manager to set verbose ui

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date April 16, 2019, 5:13 p.m.
Message ID <f64bbdc70aaa1ca8c504.1555434825@chloe>
Download mbox | patch
Permalink /patch/39657/
State Accepted
Headers show

Comments

Jordi Gutiérrez Hermoso - April 16, 2019, 5:13 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@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.
Yuya Nishihara - April 17, 2019, 10:56 p.m.
On Tue, 16 Apr 2019 13:13:45 -0400, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@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

Queued, thanks.

> I'm still not exactly sure why this is necessary -- perhaps setting it
> unconditionally would leak this setting in chg invocations.

No in chg, but that could theoretically happen in a single-process
commandserver.

Patch

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