Skip to content

Commit

Permalink
git-p4: add option to system() to return subshell status
Browse files Browse the repository at this point in the history
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 <luke@diamand.org>
Signed-off-by: Jeff King <peff@peff.net>
  • Loading branch information
luked99 authored and peff committed Nov 24, 2015
1 parent 74b6fe9 commit cbff4b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions git-p4.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,16 @@ def p4_has_move_command():
# assume it failed because @... was invalid changelist
return True

def system(cmd):
def system(cmd, ignore_error=False):
expand = isinstance(cmd,basestring)
if verbose:
sys.stderr.write("executing %s\n" % str(cmd))
retcode = subprocess.call(cmd, shell=expand)
if retcode:
if retcode and not ignore_error:
raise CalledProcessError(retcode, cmd)

return retcode

def p4_system(cmd):
"""Specifically invoke p4 as the system command. """
real_cmd = p4_build_cmd(cmd)
Expand Down

0 comments on commit cbff4b2

Please sign in to comment.