git p4: add comments to p4BranchesInGit

Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pete Wyckoff committed Jan 14, 2013 at 19:46 UTC 2c8037edeef9ae6f510335587c04081e58564758
1 file changed +17 -8
git-p4.py
+17 -8
@@ -547,27 +547,36 @@ def gitConfigList(key):
547 _gitConfig[key] = read_pipe("git config --get-all %s" % key, ignore_error=True).strip().split(os.linesep)
548 return _gitConfig[key]
549
550 -def p4BranchesInGit(branchesAreInRemotes = True):
550 +def p4BranchesInGit(branchesAreInRemotes=True):
551 + """Find all the branches whose names start with "p4/", looking
552 + in remotes or heads as specified by the argument. Return
553 + a dictionary of { branch: revision } for each one found.
554 + The branch names are the short names, without any
555 + "p4/" prefix."""
556 +
557 branches = {}
558
559 cmdline = "git rev-parse --symbolic "
560 if branchesAreInRemotes:
555 - cmdline += " --remotes"
561 + cmdline += "--remotes"
562 else:
557 - cmdline += " --branches"
563 + cmdline += "--branches"
564
565 for line in read_pipe_lines(cmdline):
566 line = line.strip()
567
562 - ## only import to p4/
563 - if not line.startswith('p4/') or line == "p4/HEAD":
568 + # only import to p4/
569 + if not line.startswith('p4/'):
570 + continue
571 + # special symbolic ref to p4/master
572 + if line == "p4/HEAD":
573 continue
565 - branch = line
574
567 - # strip off p4
568 - branch = re.sub ("^p4/", "", line)
575 + # strip off p4/ prefix
576 + branch = line[len("p4/"):]
577
578 branches[branch] = parseRevision(line)
579 +
580 return branches
581
582 def findUpstreamBranchPoint(head = "HEAD"):