Skip to content

Commit

Permalink
git-p4: Optimize the fetching of data from perforce.
Browse files Browse the repository at this point in the history
 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>
  • Loading branch information
Marius Storm-Olsen authored and Simon Hausmann committed Mar 13, 2008
1 parent a6828f5 commit 8ff45f2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions contrib/fast-import/git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -882,21 +882,21 @@ class P4Sync(Command):
while j < len(filedata):
stat = filedata[j]
j += 1
text = ''
text = [];
while j < len(filedata) and filedata[j]['code'] in ('text', 'unicode', 'binary'):
tmp = filedata[j]['data']
if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
tmp = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', tmp)
elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
tmp = re.sub(r'(?i)\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', tmp)
text += tmp
text.append(filedata[j]['data'])
j += 1

text = ''.join(text)

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

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

contents[stat['depotFile']] = text

for f in filesForCommit:
Expand Down

0 comments on commit 8ff45f2

Please sign in to comment.