parent
12d04ca7da
commit
44b3add651
|
@ -93,7 +93,20 @@ def p4Cmd(cmd):
|
||||||
result.update(entry)
|
result.update(entry)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
def commit(details):
|
def extractFilesFromCommit(commit):
|
||||||
|
files = []
|
||||||
|
fnum = 0
|
||||||
|
while commit.has_key("depotFile%s" % fnum):
|
||||||
|
file = {}
|
||||||
|
file["path"] = commit["depotFile%s" % fnum]
|
||||||
|
file["rev"] = commit["rev%s" % fnum]
|
||||||
|
file["action"] = commit["action%s" % fnum]
|
||||||
|
file["type"] = commit["type%s" % fnum]
|
||||||
|
files.append(file)
|
||||||
|
fnum = fnum + 1
|
||||||
|
return files
|
||||||
|
|
||||||
|
def commit(details, files, branch):
|
||||||
global initialParent
|
global initialParent
|
||||||
global users
|
global users
|
||||||
global lastChange
|
global lastChange
|
||||||
|
@ -119,24 +132,22 @@ def commit(details):
|
||||||
gitStream.write("from %s\n" % initialParent)
|
gitStream.write("from %s\n" % initialParent)
|
||||||
initialParent = ""
|
initialParent = ""
|
||||||
|
|
||||||
fnum = 0
|
for file in files:
|
||||||
while details.has_key("depotFile%s" % fnum):
|
path = file["path"]
|
||||||
path = details["depotFile%s" % fnum]
|
|
||||||
if not path.startswith(prefix):
|
if not path.startswith(prefix):
|
||||||
print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, prefix, change)
|
print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, prefix, change)
|
||||||
fnum = fnum + 1
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
rev = details["rev%s" % fnum]
|
rev = file["rev"]
|
||||||
depotPath = path + "#" + rev
|
depotPath = path + "#" + rev
|
||||||
relPath = path[len(prefix):]
|
relPath = path[len(prefix):]
|
||||||
action = details["action%s" % fnum]
|
action = file["action"]
|
||||||
|
|
||||||
if action == "delete":
|
if action == "delete":
|
||||||
gitStream.write("D %s\n" % relPath)
|
gitStream.write("D %s\n" % relPath)
|
||||||
else:
|
else:
|
||||||
mode = 644
|
mode = 644
|
||||||
if details["type%s" % fnum].startswith("x"):
|
if file["type"].startswith("x"):
|
||||||
mode = 755
|
mode = 755
|
||||||
|
|
||||||
data = os.popen("p4 print -q \"%s\"" % depotPath, "rb").read()
|
data = os.popen("p4 print -q \"%s\"" % depotPath, "rb").read()
|
||||||
|
@ -146,8 +157,6 @@ def commit(details):
|
||||||
gitStream.write(data)
|
gitStream.write(data)
|
||||||
gitStream.write("\n")
|
gitStream.write("\n")
|
||||||
|
|
||||||
fnum = fnum + 1
|
|
||||||
|
|
||||||
gitStream.write("\n")
|
gitStream.write("\n")
|
||||||
|
|
||||||
lastChange = details["change"]
|
lastChange = details["change"]
|
||||||
|
@ -215,7 +224,7 @@ if len(revision) > 0:
|
||||||
details["change"] = newestRevision
|
details["change"] = newestRevision
|
||||||
|
|
||||||
try:
|
try:
|
||||||
commit(details)
|
commit(details, extractFilesFromCommit(details), branch)
|
||||||
except:
|
except:
|
||||||
print gitError.read()
|
print gitError.read()
|
||||||
|
|
||||||
|
@ -242,7 +251,7 @@ else:
|
||||||
cnt = cnt + 1
|
cnt = cnt + 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
commit(description)
|
commit(description, extractFilesFromCommit(description), branch)
|
||||||
except:
|
except:
|
||||||
print gitError.read()
|
print gitError.read()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in New Issue