Skip to content

Commit 690522a

Browse files
committed
Use custom call_subprocess for VCS commands
1 parent c87f1b3 commit 690522a

File tree

3 files changed

+8
-28
lines changed

3 files changed

+8
-28
lines changed

src/pip/_internal/vcs/subversion.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
if MYPY_CHECK_RUNNING:
28-
from typing import Optional, Tuple, Text
28+
from typing import Optional, Tuple
2929
from pip._internal.utils.subprocess import CommandArgs
3030
from pip._internal.utils.misc import HiddenText
3131
from pip._internal.vcs.versioncontrol import AuthInfo, RevOptions
@@ -215,17 +215,7 @@ def call_vcs_version(self):
215215
# svn, version 1.7.14 (r1542130)
216216
# compiled Mar 28 2018, 08:49:13 on x86_64-pc-linux-gnu
217217
version_prefix = 'svn, version '
218-
cmd_output = self.run_command(['--version'], show_stdout=False)
219-
220-
# Split the output by newline, and find the first line where
221-
# version_prefix is present
222-
output_lines = cmd_output.split('\n')
223-
version = '' # type: Text
224-
225-
for line in output_lines:
226-
if version_prefix in line:
227-
version = line
228-
break
218+
version = self.run_command(['--version'], show_stdout=True)
229219

230220
if not version.startswith(version_prefix):
231221
return ()

src/pip/_internal/vcs/versioncontrol.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
if MYPY_CHECK_RUNNING:
4040
from typing import (
4141
Dict, Iterable, Iterator, List, Optional, Text, Tuple,
42-
Type, Union, IO
42+
Type, Union
4343
)
4444
from pip._internal.utils.misc import HiddenText
4545
from pip._internal.utils.subprocess import CommandArgs
@@ -104,7 +104,8 @@ def call_subprocess(
104104
# Most places in pip use show_stdout=False.
105105
# What this means is--
106106
#
107-
# - We log this output of stdout and stderr at DEBUG level as it is received.
107+
# - We log this output of stdout and stderr at DEBUG level
108+
# as it is received.
108109
# - If DEBUG logging isn't enabled (e.g. if --verbose logging wasn't
109110
# requested), then we show a spinner so the user can still see the
110111
# subprocess is in progress.
@@ -133,9 +134,9 @@ def call_subprocess(
133134
proc = subprocess.Popen(
134135
# Convert HiddenText objects to the underlying str.
135136
reveal_command_args(cmd),
136-
stdin=subprocess.PIPE,
137137
stdout=subprocess.PIPE,
138-
cwd=cwd,
138+
stderr=subprocess.PIPE,
139+
cwd=cwd
139140
)
140141
if proc.stdin:
141142
proc.stdin.close()
@@ -163,6 +164,7 @@ def call_subprocess(
163164
finally:
164165
if proc.stdout:
165166
proc.stdout.close()
167+
166168
proc_had_error = (
167169
proc.returncode and proc.returncode not in extra_ok_returncodes
168170
)

tests/unit/test_vcs.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,18 +443,6 @@ def test_subversion__call_vcs_version():
443443
('svn, version 1.10.3 (r1842928)\n'
444444
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0',
445445
(1, 10, 3)),
446-
('Warning: Failed to set locale category LC_NUMERIC to en_IN.\n'
447-
'Warning: Failed to set locale category LC_TIME to en_IN.\n'
448-
'svn, version 1.10.3 (r1842928)\n'
449-
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0',
450-
(1, 10, 3)),
451-
('Warning: Failed to set locale category LC_NUMERIC to en_IN.\n'
452-
'Warning: Failed to set locale category LC_TIME to en_IN.\n'
453-
'svn, version 1.10.3 (r1842928)\n'
454-
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0'
455-
'svn, version 1.11.3 (r1842928)\n'
456-
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0',
457-
(1, 10, 3)),
458446
('svn, version 1.9.7 (r1800392)', (1, 9, 7)),
459447
('svn, version 1.9.7a1 (r1800392)', ()),
460448
('svn, version 1.9 (r1800392)', (1, 9)),

0 commit comments

Comments
 (0)