Fix Mercurial support when Mercurial config/extension errors are present.

Review Request #12243 — Created April 20, 2022 and submitted — Latest diff uploaded

Information

RBTools
release-3.x

Reviewers

Most of our Mercurial code assumes that the command we invoked has gone
right and that the outputted results are suitable for whatever we
queried.

This isn't always the case. If configuration is wrong (say, an extension
failed to load), any usable output could be prefixed with something like:

*** failed to import extension hgsubversion: No module named 'hgsubversion'

This went to stderr, but we redirected all errors by default to stdout.
That meant that we'd end up with a lot of bad output, which wasn't
necessarily caught until piped to another Mercurial command.

We now default any execute() calls to keeping error output on its own
stream and out of our standard output. There are some commands that do
need to check error output (such as the hgsubversion checks), so they go
through the normal behavior, but the rest will only capture usable
standard output now.

In the process, most calls to execute() have been changed to
self._execute(). That function itself has had a small logic tweak to
avoid a potentially unnecessary hg call for a capability check.

All unit tests passed in my environment with the error listed in the
description.

Commits

Files

    Loading...