Skip to content

Commit 6555b2c

Browse files
committed
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 <[email protected]>
1 parent da4a660 commit 6555b2c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

contrib/fast-import/git-p4

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ class P4Sync(Command):
700700
if branch not in branches:
701701
branches[branch] = []
702702
branches[branch].append(file)
703+
break
703704

704705
return branches
705706

@@ -938,6 +939,8 @@ class P4Sync(Command):
938939
return p
939940

940941
def getBranchMapping(self):
942+
lostAndFoundBranches = set()
943+
941944
for info in p4CmdList("branches"):
942945
details = p4Cmd("branch -o %s" % info["branch"])
943946
viewIdx = 0
@@ -953,10 +956,17 @@ class P4Sync(Command):
953956
if source.startswith(self.depotPaths[0]) and destination.startswith(self.depotPaths[0]):
954957
source = source[len(self.depotPaths[0]):-4]
955958
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+
958964
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
960970

961971
def listExistingP4GitBranches(self):
962972
self.p4BranchesInGit = []

0 commit comments

Comments
 (0)