git-p4: Allow filtering Perforce branches by user

All branches in the Perforce server are downloaded to allow branch detection. If you have a centralized server on a remote location and there is a big number of branches this operation can take some time. This patch adds the configuration option git-p4.branchUser to allow filtering the branch list by user. Although this limits the branch maintenance in Perforce to be done by a single user, it might be an advantage when the number of branches being used in a specific depot is very small when compared with the branches available in the server. Signed-off-by: Vitor Antunes <vitor.hda@gmail.com> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Vitor Antunes committed Aug 19, 2011 at 00:44 UTC 8ace74c00e87cbb16d7303761ff4f6b91505ee20
2 files changed +13 -1
contrib/fast-import/git-p4
+7 -1
@@ -1455,7 +1455,13 @@ class P4Sync(Command, P4UserMap):
1455 def getBranchMapping(self):
1456 lostAndFoundBranches = set()
1457
1458 - for info in p4CmdList("branches"):
1458 + user = gitConfig("git-p4.branchUser")
1459 + if len(user) > 0:
1460 + command = "branches -u %s" % user
1461 + else:
1462 + command = "branches"
1463 +
1464 + for info in p4CmdList(command):
1465 details = p4Cmd("branch -o %s" % info["branch"])
1466 viewIdx = 0
1467 while details.has_key("View%s" % viewIdx):
contrib/fast-import/git-p4.txt
+6
@@ -257,6 +257,12 @@ Perforce server. Will enable --find-copies-harder git argument.
257
258 git config [--global] git-p4.detectCopies true
259
260 +git-p4.branchUser
261 +
262 +Only use branch specifications defined by the selected username.
263 +
264 + git config [--global] git-p4.branchUser username
265 +
266 Implementation Details...
267 =========================
268