]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Merge branch 'sh/p4'
authorJunio C Hamano <gitster@pobox.com>
Mon, 19 Nov 2007 00:03:58 +0000 (16:03 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Nov 2007 00:03:58 +0000 (16:03 -0800)
* sh/p4:
  git-p4: Fix direct import from perforce after fetching changes through git from origin

contrib/fast-import/git-p4

index c148b5ab7d139ea64fa7836f95be542dbbf69a45..c869bb88643d67a7954db026ce9ebb50c0f89be0 100755 (executable)
@@ -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