Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Code cleanups.
author
Simon Hausmann
<simon@lst.de>
Mon, 12 Feb 2007 19:28:58 +0000
(20:28 +0100)
committer
Simon Hausmann
<simon@lst.de>
Mon, 12 Feb 2007 19:28:58 +0000
(20:28 +0100)
Signed-off-by: Simon Hausmann <simon@lst.de>
contrib/fast-import/p4-fast-export.py
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
12d04ca
)
diff --git
a/contrib/fast-import/p4-fast-export.py
b/contrib/fast-import/p4-fast-export.py
index 61b9e67e54b4bdb3808ed8c02eb668a0cb0db1cf..07d6e53852c2d76b0b16b91450eeec0c5e2d9cde 100755
(executable)
--- a/
contrib/fast-import/p4-fast-export.py
+++ b/
contrib/fast-import/p4-fast-export.py
@@
-93,7
+93,20
@@
def p4Cmd(cmd):
result.update(entry)
return result;
result.update(entry)
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 users
global lastChange
global initialParent
global users
global lastChange
@@
-119,24
+132,22
@@
def commit(details):
gitStream.write("from %s\n" % initialParent)
initialParent = ""
gitStream.write("from %s\n" % initialParent)
initialParent = ""
- fnum = 0
- while details.has_key("depotFile%s" % fnum):
- path = details["depotFile%s" % fnum]
+ for file in files:
+ path = file["path"]
if not path.startswith(prefix):
print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, prefix, change)
if not path.startswith(prefix):
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
relPath = path[len(prefix):]
depotPath = path + "#" + rev
relPath = path[len(prefix):]
- action =
details["action%s" % fnum
]
+ action =
file["action"
]
if action == "delete":
gitStream.write("D %s\n" % relPath)
else:
mode = 644
if action == "delete":
gitStream.write("D %s\n" % relPath)
else:
mode = 644
- if
details["type%s" % fnum
].startswith("x"):
+ if
file["type"
].startswith("x"):
mode = 755
data = os.popen("p4 print -q \"%s\"" % depotPath, "rb").read()
mode = 755
data = os.popen("p4 print -q \"%s\"" % depotPath, "rb").read()
@@
-146,8
+157,6
@@
def commit(details):
gitStream.write(data)
gitStream.write("\n")
gitStream.write(data)
gitStream.write("\n")
- fnum = fnum + 1
-
gitStream.write("\n")
lastChange = details["change"]
gitStream.write("\n")
lastChange = details["change"]
@@
-215,7
+224,7
@@
def getUserMap():
details["change"] = newestRevision
try:
details["change"] = newestRevision
try:
- commit(details)
+ commit(details
, extractFilesFromCommit(details), branch
)
except:
print gitError.read()
except:
print gitError.read()
@@
-242,7
+251,7
@@
def getUserMap():
cnt = cnt + 1
try:
cnt = cnt + 1
try:
- commit(description)
+ commit(description
, extractFilesFromCommit(description), branch
)
except:
print gitError.read()
sys.exit(1)
except:
print gitError.read()
sys.exit(1)