Repository: pypa/pip
Pull request #11051 (2022-04-20 18:01:29)

fix svn and bazaar failing to checkout in verbose mode
Closes: https://github.com/pypa/pip/issues/11050

devsagul: There is a a failing test: is it a flap? Should I somehow re-run it, or it can be related to the fact that timeout was not processed properly before and test failed because verbose checkouts failed and now I should fix it somehow?
uranusjr: Yeah that does nto seem related. And it only fails on one Windows machine. Don’t worry about it (for this PR), that should be dealt separately.
dfn-certling: Is there something missing here? The fix looks straight forward?
devsagul: > Is there something missing here? The fix looks straight forward?

I guess it should be planned for including into a release by a maintainer and than merged (it was never stated clearly). I will update the PR.
pfmoore: Thanks for the fix!

Patch:
diff --git a/news/11050.bugfix.rst b/news/11050.bugfix.rst
new file mode 100644
index 000000000..01aa5ea7b
--- /dev/null
+++ b/news/11050.bugfix.rst
@@ -0,0 +1,1 @@
+Fix error on checkout for subversion and bazaar with verbose mode on.
diff --git a/src/pip/_internal/vcs/bazaar.py b/src/pip/_internal/vcs/bazaar.py
index 20a17ed09..c754b7cc5 100644
--- a/src/pip/_internal/vcs/bazaar.py
+++ b/src/pip/_internal/vcs/bazaar.py
@@ -44,13 +44,13 @@ class Bazaar(VersionControl):
             display_path(dest),
         )
         if verbosity <= 0:
-            flag = "--quiet"
+            flags = ["--quiet"]
         elif verbosity == 1:
-            flag = ""
+            flags = []
         else:
-            flag = f"-{'v'*verbosity}"
+            flags = [f"-{'v'*verbosity}"]
         cmd_args = make_command(
-            "checkout", "--lightweight", flag, rev_options.to_args(), url, dest
+            "checkout", "--lightweight", *flags, rev_options.to_args(), url, dest
         )
         self.run_command(cmd_args)
 
diff --git a/src/pip/_internal/vcs/subversion.py b/src/pip/_internal/vcs/subversion.py
index 16d93a67b..f359266d9 100644
--- a/src/pip/_internal/vcs/subversion.py
+++ b/src/pip/_internal/vcs/subversion.py
@@ -288,12 +288,12 @@ class Subversion(VersionControl):
             display_path(dest),
         )
         if verbosity <= 0:
-            flag = "--quiet"
+            flags = ["--quiet"]
         else:
-            flag = ""
+            flags = []
         cmd_args = make_command(
             "checkout",
-            flag,
+            *flags,
             self.get_remote_call_options(),
             rev_options.to_args(),
             url,


Test patch:
diff --git a/tests/unit/test_vcs.py b/tests/unit/test_vcs.py
index a52a6217e..af5f348dc 100644
--- a/tests/unit/test_vcs.py
+++ b/tests/unit/test_vcs.py
@@ -777,6 +777,22 @@ class TestSubversionArgs(TestCase):
         assert self.call_subprocess_mock.call_args[0][0] == args
 
     def test_obtain(self) -> None:
+        self.svn.obtain(self.dest, hide_url(self.url), verbosity=1)
+        self.assert_call_args(
+            [
+                "svn",
+                "checkout",
+                "--non-interactive",
+                "--username",
+                "username",
+                "--password",
+                hide_value("password"),
+                hide_url("http://svn.example.com/"),
+                "/tmp/test",
+            ]
+        )
+
+    def test_obtain_quiet(self) -> None:
         self.svn.obtain(self.dest, hide_url(self.url), verbosity=0)
         self.assert_call_args(
             [
@@ -794,6 +810,18 @@ class TestSubversionArgs(TestCase):
         )
 
     def test_fetch_new(self) -> None:
+        self.svn.fetch_new(self.dest, hide_url(self.url), self.rev_options, verbosity=1)
+        self.assert_call_args(
+            [
+                "svn",
+                "checkout",
+                "--non-interactive",
+                hide_url("svn+http://username:password@svn.example.com/"),
+                "/tmp/test",
+            ]
+        )
+
+    def test_fetch_new_quiet(self) -> None:
         self.svn.fetch_new(self.dest, hide_url(self.url), self.rev_options, verbosity=0)
         self.assert_call_args(
             [
@@ -807,6 +835,21 @@ class TestSubversionArgs(TestCase):
         )
 
     def test_fetch_new_revision(self) -> None:
+        rev_options = RevOptions(Subversion, "123")
+        self.svn.fetch_new(self.dest, hide_url(self.url), rev_options, verbosity=1)
+        self.assert_call_args(
+            [
+                "svn",
+                "checkout",
+                "--non-interactive",
+                "-r",
+                "123",
+                hide_url("svn+http://username:password@svn.example.com/"),
+                "/tmp/test",
+            ]
+        )
+
+    def test_fetch_new_revision_quiet(self) -> None:
         rev_options = RevOptions(Subversion, "123")
         self.svn.fetch_new(self.dest, hide_url(self.url), rev_options, verbosity=0)
         self.assert_call_args(