Skip to content

Commit cbff4b2

Browse files
luked99peff
authored andcommitted
git-p4: add option to system() to return subshell status
Add an optional parameter ignore_error to the git-p4 system() function. If used, it will return the subshell exit status rather than throwing an exception. Signed-off-by: Luke Diamand <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 74b6fe9 commit cbff4b2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

git-p4.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,16 @@ def p4_has_move_command():
192192
# assume it failed because @... was invalid changelist
193193
return True
194194

195-
def system(cmd):
195+
def system(cmd, ignore_error=False):
196196
expand = isinstance(cmd,basestring)
197197
if verbose:
198198
sys.stderr.write("executing %s\n" % str(cmd))
199199
retcode = subprocess.call(cmd, shell=expand)
200-
if retcode:
200+
if retcode and not ignore_error:
201201
raise CalledProcessError(retcode, cmd)
202202

203+
return retcode
204+
203205
def p4_system(cmd):
204206
"""Specifically invoke p4 as the system command. """
205207
real_cmd = p4_build_cmd(cmd)

0 commit comments

Comments
 (0)