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>
Luke Diamand committed
Nov 21, 2015 at 09:54 UTC
cbff4b25e4e6e08637403d76bf32dbbd4d517442
1 file changed
+4
-2
git-p4.py
+4
-2
@@ -192,14 +192,16 @@ def p4_has_move_command():
192
# assume it failed because @... was invalid changelist
193
return True
194
195
-def system(cmd):
195
+def system(cmd, ignore_error=False):
196
expand = isinstance(cmd,basestring)
197
if verbose:
198
sys.stderr.write("executing %s\n" % str(cmd))
199
retcode = subprocess.call(cmd, shell=expand)
200
- if retcode:
200
+ if retcode and not ignore_error:
201
raise CalledProcessError(retcode, cmd)
202
203
+ return retcode
204
+
205
def p4_system(cmd):
206
"""Specifically invoke p4 as the system command. """
207
real_cmd = p4_build_cmd(cmd)