diff options
author | Simon Hausmann <hausmann@kde.org> | 2007-01-31 22:38:07 +0100 |
---|---|---|
committer | Simon Hausmann <hausmann@kde.org> | 2007-01-31 22:38:07 +0100 |
commit | 2385536282d809e923af3895624d8c66b01ec433 (patch) | |
tree | 700ee2cb14b51c4652ddb0ae3f8e7b8321dfb738 /contrib/fast-import/p4-fast-export.py | |
parent | Ported the remaining functions that parsed p4 shell output over to the p4 pyt... (diff) | |
download | tgif-2385536282d809e923af3895624d8c66b01ec433.tar.xz |
Avoid calling fstat for every imported file (slow!) and instead read the file data first into the python process and use the length of the bytes read for the size field of git fast-import.
Signed-off-by: Simon Hausmann <hausmann@kde.org>
Diffstat (limited to 'contrib/fast-import/p4-fast-export.py')
-rw-r--r-- | contrib/fast-import/p4-fast-export.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/contrib/fast-import/p4-fast-export.py b/contrib/fast-import/p4-fast-export.py index 45d5157961..133447c4e7 100644 --- a/contrib/fast-import/p4-fast-export.py +++ b/contrib/fast-import/p4-fast-export.py @@ -57,9 +57,6 @@ def p4Cmd(cmd): result.update(entry) return result; -def p4FileSize(path): - return int(p4Cmd("fstat -Ol \"%s\"" % path)["fileSize"]) - def getUserMap(): users = {} @@ -121,14 +118,15 @@ for change in changes: if action == "delete": gitStream.write("D %s\n" % relPath) else: - fileSize = p4FileSize(depotPath) mode = 644 if description["type%s" % fnum].startswith("x"): mode = 755 + data = os.popen("p4 print -q \"%s\"" % depotPath, "rb").read() + gitStream.write("M %s inline %s\n" % (mode, relPath)) - gitStream.write("data %s\n" % fileSize) - gitStream.write(os.popen("p4 print -q \"%s\"" % depotPath).read()) + gitStream.write("data %s\n" % len(data)) + gitStream.write(data) gitStream.write("\n") fnum = fnum + 1 |