@matheusbsbs / matheus-bagliano / commits / 8ff45f2af5
Fork 0

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>

Marius Storm-Olsen committed Mar 3, 2008 at 13:42 UTC 8ff45f2af5b25b7581072ee7896f4285dfc034ea
1 file changed +8 -8
contrib/fast-import/git-p4
+8 -8
@@ -882,21 +882,21 @@ class P4Sync(Command):
882 while j < len(filedata):
883 stat = filedata[j]
884 j += 1
885 - text = ''
885 + text = [];
886 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'])
888 j += 1
894 -
889 + text = ''.join(text)
890
891 if not stat.has_key('depotFile'):
892 sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
893 continue
894
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 +
900 contents[stat['depotFile']] = text
901
902 for f in filesForCommit: