summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorLibravatar Simon Hausmann <shausman@trolltech.com>2007-05-18 22:13:26 +0200
committerLibravatar Simon Hausmann <shausman@trolltech.com>2007-05-18 22:13:26 +0200
commit8f9b2e082b54787676bdad793ca013ba4fb4e407 (patch)
tree0b56fa53c331fc565fb90a9327e5014ab6cb3af3 /contrib
parentStarted rewriting the branch detection, based on "p4 branches" and "p4 branch... (diff)
downloadtgif-8f9b2e082b54787676bdad793ca013ba4fb4e407.tar.xz
Give branches a nice project prefix and don't bail out on clone if we failed
to detect the master branch. Signed-off-by: Simon Hausmann <shausman@trolltech.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/fast-import/git-p421
1 files changed, 18 insertions, 3 deletions
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index e993d3f693..7d42739637 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -729,6 +729,7 @@ class P4Sync(Command):
if self.detectBranches:
self.getBranchMapping();
+ self.branchPrefix = self.depotPath[self.depotPath[:-1].rfind("/") + 1:]
self.tz = "%+03d%02d" % (- time.timezone / 3600, ((- time.timezone % 3600) / 60))
@@ -815,12 +816,23 @@ class P4Sync(Command):
filesForCommit = self.extractFilesInCommitToBranch(files, branch)
- if branch not in self.createdBranches :
+ if branch not in self.createdBranches:
self.createdBranches.add(branch)
parent = self.knownBranches[branch]
if parent == branch:
parent = ""
+ # main branch? use master
+ if branch == "main":
+ branch = "master"
+ else:
+ branch = self.branchPrefix + branch
+
+ if parent == "main":
+ parent = "master"
+ elif len(parent) > 0:
+ parent = self.branchPrefix + parent
+
branch = "refs/remotes/p4/" + branch
if len(parent) > 0:
parent = "refs/remotes/p4/" + parent
@@ -906,8 +918,11 @@ class P4Clone(P4Sync):
if not P4Sync.run(self, [depotPath]):
return False
if self.branch != "master":
- system("git branch master p4")
- system("git checkout -f")
+ if gitBranchExists("refs/remotes/p4/master"):
+ system("git branch master refs/remotes/p4/master")
+ system("git checkout -f")
+ else:
+ print "Could not detect main branch. No checkout/master branch created."
return True
class HelpFormatter(optparse.IndentedHelpFormatter):