mercurial/debugcommands.py
changeset 47437 7a430116f639
parent 47351 3b9914b28133
child 47438 1be9bf3669cb
--- a/mercurial/debugcommands.py	Fri Jun 18 14:17:43 2021 -0700
+++ b/mercurial/debugcommands.py	Fri Jun 18 15:48:51 2021 -0700
@@ -2754,9 +2754,9 @@
         changedelete = opts[b'changedelete']
         for path in ctx.walk(m):
             fctx = ctx[path]
-            try:
-                if not ui.debugflag:
-                    ui.pushbuffer(error=True)
+            with ui.silent(
+                error=True
+            ) if not ui.debugflag else util.nullcontextmanager():
                 tool, toolpath = filemerge._picktool(
                     repo,
                     ui,
@@ -2765,9 +2765,6 @@
                     b'l' in fctx.flags(),
                     changedelete,
                 )
-            finally:
-                if not ui.debugflag:
-                    ui.popbuffer()
             ui.write(b'%s = %s\n' % (path, tool))
 
 
@@ -4580,17 +4577,16 @@
             ui.write(_(b'creating http peer for wire protocol version 2\n'))
             # We go through makepeer() because we need an API descriptor for
             # the peer instance to be useful.
-            with ui.configoverride(
+            maybe_silent = (
+                ui.silent()
+                if opts[b'nologhandshake']
+                else util.nullcontextmanager()
+            )
+            with maybe_silent, ui.configoverride(
                 {(b'experimental', b'httppeer.advertise-v2'): True}
             ):
-                if opts[b'nologhandshake']:
-                    ui.pushbuffer()
-
                 peer = httppeer.makepeer(ui, path, opener=opener)
 
-                if opts[b'nologhandshake']:
-                    ui.popbuffer()
-
             if not isinstance(peer, httppeer.httpv2peer):
                 raise error.Abort(
                     _(