Skip to content

Commit 8134f69

Browse files
committed
git-p4: Cleanup; moved the (duplicated) code for turning a branch into a git ref (for example foo -> refs/remotes/p4/<project>/foo) into a separate method.
Signed-off-by: Simon Hausmann <simon@lst.de>
1 parent c208a24 commit 8134f69

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

contrib/fast-import/git-p4

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,15 @@ class P4Sync(Command):
11181118
self.keepRepoPath = (d.has_key('options')
11191119
and ('keepRepoPath' in d['options']))
11201120

1121+
def gitRefForBranch(self, branch):
1122+
if branch == "main":
1123+
return self.refPrefix + "master"
1124+
1125+
if len(branch) <= 0:
1126+
return branch
1127+
1128+
return self.refPrefix + self.projectName + branch
1129+
11211130
def importChanges(self, changes):
11221131
cnt = 1
11231132
for change in changes:
@@ -1153,23 +1162,8 @@ class P4Sync(Command):
11531162
elif self.verbose:
11541163
print "parent determined through known branches: %s" % parent
11551164

1156-
# main branch? use master
1157-
if branch == "main":
1158-
branch = "master"
1159-
else:
1160-
1161-
## FIXME
1162-
branch = self.projectName + branch
1163-
1164-
if parent == "main":
1165-
parent = "master"
1166-
elif len(parent) > 0:
1167-
## FIXME
1168-
parent = self.projectName + parent
1169-
1170-
branch = self.refPrefix + branch
1171-
if len(parent) > 0:
1172-
parent = self.refPrefix + parent
1165+
branch = self.gitRefForBranch(branch)
1166+
parent = self.gitRefForBranch(parent)
11731167

11741168
if self.verbose:
11751169
print "looking for initial parent for %s; current parent is %s" % (branch, parent)

0 commit comments

Comments
 (0)