git-p4: Fix upstream branch detection for submit/rebase with multiple branches.
Don't use git name-rev to locate the upstream git-p4 branch for rebase and submit but instead locate the branch by comparing the depot paths. name-rev may produce results like wrongbranch~12 as it uses the first match. Signed-off-by: Simon Hausmann <simon@lst.de> Signed-off-by: Marius Storm-Olsen <marius@trolltech.com>
This commit is contained in:
parent
062410bb9d
commit
86506fe54c
@ -205,26 +205,31 @@ def p4BranchesInGit(branchesAreInRemotes = True):
|
|||||||
return branches
|
return branches
|
||||||
|
|
||||||
def findUpstreamBranchPoint(head = "HEAD"):
|
def findUpstreamBranchPoint(head = "HEAD"):
|
||||||
|
branches = p4BranchesInGit()
|
||||||
|
# map from depot-path to branch name
|
||||||
|
branchByDepotPath = {}
|
||||||
|
for branch in branches.keys():
|
||||||
|
tip = branches[branch]
|
||||||
|
log = extractLogMessageFromGitCommit(tip)
|
||||||
|
settings = extractSettingsGitLog(log)
|
||||||
|
if settings.has_key("depot-paths"):
|
||||||
|
paths = ",".join(settings["depot-paths"])
|
||||||
|
branchByDepotPath[paths] = "remotes/p4/" + branch
|
||||||
|
|
||||||
settings = None
|
settings = None
|
||||||
branchPoint = ""
|
|
||||||
parent = 0
|
parent = 0
|
||||||
while parent < 65535:
|
while parent < 65535:
|
||||||
commit = head + "~%s" % parent
|
commit = head + "~%s" % parent
|
||||||
log = extractLogMessageFromGitCommit(commit)
|
log = extractLogMessageFromGitCommit(commit)
|
||||||
settings = extractSettingsGitLog(log)
|
settings = extractSettingsGitLog(log)
|
||||||
if not settings.has_key("depot-paths"):
|
if settings.has_key("depot-paths"):
|
||||||
parent = parent + 1
|
paths = ",".join(settings["depot-paths"])
|
||||||
continue
|
if branchByDepotPath.has_key(paths):
|
||||||
|
return [branchByDepotPath[paths], settings]
|
||||||
|
|
||||||
names = read_pipe_lines("git name-rev \"--refs=refs/remotes/p4/*\" \"%s\"" % commit)
|
parent = parent + 1
|
||||||
if len(names) <= 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# strip away the beginning of 'HEAD~42 refs/remotes/p4/foo'
|
return ["", settings]
|
||||||
branchPoint = names[0].strip()[len(commit) + 1:]
|
|
||||||
break
|
|
||||||
|
|
||||||
return [branchPoint, settings]
|
|
||||||
|
|
||||||
class Command:
|
class Command:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user