More cleanups and speedups for labels and branches
Signed-off-by: Simon Hausmann <shausman@trolltech.com>
Simon Hausmann committed
May 19, 2007 at 11:54 UTC
71b112d4a4e070170af7b5a50647f7dac9b48e56
1 file changed
+29
-10
contrib/fast-import/git-p4
+29
-10
@@ -461,17 +461,32 @@ class P4Sync(Command):
461
fnum = fnum + 1
462
return files
463
464
- def splitFilesIntoBranches(self, files):
464
+ def splitFilesIntoBranches(self, commit):
465
branches = {}
466
467
- for file in files:
468
- path = file["path"][len(self.depotPath):]
467
+ fnum = 0
468
+ while commit.has_key("depotFile%s" % fnum):
469
+ path = commit["depotFile%s" % fnum]
470
+ if not path.startswith(self.depotPath):
471
+ # if not self.silent:
472
+ # print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, self.depotPath, change)
473
+ fnum = fnum + 1
474
+ continue
475
+
476
+ file = {}
477
+ file["path"] = path
478
+ file["rev"] = commit["rev%s" % fnum]
479
+ file["action"] = commit["action%s" % fnum]
480
+ file["type"] = commit["type%s" % fnum]
481
+ fnum = fnum + 1
482
+
483
+ relPath = path[len(self.depotPath):]
484
485
for branch in self.knownBranches.keys():
471
- if path.startswith(branch):
486
+ if relPath.startswith(branch):
487
if branch not in branches:
488
branches[branch] = []
474
- branches[branch].append(file["path"])
489
+ branches[branch].append(file)
490
491
return branches
492
@@ -542,6 +557,8 @@ class P4Sync(Command):
557
label = self.labels[change]
558
labelDetails = label[0]
559
labelRevisions = label[1]
560
+ if self.verbose:
561
+ print "Change %s is labelled %s" % (change, labelDetails)
562
563
files = p4CmdList("files %s...@%s" % (branchPrefix, change))
564
@@ -595,13 +612,15 @@ class P4Sync(Command):
612
label = output["label"]
613
revisions = {}
614
newestChange = 0
598
- for file in p4CmdList("files //...@%s" % label):
615
+ if self.verbose:
616
+ print "Querying files for label %s" % label
617
+ for file in p4CmdList("files %s...@%s" % (self.depotPath, label)):
618
revisions[file["depotFile"]] = file["rev"]
619
change = int(file["change"])
620
if change > newestChange:
621
newestChange = change
622
604
- self.labels[newestChange] = [output, revisions]
623
+ self.labels[int(newestChange)] = [output, revisions]
624
625
def getBranchMapping(self):
626
self.projectName = self.depotPath[self.depotPath[:-1].rfind("/") + 1:]
@@ -846,9 +865,8 @@ class P4Sync(Command):
865
cnt = cnt + 1
866
867
try:
849
- files = self.extractFilesFromCommit(description)
868
if self.detectBranches:
851
- branches = self.splitFilesIntoBranches(files)
869
+ branches = self.splitFilesIntoBranches(description)
870
for branch in branches.keys():
871
branchPrefix = self.depotPath + branch + "/"
872
@@ -889,8 +907,9 @@ class P4Sync(Command):
907
parent = self.initialParents[branch]
908
del self.initialParents[branch]
909
892
- self.commit(description, files, branch, branchPrefix, parent)
910
+ self.commit(description, filesForCommit, branch, branchPrefix, parent)
911
else:
912
+ files = self.extractFilesFromCommit(description)
913
self.commit(description, files, self.branch, self.depotPath, self.initialParent)
914
self.initialParent = ""
915
except IOError: