Skip to content

Commit 2c8037e

Browse files
Pete Wyckoffgitster
authored andcommitted
git p4: add comments to p4BranchesInGit
Signed-off-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 991a2de commit 2c8037e

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

git-p4.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -547,27 +547,36 @@ def gitConfigList(key):
547547
_gitConfig[key] = read_pipe("git config --get-all %s" % key, ignore_error=True).strip().split(os.linesep)
548548
return _gitConfig[key]
549549

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+
551557
branches = {}
552558

553559
cmdline = "git rev-parse --symbolic "
554560
if branchesAreInRemotes:
555-
cmdline += " --remotes"
561+
cmdline += "--remotes"
556562
else:
557-
cmdline += " --branches"
563+
cmdline += "--branches"
558564

559565
for line in read_pipe_lines(cmdline):
560566
line = line.strip()
561567

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":
564573
continue
565-
branch = line
566574

567-
# strip off p4
568-
branch = re.sub ("^p4/", "", line)
575+
# strip off p4/ prefix
576+
branch = line[len("p4/"):]
569577

570578
branches[branch] = parseRevision(line)
579+
571580
return branches
572581

573582
def findUpstreamBranchPoint(head = "HEAD"):

0 commit comments

Comments
 (0)