summaryrefslogtreecommitdiff
path: root/git-p4.py
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-02-01 12:40:10 -0800
committerJunio C Hamano <gitster@pobox.com>2013-02-01 12:40:10 -0800
commit97fbc23ad7bf13e4f4b74c6f9f98aaa65bd2117a (patch)
tree202cf21695faed41594221e6cdf03b26f64eff1f /git-p4.py
parenta14daf8b9101225792341e4354699c5a2e30449a (diff)
parent2e4f04fae6810161c17bf456124b364ad927c499 (diff)
downloadgit-97fbc23ad7bf13e4f4b74c6f9f98aaa65bd2117a.tar.gz
Merge branch 'bc/git-p4-for-python-2.4'
With small updates to remove dependency on newer features of Python, keep git-p4 usable with older Python. * bc/git-p4-for-python-2.4: INSTALL: git-p4 does not support Python 3 git-p4.py: support Python 2.4 git-p4.py: support Python 2.5
Diffstat (limited to 'git-p4.py')
-rwxr-xr-xgit-p4.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/git-p4.py b/git-p4.py
index 2da564995d..625a3968c2 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -18,6 +18,21 @@ import optparse, os, marshal, subprocess, shelve
import tempfile, getopt, os.path, time, platform
import re, shutil
+try:
+ from subprocess import CalledProcessError
+except ImportError:
+ # from python2.7:subprocess.py
+ # Exception classes used by this module.
+ class CalledProcessError(Exception):
+ """This exception is raised when a process run by check_call() returns
+ a non-zero exit status. The exit status will be stored in the
+ returncode attribute."""
+ def __init__(self, returncode, cmd):
+ self.returncode = returncode
+ self.cmd = cmd
+ def __str__(self):
+ return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
+
verbose = False
# Only labels/tags matching this will be imported/exported
@@ -158,13 +173,17 @@ def system(cmd):
expand = isinstance(cmd,basestring)
if verbose:
sys.stderr.write("executing %s\n" % str(cmd))
- subprocess.check_call(cmd, shell=expand)
+ retcode = subprocess.call(cmd, shell=expand)
+ if retcode:
+ raise CalledProcessError(retcode, cmd)
def p4_system(cmd):
"""Specifically invoke p4 as the system command. """
real_cmd = p4_build_cmd(cmd)
expand = isinstance(real_cmd, basestring)
- subprocess.check_call(real_cmd, shell=expand)
+ retcode = subprocess.call(real_cmd, shell=expand)
+ if retcode:
+ raise CalledProcessError(retcode, real_cmd)
def p4_integrate(src, dest):
p4_system(["integrate", "-Dt", wildcard_encode(src), wildcard_encode(dest)])
@@ -768,7 +787,8 @@ def wildcard_encode(path):
return path
def wildcard_present(path):
- return path.translate(None, "*#@%") != path
+ m = re.search("[*#@%]", path)
+ return m is not None
class Command:
def __init__(self):
@@ -3173,7 +3193,9 @@ class P4Clone(P4Sync):
init_cmd = [ "git", "init" ]
if self.cloneBare:
init_cmd.append("--bare")
- subprocess.check_call(init_cmd)
+ retcode = subprocess.call(init_cmd)
+ if retcode:
+ raise CalledProcessError(retcode, init_cmd)
if not P4Sync.run(self, depotPaths):
return False