aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorSimon Hausmann <simon@lst.de>2007-07-18 12:40:12 +0200
committerSimon Hausmann <simon@lst.de>2007-07-18 17:29:31 +0200
commit86506fe54c8e9e5f75a73956840497e3e5744f86 (patch)
tree1f5429d94161bb3b368f21282e78e578784cc6b8 /contrib
parent062410bb9d6553e6bc4f8fa7f0cab1ed63b75628 (diff)
downloadgit-86506fe54c8e9e5f75a73956840497e3e5744f86.tar.gz
git-86506fe54c8e9e5f75a73956840497e3e5744f86.tar.xz
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>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/fast-import/git-p429
1 files changed, 17 insertions, 12 deletions
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index d4a2f1431..a65f53a47 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -205,26 +205,31 @@ def p4BranchesInGit(branchesAreInRemotes = True):
return branches
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
- branchPoint = ""
parent = 0
while parent < 65535:
commit = head + "~%s" % parent
log = extractLogMessageFromGitCommit(commit)
settings = extractSettingsGitLog(log)
- if not settings.has_key("depot-paths"):
- parent = parent + 1
- continue
-
- names = read_pipe_lines("git name-rev \"--refs=refs/remotes/p4/*\" \"%s\"" % commit)
- if len(names) <= 0:
- continue
+ if settings.has_key("depot-paths"):
+ paths = ",".join(settings["depot-paths"])
+ if branchByDepotPath.has_key(paths):
+ return [branchByDepotPath[paths], settings]
- # strip away the beginning of 'HEAD~42 refs/remotes/p4/foo'
- branchPoint = names[0].strip()[len(commit) + 1:]
- break
+ parent = parent + 1
- return [branchPoint, settings]
+ return ["", settings]
class Command:
def __init__(self):