git-p4: Support purged files and optimize memory usage
Purged files are handled as if they are merely deleted, which is not entirely optimal, but I don't know of any other way to handle them. File data is deleted from memory as early as they can, and they are more efficiently handled, at (significant) cost to CPU usage. Still need to handle p4 branches with spaces in their names. Still need to make git-p4 clone more reliable. - Perhaps with a --continue option. (Sometimes the p4 server kills the connection) Signed-off-by: John Chapman <thestar@fussycoder.id.au> Acked-by: Simon Hausmann <simon@lst.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
John Chapman committed
Nov 8, 2008 at 14:22 UTC
7f96e2e25aa008556a4ede7a65de8488eb9890e6
1 file changed
+7
-7
contrib/fast-import/git-p4
+7
-7
@@ -946,7 +946,7 @@ class P4Sync(Command):
946
947
if includeFile:
948
filesForCommit.append(f)
949
- if f['action'] != 'delete':
949
+ if f['action'] not in ('delete', 'purge'):
950
filesToRead.append(f)
951
952
filedata = []
@@ -965,11 +965,11 @@ class P4Sync(Command):
965
while j < len(filedata):
966
stat = filedata[j]
967
j += 1
968
- text = [];
968
+ text = ''
969
while j < len(filedata) and filedata[j]['code'] in ('text', 'unicode', 'binary'):
970
- text.append(filedata[j]['data'])
970
+ text += filedata[j]['data']
971
+ del filedata[j]['data']
972
j += 1
972
- text = ''.join(text)
973
974
if not stat.has_key('depotFile'):
975
sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
@@ -1038,7 +1038,7 @@ class P4Sync(Command):
1038
continue
1039
1040
relPath = self.stripRepoPath(file['path'], branchPrefixes)
1041
- if file["action"] == "delete":
1041
+ if file["action"] in ("delete", "purge"):
1042
self.gitStream.write("D %s\n" % relPath)
1043
else:
1044
data = file['data']
@@ -1077,7 +1077,7 @@ class P4Sync(Command):
1077
1078
cleanedFiles = {}
1079
for info in files:
1080
- if info["action"] == "delete":
1080
+ if info["action"] in ("delete", "purge"):
1081
continue
1082
cleanedFiles[info["depotFile"]] = info["rev"]
1083
@@ -1400,7 +1400,7 @@ class P4Sync(Command):
1400
if change > newestRevision:
1401
newestRevision = change
1402
1403
- if info["action"] == "delete":
1403
+ if info["action"] in ("delete", "purge"):
1404
# don't increase the file cnt, otherwise details["depotFile123"] will have gaps!
1405
#fileCnt = fileCnt + 1
1406
continue