This is an archive of the discontinued Mercurial Phabricator instance.

ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
ClosedPublic

Authored by martinvonz on Jun 18 2021, 7:57 PM.

Details

Summary

We often silence the ui by calling ui.pushbuffer() followed (a later
in the code) by ui.popbuffer(). These places can be identified by
the fact that they ignore the output returned from
ui.popbuffer(). Let's create a context manager for these cases, to
avoid repetition, and to avoid accidentally leaving the ui silent on
exceptions. I deliberately called the new function silent() instead
of buffered(), because it's just an implementation detail that it
uses pushbuffer() and popbuffer(). We could later optimize it to
not buffer the output.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

martinvonz created this revision.Jun 18 2021, 7:57 PM
pulkit accepted this revision.Jun 21 2021, 3:03 AM
This revision is now accepted and ready to land.Jun 21 2021, 3:03 AM

This revision breaks test-check-imports.t, please follow-up.

This revision breaks test-check-imports.t, please follow-up.

Hmm, sorry about that. I noticed that it was failing, but it has been failing since D10513 for me. This is how it fails for me:

--- /usr/local/google/home/martinvonz/hg/tests/test-check-module-imports.t
+++ /usr/local/google/home/martinvonz/hg/tests/test-check-module-imports.t.err
@@ -42,3 +42,10 @@
   > -X tests/test-imports-checker.t \
   > -X tests/test-verify-repo-operations.py \
   > | sed 's-\\-/-g' | "$PYTHON" "$import_checker" -
+  tests/test-convert-bzr.t:117: imports not lexically sorted: breezy.bzr.bzrdir < sys
+  tests/test-convert-bzr.t:117: stdlib import "breezy.bzr.bzrdir" follows local import: breezy
+  tests/test-convert-bzr-ghosts.t:7: imports not lexically sorted: breezy.bzr.bzrdir < sys
+  tests/test-convert-bzr-ghosts.t:7: stdlib import "breezy.bzr.bzrdir" follows local import: breezy
+  tests/test-convert-bzr-treeroot.t:7: imports not lexically sorted: breezy.bzr.bzrdir < sys
+  tests/test-convert-bzr-treeroot.t:7: stdlib import "breezy.bzr.bzrdir" follows local import: breezy
+  [1]

ERROR: test-check-module-imports.t output changed

Does it fail in some other way for you?

Alphare added a comment.EditedJun 22 2021, 4:21 AM

This revision breaks test-check-imports.t, please follow-up.

Hmm, sorry about that. I noticed that it was failing, but it has been failing since D10513 for me. This is how it fails for me:

--- /usr/local/google/home/martinvonz/hg/tests/test-check-module-imports.t
+++ /usr/local/google/home/martinvonz/hg/tests/test-check-module-imports.t.err
@@ -42,3 +42,10 @@
   > -X tests/test-imports-checker.t \
   > -X tests/test-verify-repo-operations.py \
   > | sed 's-\\-/-g' | "$PYTHON" "$import_checker" -
+  tests/test-convert-bzr.t:117: imports not lexically sorted: breezy.bzr.bzrdir < sys
+  tests/test-convert-bzr.t:117: stdlib import "breezy.bzr.bzrdir" follows local import: breezy
+  tests/test-convert-bzr-ghosts.t:7: imports not lexically sorted: breezy.bzr.bzrdir < sys
+  tests/test-convert-bzr-ghosts.t:7: stdlib import "breezy.bzr.bzrdir" follows local import: breezy
+  tests/test-convert-bzr-treeroot.t:7: imports not lexically sorted: breezy.bzr.bzrdir < sys
+  tests/test-convert-bzr-treeroot.t:7: stdlib import "breezy.bzr.bzrdir" follows local import: breezy
+  [1]
ERROR: test-check-module-imports.t output changed

Does it fail in some other way for you?

Sorry, I was thinking about test-check-pyflakes.t, I got mixed up.

However test-check-imports.t does not fail for me either locally or on the CI, that's weird, I'll look at the test a little to see what could be happening.

Don't hesitate to mention new failures like these as soon as you see them so we can improve the CI, I'm always interested.

This revision breaks test-check-imports.t, please follow-up.

Hmm, sorry about that. I noticed that it was failing, but it has been failing since D10513 for me. This is how it fails for me:

--- /usr/local/google/home/martinvonz/hg/tests/test-check-module-imports.t
+++ /usr/local/google/home/martinvonz/hg/tests/test-check-module-imports.t.err
@@ -42,3 +42,10 @@
   > -X tests/test-imports-checker.t \
   > -X tests/test-verify-repo-operations.py \
   > | sed 's-\\-/-g' | "$PYTHON" "$import_checker" -
+  tests/test-convert-bzr.t:117: imports not lexically sorted: breezy.bzr.bzrdir < sys
+  tests/test-convert-bzr.t:117: stdlib import "breezy.bzr.bzrdir" follows local import: breezy
+  tests/test-convert-bzr-ghosts.t:7: imports not lexically sorted: breezy.bzr.bzrdir < sys
+  tests/test-convert-bzr-ghosts.t:7: stdlib import "breezy.bzr.bzrdir" follows local import: breezy
+  tests/test-convert-bzr-treeroot.t:7: imports not lexically sorted: breezy.bzr.bzrdir < sys
+  tests/test-convert-bzr-treeroot.t:7: stdlib import "breezy.bzr.bzrdir" follows local import: breezy
+  [1]
ERROR: test-check-module-imports.t output changed

Does it fail in some other way for you?

Sorry, I was thinking about test-check-pyflakes.t, I got mixed up.

Ohh, turns out I didn't have pyflakes installed. I feel like I must have had that installed at some point after switching to Python 3. Ah, they're installed per minor version, so I must have lost it when I upgraded to Python 3.9. Anyway, I see the failure now, so I'll send a patch.

However test-check-imports.t does not fail for me either locally or on the CI, that's weird, I'll look at the test a little to see what could be happening.
Don't hesitate to mention new failures like these as soon as you see them so we can improve the CI, I'm always interested.

I'm used to having some tests fail so it doesn't bother me much :) FWIW, I also have this failure (I've seen it for months):

--- /usr/local/google/home/martinvonz/hg/tests/test-fuzz-targets.t
+++ /usr/local/google/home/martinvonz/hg/tests/test-fuzz-targets.t.err
@@ -43,6 +43,9 @@
 #if no-clang-libfuzzer clang-6.0
   $ CXX=clang++-6.0 havefuzz || exit 80
   $ $MAKE -s clean all CC=clang-6.0 CXX=clang++-6.0 PYTHON_CONFIG="$PYTHON_CONFIG"
+  clang: error: unknown argument: '-ffile-prefix-map=/build/python3.9-TR50zI/python3.9-3.9.2=.'
+  gmake: *** [Makefile:35: pyutil.o] Error 1
+  [2]
 #endif
 #if no-clang-libfuzzer no-clang-6.0
   $ exit 80
@@ -59,14 +62,7 @@
   >   ./$fuzzer dummy.cc > /dev/null 2>&1
   > done
   run bdiff_fuzzer...
-  run dirs_fuzzer...
-  run dirstate_fuzzer...
-  run fm1readmarkers_fuzzer...
-  run fncache_fuzzer...
-  run jsonescapeu8fast_fuzzer...
-  run manifest_fuzzer...
   run mpatch_fuzzer...
-  run revlog_fuzzer...
   run xdiff_fuzzer...

 Clean up.

ERROR: test-fuzz-targets.t output changed