# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 2021-06-18 23:00:58
# Node ID 1be9bf3669cb9052885d760a7c4b03d8fc3c164e
# Parent  7a430116f6396332ffb0ec41cc00471635156136

debugbackupbundle: use new context manager for silencing the ui

A difference between setting `ui.quiet` and using `ui.silent()` is
that the latter also silences `ui.write()` calls. That's practically
always what one wants, including here, I think.

Differential Revision: https://phab.mercurial-scm.org/D10885

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -3791,16 +3791,13 @@ def debugbackupbundle(ui, repo, *pats, *
         if revs:
             revs = [other.lookup(rev) for rev in revs]
 
-        quiet = ui.quiet
-        try:
-            ui.quiet = True
-            other, chlist, cleanupfn = bundlerepo.getremotechanges(
-                ui, repo, other, revs, opts[b"bundle"], opts[b"force"]
-            )
-        except error.LookupError:
-            continue
-        finally:
-            ui.quiet = quiet
+        with ui.silent():
+            try:
+                other, chlist, cleanupfn = bundlerepo.getremotechanges(
+                    ui, repo, other, revs, opts[b"bundle"], opts[b"force"]
+                )
+            except error.LookupError:
+                continue
 
         try:
             if not chlist: