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
This commit is contained in:
Junio C Hamano 2013-02-04 10:04:57 -08:00
commit 390ac27a18
3 changed files with 35 additions and 11 deletions

View File

@ -131,8 +131,9 @@ Issues of note:
use English. Under autoconf the configure script will do this use English. Under autoconf the configure script will do this
automatically if it can't find libintl on the system. automatically if it can't find libintl on the system.
- Python version 2.6 or later is needed to use the git-p4 - Python version 2.4 or later (but not 3.x, which is not
interface to Perforce. supported by Perforce) is needed to use the git-p4 interface
to Perforce.
- Some platform specific issues are dealt with Makefile rules, - Some platform specific issues are dealt with Makefile rules,
but depending on your specific installation, you may not but depending on your specific installation, you may not

View File

@ -12,6 +12,21 @@ import optparse, sys, os, marshal, subprocess, shelve
import tempfile, getopt, os.path, time, platform import tempfile, getopt, os.path, time, platform
import re, shutil 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 verbose = False
# Only labels/tags matching this will be imported/exported # Only labels/tags matching this will be imported/exported
@ -152,13 +167,17 @@ def system(cmd):
expand = isinstance(cmd,basestring) expand = isinstance(cmd,basestring)
if verbose: if verbose:
sys.stderr.write("executing %s\n" % str(cmd)) 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): def p4_system(cmd):
"""Specifically invoke p4 as the system command. """ """Specifically invoke p4 as the system command. """
real_cmd = p4_build_cmd(cmd) real_cmd = p4_build_cmd(cmd)
expand = isinstance(real_cmd, basestring) 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): def p4_integrate(src, dest):
p4_system(["integrate", "-Dt", wildcard_encode(src), wildcard_encode(dest)]) p4_system(["integrate", "-Dt", wildcard_encode(src), wildcard_encode(dest)])
@ -742,7 +761,8 @@ def wildcard_encode(path):
return path return path
def wildcard_present(path): def wildcard_present(path):
return path.translate(None, "*#@%") != path m = re.search("[*#@%]", path)
return m is not None
class Command: class Command:
def __init__(self): def __init__(self):
@ -3103,7 +3123,9 @@ class P4Clone(P4Sync):
init_cmd = [ "git", "init" ] init_cmd = [ "git", "init" ]
if self.cloneBare: if self.cloneBare:
init_cmd.append("--bare") 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): if not P4Sync.run(self, depotPaths):
return False return False

View File

@ -105,12 +105,13 @@ build_gendouble() {
cat >gendouble.py <<-\EOF cat >gendouble.py <<-\EOF
import sys import sys
import struct import struct
import array
s = array.array("c", '\0' * 26) s = struct.pack(">LL18s",
struct.pack_into(">L", s, 0, 0x00051607) # AppleDouble 0x00051607, # AppleDouble
struct.pack_into(">L", s, 4, 0x00020000) # version 2 0x00020000, # version 2
s.tofile(sys.stdout) "" # pad to 26 bytes
)
sys.stdout.write(s)
EOF EOF
} }