diff options
author | Simon Hausmann <simon@lst.de> | 2007-11-15 10:38:45 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-11-16 01:32:59 -0800 |
commit | 38f9f5ec41803558b4ccefc9db08fac5696aff8d (patch) | |
tree | f64723cc7b9d0eb495968542cb6a6bb9f878be37 /contrib/fast-import | |
parent | 41a7aa588f449d3b139480b102f510abc5ef7f85 (diff) | |
download | git-38f9f5ec41803558b4ccefc9db08fac5696aff8d.tar.gz |
git-p4: Fix direct import from perforce after fetching changes through git from origin
When using an existing git repository to cache the perforce import we don't
fetch the branch mapping from perforce as that is a slow operation. However
the origin repository may not be fully up-to-date and therefore it may be
necessary to import more changes directly from Perforce.
Such a direct import needs self.knownBranches to be set up though, so
initialize it from the existing p4/* git branches.
Signed-off-by: Simon Hausmann <simon@lst.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/fast-import')
-rwxr-xr-x | contrib/fast-import/git-p4 | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4 index c148b5ab7d..c869bb8864 100755 --- a/contrib/fast-import/git-p4 +++ b/contrib/fast-import/git-p4 @@ -1207,6 +1207,15 @@ class P4Sync(Command): for branch in lostAndFoundBranches: self.knownBranches[branch] = branch + def getBranchMappingFromGitBranches(self): + branches = p4BranchesInGit(self.importIntoRemotes) + for branch in branches.keys(): + if branch == "master": + branch = "main" + else: + branch = branch[len(self.projectName):] + self.knownBranches[branch] = branch + def listExistingP4GitBranches(self): # branches holds mapping from name to commit branches = p4BranchesInGit(self.importIntoRemotes) @@ -1541,8 +1550,10 @@ class P4Sync(Command): ## FIXME - what's a P4 projectName ? self.projectName = self.guessProjectName() - if not self.hasOrigin: - self.getBranchMapping(); + if self.hasOrigin: + self.getBranchMappingFromGitBranches() + else: + self.getBranchMapping() if self.verbose: print "p4-git branches: %s" % self.p4BranchesInGit print "initial parents: %s" % self.initialParents |