Skip to content

Commit 390ac27

Browse files
committed
Merge branch 'bc/git-p4-for-python-2.4' into maint
* 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
2 parents 6cc0149 + 2e4f04f commit 390ac27

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

INSTALL

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ Issues of note:
131131
use English. Under autoconf the configure script will do this
132132
automatically if it can't find libintl on the system.
133133

134-
- Python version 2.6 or later is needed to use the git-p4
135-
interface to Perforce.
134+
- Python version 2.4 or later (but not 3.x, which is not
135+
supported by Perforce) is needed to use the git-p4 interface
136+
to Perforce.
136137

137138
- Some platform specific issues are dealt with Makefile rules,
138139
but depending on your specific installation, you may not

git-p4.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212
import tempfile, getopt, os.path, time, platform
1313
import re, shutil
1414

15+
try:
16+
from subprocess import CalledProcessError
17+
except ImportError:
18+
# from python2.7:subprocess.py
19+
# Exception classes used by this module.
20+
class CalledProcessError(Exception):
21+
"""This exception is raised when a process run by check_call() returns
22+
a non-zero exit status. The exit status will be stored in the
23+
returncode attribute."""
24+
def __init__(self, returncode, cmd):
25+
self.returncode = returncode
26+
self.cmd = cmd
27+
def __str__(self):
28+
return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
29+
1530
verbose = False
1631

1732
# Only labels/tags matching this will be imported/exported
@@ -152,13 +167,17 @@ def system(cmd):
152167
expand = isinstance(cmd,basestring)
153168
if verbose:
154169
sys.stderr.write("executing %s\n" % str(cmd))
155-
subprocess.check_call(cmd, shell=expand)
170+
retcode = subprocess.call(cmd, shell=expand)
171+
if retcode:
172+
raise CalledProcessError(retcode, cmd)
156173

157174
def p4_system(cmd):
158175
"""Specifically invoke p4 as the system command. """
159176
real_cmd = p4_build_cmd(cmd)
160177
expand = isinstance(real_cmd, basestring)
161-
subprocess.check_call(real_cmd, shell=expand)
178+
retcode = subprocess.call(real_cmd, shell=expand)
179+
if retcode:
180+
raise CalledProcessError(retcode, real_cmd)
162181

163182
def p4_integrate(src, dest):
164183
p4_system(["integrate", "-Dt", wildcard_encode(src), wildcard_encode(dest)])
@@ -742,7 +761,8 @@ def wildcard_encode(path):
742761
return path
743762

744763
def wildcard_present(path):
745-
return path.translate(None, "*#@%") != path
764+
m = re.search("[*#@%]", path)
765+
return m is not None
746766

747767
class Command:
748768
def __init__(self):
@@ -3103,7 +3123,9 @@ def run(self, args):
31033123
init_cmd = [ "git", "init" ]
31043124
if self.cloneBare:
31053125
init_cmd.append("--bare")
3106-
subprocess.check_call(init_cmd)
3126+
retcode = subprocess.call(init_cmd)
3127+
if retcode:
3128+
raise CalledProcessError(retcode, init_cmd)
31073129

31083130
if not P4Sync.run(self, depotPaths):
31093131
return False

t/t9802-git-p4-filetype.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ build_gendouble() {
105105
cat >gendouble.py <<-\EOF
106106
import sys
107107
import struct
108-
import array
109108
110-
s = array.array("c", '\0' * 26)
111-
struct.pack_into(">L", s, 0, 0x00051607) # AppleDouble
112-
struct.pack_into(">L", s, 4, 0x00020000) # version 2
113-
s.tofile(sys.stdout)
109+
s = struct.pack(">LL18s",
110+
0x00051607, # AppleDouble
111+
0x00020000, # version 2
112+
"" # pad to 26 bytes
113+
)
114+
sys.stdout.write(s)
114115
EOF
115116
}
116117

0 commit comments

Comments
 (0)