Skip to content

Commit 7f96e2e

Browse files
arafangiongitster
authored andcommitted
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 <[email protected]> Acked-by: Simon Hausmann <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 42fc113 commit 7f96e2e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

contrib/fast-import/git-p4

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ class P4Sync(Command):
946946

947947
if includeFile:
948948
filesForCommit.append(f)
949-
if f['action'] != 'delete':
949+
if f['action'] not in ('delete', 'purge'):
950950
filesToRead.append(f)
951951

952952
filedata = []
@@ -965,11 +965,11 @@ class P4Sync(Command):
965965
while j < len(filedata):
966966
stat = filedata[j]
967967
j += 1
968-
text = [];
968+
text = ''
969969
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']
971972
j += 1
972-
text = ''.join(text)
973973

974974
if not stat.has_key('depotFile'):
975975
sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
@@ -1038,7 +1038,7 @@ class P4Sync(Command):
10381038
continue
10391039

10401040
relPath = self.stripRepoPath(file['path'], branchPrefixes)
1041-
if file["action"] == "delete":
1041+
if file["action"] in ("delete", "purge"):
10421042
self.gitStream.write("D %s\n" % relPath)
10431043
else:
10441044
data = file['data']
@@ -1077,7 +1077,7 @@ class P4Sync(Command):
10771077

10781078
cleanedFiles = {}
10791079
for info in files:
1080-
if info["action"] == "delete":
1080+
if info["action"] in ("delete", "purge"):
10811081
continue
10821082
cleanedFiles[info["depotFile"]] = info["rev"]
10831083

@@ -1400,7 +1400,7 @@ class P4Sync(Command):
14001400
if change > newestRevision:
14011401
newestRevision = change
14021402

1403-
if info["action"] == "delete":
1403+
if info["action"] in ("delete", "purge"):
14041404
# don't increase the file cnt, otherwise details["depotFile123"] will have gaps!
14051405
#fileCnt = fileCnt + 1
14061406
continue

0 commit comments

Comments
 (0)