chistedit: use context manager to set verbose ui
authorJordi Gutiérrez Hermoso <jordigh@octave.org>
Tue, 16 Apr 2019 13:12:21 -0400
changeset 42160 9e40c5892714
parent 42159 4f9a89837f07
child 42161 7815cf0ea88b
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.
hgext/histedit.py
--- a/hgext/histedit.py	Tue Apr 16 17:26:38 2019 +0200
+++ b/hgext/histedit.py	Tue Apr 16 13:12:21 2019 -0400
@@ -1230,12 +1230,13 @@
 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):