Skip to content

Commit

Permalink
Fix the branch mapping detection to be independent from the order of …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
Simon Hausmann committed Jun 17, 2007
1 parent da4a660 commit 6555b2c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions contrib/fast-import/git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ class P4Sync(Command):
if branch not in branches:
branches[branch] = []
branches[branch].append(file)
break

return branches

Expand Down Expand Up @@ -938,6 +939,8 @@ class P4Sync(Command):
return p

def getBranchMapping(self):
lostAndFoundBranches = set()

for info in p4CmdList("branches"):
details = p4Cmd("branch -o %s" % info["branch"])
viewIdx = 0
Expand All @@ -953,10 +956,17 @@ class P4Sync(Command):
if source.startswith(self.depotPaths[0]) and destination.startswith(self.depotPaths[0]):
source = source[len(self.depotPaths[0]):-4]
destination = destination[len(self.depotPaths[0]):-4]
if destination not in self.knownBranches:
self.knownBranches[destination] = source

self.knownBranches[destination] = source

lostAndFoundBranches.discard(destination)

if source not in self.knownBranches:
self.knownBranches[source] = source
lostAndFoundBranches.add(source)


for branch in lostAndFoundBranches:
self.knownBranches[branch] = branch

def listExistingP4GitBranches(self):
self.p4BranchesInGit = []
Expand Down

0 comments on commit 6555b2c

Please sign in to comment.