Skip to content

Commit 8ff45f2

Browse files
Marius Storm-Olsentronical
authored andcommitted
git-p4: Optimize the fetching of data from perforce.
Use shallow copies in loop, and join content at the end. Then do the substitution, if needed. Signed-off-by: Marius Storm-Olsen <marius@trolltech.com> Signed-off-by: Simon Hausmann <simon@lst.de>
1 parent a6828f5 commit 8ff45f2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

contrib/fast-import/git-p4

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -882,21 +882,21 @@ class P4Sync(Command):
882882
while j < len(filedata):
883883
stat = filedata[j]
884884
j += 1
885-
text = ''
885+
text = [];
886886
while j < len(filedata) and filedata[j]['code'] in ('text', 'unicode', 'binary'):
887-
tmp = filedata[j]['data']
888-
if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
889-
tmp = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', tmp)
890-
elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
891-
tmp = re.sub(r'(?i)\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', tmp)
892-
text += tmp
887+
text.append(filedata[j]['data'])
893888
j += 1
894-
889+
text = ''.join(text)
895890

896891
if not stat.has_key('depotFile'):
897892
sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
898893
continue
899894

895+
if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
896+
text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
897+
elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
898+
text = re.sub(r'(?i)\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
899+
900900
contents[stat['depotFile']] = text
901901

902902
for f in filesForCommit:

0 commit comments

Comments
 (0)