Improve check for svn version string

This commit is contained in:
Devesh Kumar Singh 2020-04-03 13:08:41 +05:30
parent 642fb07337
commit 1471897b84
3 changed files with 26 additions and 2 deletions

1
news/7968.bugfix Normal file
View File

@ -0,0 +1 @@
Look for version string in the entire output of svn --version, not just the first line

View File

@ -25,7 +25,7 @@ _svn_info_xml_url_re = re.compile(r'<url>(.*)</url>')
if MYPY_CHECK_RUNNING: if MYPY_CHECK_RUNNING:
from typing import Optional, Tuple from typing import Optional, Tuple, Text
from pip._internal.utils.subprocess import CommandArgs from pip._internal.utils.subprocess import CommandArgs
from pip._internal.utils.misc import HiddenText from pip._internal.utils.misc import HiddenText
from pip._internal.vcs.versioncontrol import AuthInfo, RevOptions from pip._internal.vcs.versioncontrol import AuthInfo, RevOptions
@ -215,7 +215,18 @@ class Subversion(VersionControl):
# svn, version 1.7.14 (r1542130) # svn, version 1.7.14 (r1542130)
# compiled Mar 28 2018, 08:49:13 on x86_64-pc-linux-gnu # compiled Mar 28 2018, 08:49:13 on x86_64-pc-linux-gnu
version_prefix = 'svn, version ' version_prefix = 'svn, version '
version = self.run_command(['--version'], show_stdout=False) cmd_output = self.run_command(['--version'], show_stdout=False)
# Split the output by newline, and find the first line where
# version_prefix is present
output_lines = cmd_output.split('\n')
version = '' # type: Text
for line in output_lines:
if version_prefix in line:
version = line
break
if not version.startswith(version_prefix): if not version.startswith(version_prefix):
return () return ()

View File

@ -443,6 +443,18 @@ def test_subversion__call_vcs_version():
('svn, version 1.10.3 (r1842928)\n' ('svn, version 1.10.3 (r1842928)\n'
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0', ' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0',
(1, 10, 3)), (1, 10, 3)),
('Warning: Failed to set locale category LC_NUMERIC to en_IN.\n'
'Warning: Failed to set locale category LC_TIME to en_IN.\n'
'svn, version 1.10.3 (r1842928)\n'
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0',
(1, 10, 3)),
('Warning: Failed to set locale category LC_NUMERIC to en_IN.\n'
'Warning: Failed to set locale category LC_TIME to en_IN.\n'
'svn, version 1.10.3 (r1842928)\n'
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0'
'svn, version 1.11.3 (r1842928)\n'
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0',
(1, 10, 3)),
('svn, version 1.9.7 (r1800392)', (1, 9, 7)), ('svn, version 1.9.7 (r1800392)', (1, 9, 7)),
('svn, version 1.9.7a1 (r1800392)', ()), ('svn, version 1.9.7a1 (r1800392)', ()),
('svn, version 1.9 (r1800392)', (1, 9)), ('svn, version 1.9 (r1800392)', (1, 9)),