+#
+# Copyright (C) 2005 Fredrik Kuivinen
+#
+
import sys, re, os, traceback
from sets import Set
-if sys.version_info[0] < 2 or \
- (sys.version_info[0] == 2 and sys.version_info[1] < 4):
- print 'Python version 2.4 required, found', \
- str(sys.version_info[0])+'.'+str(sys.version_info[1])+'.'+ \
- str(sys.version_info[2])
- sys.exit(1)
-
-import subprocess
-
def die(*args):
printList(args, sys.stderr)
sys.exit(2)
+def printList(list, file=sys.stdout):
+ for x in list:
+ file.write(str(x))
+ file.write(' ')
+ file.write('\n')
+
+import subprocess
+
# Debugging machinery
# -------------------
if funcName in functionsToDebug:
printList(args)
-def printList(list, file=sys.stdout):
- for x in list:
- file.write(str(x))
- file.write(' ')
- file.write('\n')
-
# Program execution
# -----------------
self.progStr = progStr
self.error = error
+ def __str__(self):
+ return self.progStr + ': ' + self.error
+
addDebug('runProgram')
def runProgram(prog, input=None, returnCode=False, env=None, pipeOutput=True):
debug('runProgram prog:', str(prog), 'input:', str(input))
return (type(obj) is str and bool(shaRE.match(obj))) or \
(type(obj) is int and obj >= 1)
-class Commit:
+class Commit(object):
+ __slots__ = ['parents', 'firstLineMsg', 'children', '_tree', 'sha',
+ 'virtual']
+
def __init__(self, sha, parents, tree=None):
self.parents = parents
self.firstLineMsg = None
# Write the empty tree to the object database and return its SHA1
def writeEmptyTree():
- tmpIndex = os.environ['GIT_DIR'] + '/merge-tmp-index'
+ tmpIndex = os.environ.get('GIT_DIR', '.git') + '/merge-tmp-index'
def delTmpIndex():
try:
os.unlink(tmpIndex)