Skip to content

Commit ab3ee71

Browse files
committed
Remove on_returncode parameter from call_subprocess
1 parent 94882fd commit ab3ee71

File tree

3 files changed

+21
-32
lines changed

3 files changed

+21
-32
lines changed

src/pip/_internal/vcs/git.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,13 @@ def get_revision_sha(cls, dest, rev):
134134
rev: the revision name.
135135
"""
136136
# Pass rev to pre-filter the list.
137-
output = cls.run_command(['show-ref', rev], cwd=dest,
138-
on_returncode='ignore')
137+
138+
output = ''
139+
try:
140+
output = cls.run_command(['show-ref', rev], cwd=dest)
141+
except SubProcessError:
142+
pass
143+
139144
refs = {}
140145
for line in output.strip().splitlines():
141146
try:
@@ -378,7 +383,6 @@ def get_repository_root(cls, location):
378383
r = cls.run_command(
379384
['rev-parse', '--show-toplevel'],
380385
cwd=location,
381-
on_returncode='raise',
382386
log_failed_cmd=False,
383387
)
384388
except BadCommand:

src/pip/_internal/vcs/mercurial.py

-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def get_repository_root(cls, location):
144144
r = cls.run_command(
145145
['root'],
146146
cwd=location,
147-
on_returncode='raise',
148147
log_failed_cmd=False,
149148
)
150149
except BadCommand:

src/pip/_internal/vcs/versioncontrol.py

+14-28
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def make_vcs_requirement_url(repo_url, rev, project_name, subdir=None):
8484
def call_subprocess(
8585
cmd, # type: Union[List[str], CommandArgs]
8686
cwd=None, # type: Optional[str]
87-
on_returncode='raise', # type: str
8887
extra_environ=None, # type: Optional[Mapping[str, Any]]
8988
extra_ok_returncodes=None, # type: Optional[Iterable[int]]
9089
log_failed_cmd=True # type: Optional[bool]
@@ -150,32 +149,21 @@ def call_subprocess(
150149
proc.returncode and proc.returncode not in extra_ok_returncodes
151150
)
152151
if proc_had_error:
153-
if on_returncode == 'raise':
154-
if not showing_subprocess and log_failed_cmd:
155-
# Then the subprocess streams haven't been logged to the
156-
# console yet.
157-
msg = make_subprocess_output_error(
158-
cmd_args=cmd,
159-
cwd=cwd,
160-
lines=all_output,
161-
exit_status=proc.returncode,
162-
)
163-
subprocess_logger.error(msg)
164-
exc_msg = (
165-
'Command errored out with exit status {}: {} '
166-
'Check the logs for full command output.'
167-
).format(proc.returncode, command_desc)
168-
raise SubProcessError(exc_msg)
169-
elif on_returncode == 'warn':
170-
subprocess_logger.warning(
171-
'Command "{}" had error code {} in {}'.format(
172-
command_desc, proc.returncode, cwd)
152+
if not showing_subprocess and log_failed_cmd:
153+
# Then the subprocess streams haven't been logged to the
154+
# console yet.
155+
msg = make_subprocess_output_error(
156+
cmd_args=cmd,
157+
cwd=cwd,
158+
lines=all_output,
159+
exit_status=proc.returncode,
173160
)
174-
elif on_returncode == 'ignore':
175-
pass
176-
else:
177-
raise ValueError('Invalid value: on_returncode={!r}'.format(
178-
on_returncode))
161+
subprocess_logger.error(msg)
162+
exc_msg = (
163+
'Command errored out with exit status {}: {} '
164+
'Check the logs for full command output.'
165+
).format(proc.returncode, command_desc)
166+
raise SubProcessError(exc_msg)
179167
return ''.join(all_output)
180168

181169

@@ -768,7 +756,6 @@ def run_command(
768756
cls,
769757
cmd, # type: Union[List[str], CommandArgs]
770758
cwd=None, # type: Optional[str]
771-
on_returncode='raise', # type: str
772759
extra_environ=None, # type: Optional[Mapping[str, Any]]
773760
extra_ok_returncodes=None, # type: Optional[Iterable[int]]
774761
log_failed_cmd=True # type: bool
@@ -782,7 +769,6 @@ def run_command(
782769
cmd = make_command(cls.name, *cmd)
783770
try:
784771
return call_subprocess(cmd, cwd,
785-
on_returncode=on_returncode,
786772
extra_environ=extra_environ,
787773
extra_ok_returncodes=extra_ok_returncodes,
788774
log_failed_cmd=log_failed_cmd)

0 commit comments

Comments
 (0)