diff options
author | Luke Diamand <luke@diamand.org> | 2015-11-21 09:54:40 +0000 |
---|---|---|
committer | Jeff King <peff@peff.net> | 2015-11-24 15:20:15 -0500 |
commit | cbff4b25e4e6e08637403d76bf32dbbd4d517442 (patch) | |
tree | e6d92c26e0cfd5033e2265a7db139464a466238a /git-p4.py | |
parent | 74b6fe9202792f43ba01014599c8fe183149c0a3 (diff) | |
download | git-cbff4b25e4e6e08637403d76bf32dbbd4d517442.tar.gz |
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 <luke@diamand.org>
Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'git-p4.py')
-rwxr-xr-x | git-p4.py | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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) |