git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luke Diamand <luke@diamand.org>
To: git@vger.kernel.org
Cc: larsxschneider@gmail.com, Junio C Hamano <gitster@pobox.com>,
	peff@peff.net, sunshine@sunshineco.com,
	Luke Diamand <luke@diamand.org>
Subject: [PATCH v2 2/3] git-p4: add option to system() to return subshell status
Date: Sat, 21 Nov 2015 09:54:40 +0000	[thread overview]
Message-ID: <1448099681-20183-3-git-send-email-luke@diamand.org> (raw)
In-Reply-To: <1448099681-20183-1-git-send-email-luke@diamand.org>

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>
---
 git-p4.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/git-p4.py b/git-p4.py
index 0093fa3..9d55f9c 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -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)
-- 
2.6.0.rc3.238.gc07a1e8

  parent reply	other threads:[~2015-11-21  9:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-21  9:54 [PATCH v2 0/2] git-p4: allow submission from detached head Luke Diamand
2015-11-21  9:54 ` [PATCH v2 1/3] git-p4: add failing test for submit " Luke Diamand
2015-11-21  9:54 ` Luke Diamand [this message]
2015-11-21  9:54 ` [PATCH v2 3/3] git-p4: work with a " Luke Diamand
  -- strict thread matches above, loose matches on Subject: below --
2015-11-07  1:07 [PATCH v2 0/2] git-p4: allow submission from " Luke Diamand
2015-11-07  1:07 ` [PATCH v2 2/3] git-p4: add option to system() to return subshell status Luke Diamand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448099681-20183-3-git-send-email-luke@diamand.org \
    --to=luke@diamand.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=larsxschneider@gmail.com \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).