Fix the branch mapping detection to be independent from the order of the "p4 branches" output.
Collect "unknown" source branches separately and register them at the end. Also added a minor speed up to splitFilesIntoBranches by breaking out of the loop through all branches when it's safe. Signed-off-by: Simon Hausmann <simon@lst.de>
Simon Hausmann committed
Jun 17, 2007 at 11:25 UTC
6555b2ccfe63913b3e5c8b02e117f0f476307ca2
1 file changed
+13
-3
contrib/fast-import/git-p4
+13
-3
@@ -700,6 +700,7 @@ class P4Sync(Command):
700
if branch not in branches:
701
branches[branch] = []
702
branches[branch].append(file)
703
+ break
704
705
return branches
706
@@ -938,6 +939,8 @@ class P4Sync(Command):
939
return p
940
941
def getBranchMapping(self):
942
+ lostAndFoundBranches = set()
943
+
944
for info in p4CmdList("branches"):
945
details = p4Cmd("branch -o %s" % info["branch"])
946
viewIdx = 0
@@ -953,10 +956,17 @@ class P4Sync(Command):
956
if source.startswith(self.depotPaths[0]) and destination.startswith(self.depotPaths[0]):
957
source = source[len(self.depotPaths[0]):-4]
958
destination = destination[len(self.depotPaths[0]):-4]
956
- if destination not in self.knownBranches:
957
- self.knownBranches[destination] = source
959
+
960
+ self.knownBranches[destination] = source
961
+
962
+ lostAndFoundBranches.discard(destination)
963
+
964
if source not in self.knownBranches:
959
- self.knownBranches[source] = source
965
+ lostAndFoundBranches.add(source)
966
+
967
+
968
+ for branch in lostAndFoundBranches:
969
+ self.knownBranches[branch] = branch
970
971
def listExistingP4GitBranches(self):
972
self.p4BranchesInGit = []