Cleanup/speed up the branch<> file split and removed change range limitation that I added for debugging (oops).
Cleanup/speed up the branch<> file split and removed change range limitation that I added for debugging (oops). Signed-off-by: Simon Hausmann <shausman@trolltech.com>
Simon Hausmann committed
May 19, 2007 at 11:07 UTC
d5904674d1a52620a702b4f5efa1afe21f8a5947
1 file changed
+9
-17
contrib/fast-import/git-p4
+9
-17
@@ -461,15 +461,17 @@ class P4Sync(Command):
461
fnum = fnum + 1
462
return files
463
464
- def branchesForCommit(self, files):
465
- branches = Set()
464
+ def splitFilesIntoBranches(self, files):
465
+ branches = {}
466
467
for file in files:
468
path = file["path"][len(self.depotPath):]
469
470
for branch in self.knownBranches.keys():
471
if path.startswith(branch):
472
- branches.add(branch)
472
+ if branch not in branches:
473
+ branches[branch] = []
474
+ branches[branch].append(file["path"])
475
476
return branches
477
@@ -574,16 +576,6 @@ class P4Sync(Command):
576
if not self.silent:
577
print "Tag %s does not match with change %s: file count is different." % (labelDetails["label"], change)
578
577
- def extractFilesInCommitToBranch(self, files, branchPrefix):
578
- newFiles = []
579
-
580
- for file in files:
581
- path = file["path"]
582
- if path.startswith(branchPrefix):
583
- newFiles.append(file)
584
-
585
- return newFiles
586
-
579
def getUserMap(self):
580
self.users = {}
581
@@ -713,8 +705,7 @@ class P4Sync(Command):
705
706
if p4Change > 0:
707
self.depotPath = self.previousDepotPath
716
- #self.changeRange = "@%s,#head" % p4Change
717
- self.changeRange = "@%s,%s" % (p4Change, p4Change + 10)
708
+ self.changeRange = "@%s,#head" % p4Change
709
self.initialParent = parseRevision(self.branch)
710
if not self.silent:
711
print "Performing incremental import into %s git branch" % self.branch
@@ -857,12 +848,13 @@ class P4Sync(Command):
848
try:
849
files = self.extractFilesFromCommit(description)
850
if self.detectBranches:
860
- for branch in self.branchesForCommit(files):
851
+ branches = self.splitFilesIntoBranches(files)
852
+ for branch in branches.keys():
853
branchPrefix = self.depotPath + branch + "/"
854
855
parent = ""
856
865
- filesForCommit = self.extractFilesInCommitToBranch(files, branch)
857
+ filesForCommit = branches[branch]
858
859
if self.verbose:
860
print "branch is %s" % branch