Fix creating the remotes/p4 branches based on origin/* for the multi-branch import
Signed-off-by: Simon Hausmann <simon@lst.de>
Simon Hausmann committed
May 24, 2007 at 21:23 UTC
d1874ed33bc346dca8b86891757703c908634aad
1 file changed
+19
-9
contrib/fast-import/git-p4
+19
-9
@@ -795,6 +795,20 @@ class P4Sync(Command):
795
self.p4BranchesInGit.append(branch)
796
self.initialParents[self.refPrefix + branch] = parseRevision(line[:-1])
797
798
+ def createBranchesFromOrigin(self):
799
+ if not self.silent:
800
+ print "Creating branch(es) in %s based on origin branch(es)" % self.refPrefix
801
+
802
+ for line in mypopen("git rev-parse --symbolic --remotes"):
803
+ if (not line.startswith("origin/")) or line.endswith("HEAD\n"):
804
+ continue
805
+ headName = line[len("origin/"):-1]
806
+ remoteHead = self.refPrefix + headName
807
+ if not os.path.exists(gitdir + "/" + remoteHead):
808
+ if self.verbose:
809
+ print "creating %s" % remoteHead
810
+ system("git update-ref %s origin/%s" % (remoteHead, headName))
811
+
812
def run(self, args):
813
self.depotPath = ""
814
self.changeRange = ""
@@ -841,18 +855,14 @@ class P4Sync(Command):
855
self.listExistingP4GitBranches()
856
if len(self.p4BranchesInGit) > 1:
857
if not self.silent:
844
- print "Importing from/into multiple branches"
858
+ print "Importing from/into multiple branches"
859
self.detectBranches = True
860
861
if len(args) == 0:
848
- if not gitBranchExists(self.branch) and gitBranchExists("origin") and not self.detectBranches:
849
- ### needs to be ported to multi branch import
850
- if not self.silent:
851
- print "Creating %s branch in git repository based on origin" % self.branch
852
- branch = self.branch
853
- if not branch.startswith("refs"):
854
- branch = "refs/heads/" + branch
855
- system("git update-ref %s origin" % branch)
862
+ if len(self.p4BranchesInGit) == 0:
863
+ self.createBranchesFromOrigin()
864
+ self.listExistingP4GitBranches()
865
+ return True
866
867
if self.verbose:
868
print "branches: %s" % self.p4BranchesInGit