avoid fstat for every file

This commit is contained in:
Simon Hausmann
2007-01-31 22:38:07 +01:00
parent 6a5b413aae
commit 555a9dd9d9

View File

@@ -57,9 +57,6 @@ def p4Cmd(cmd):
result.update(entry) result.update(entry)
return result; return result;
def p4FileSize(path):
return int(p4Cmd("fstat -Ol \"%s\"" % path)["fileSize"])
def getUserMap(): def getUserMap():
users = {} users = {}
@@ -121,14 +118,15 @@ for change in changes:
if action == "delete": if action == "delete":
gitStream.write("D %s\n" % relPath) gitStream.write("D %s\n" % relPath)
else: else:
fileSize = p4FileSize(depotPath)
mode = 644 mode = 644
if description["type%s" % fnum].startswith("x"): if description["type%s" % fnum].startswith("x"):
mode = 755 mode = 755
data = os.popen("p4 print -q \"%s\"" % depotPath, "rb").read()
gitStream.write("M %s inline %s\n" % (mode, relPath)) gitStream.write("M %s inline %s\n" % (mode, relPath))
gitStream.write("data %s\n" % fileSize) gitStream.write("data %s\n" % len(data))
gitStream.write(os.popen("p4 print -q \"%s\"" % depotPath).read()) gitStream.write(data)
gitStream.write("\n") gitStream.write("\n")
fnum = fnum + 1 fnum = fnum + 1