Fix invocation issues when running brz in Python module directories.

Review Request #12301 — Created May 25, 2022 and submitted

Information

Review Board
release-4.0.x

Reviewers

When running Bazaar or Breezy, we construct a plugin path in order to
register rbssh as an SSH provider. To avoid overriding existing
plugins, we factor in an existing path in the environment. If that's
empty, the plugin path ends up with a trailing :.

Breezy seems to, intentionally or otherwise, treat an empty path after
the : as "current directory." This can cause failures if trying to run
from within a Python module path (which can happen in unit test runs).

We now strip away any trailing :, from either our provided path or an
existing plugin path, in order to avoid this. We also no longer convert
to UTF-8, as SCMTool.popen() normalizes environment variables for us.

While working on this, I found that we sometimes also joined the
repository path to itself when trying to validate a repository. This
actually worked, which is why we didn't notice it before (presumably,
Bazaar and Breezy handle the path until it finds a Bazaar repository,
ignoring the rest). However, it's clearly wrong. We no longer perform
this join for repository validation.

Unit tests now pass. This was discovered on my release-5.0.x tree, but
is being backported to release-4.0.x.

Summary ID
Fix invocation issues when running brz in Python module directories.
When running Bazaar or Breezy, we construct a plugin path in order to register `rbssh` as an SSH provider. To avoid overriding existing plugins, we factor in an existing path in the environment. If that's empty, the plugin path ends up with a trailing `:`. Breezy seems to, intentionally or otherwise, treat an empty path after the `:` as "current directory." This can cause failures if trying to run from within a Python module path (which can happen in unit test runs). We now strip away any trailing `:`, from either our provided path or an existing plugin path, in order to avoid this. We also no longer convert to UTF-8, as `SCMTool.popen()` normalizes environment variables for us. While working on this, I found that we sometimes also joined the repository path to itself when trying to validate a repository. This actually worked, which is why we didn't notice it before (presumably, Bazaar and Breezy handle the path until it finds a Bazaar repository, ignoring the rest). However, it's clearly wrong. We no longer perform this join for repository validation.
c7d8e7fbe47868658b12b55f5e6e1cb3d4677ec6
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.0.x (b143f74)