Code

Permit calling p4-fast-export with a depot path that has the typical ... wildcard...
[git.git] / contrib / fast-import / p4-fast-export.py
index 45d5157961f0e094586ca0da319e4f0f0eb7f726..72e01224bf3d75e697479a59b4c2a7d50bab1c81 100644 (file)
@@ -35,6 +35,9 @@ try:
 except ValueError:
     changeRange = ""
 
+if prefix.endswith("..."):
+    prefix = prefix[:-3]
+
 if not prefix.endswith("/"):
     prefix += "/"
 
@@ -57,9 +60,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 +121,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