branches: Fix "not in" handling

If the branch is current, or present in less than half of the projects,
list which projects it is *in*.

Otherwise, correctly detect which projects (by relpath) it is not in.

Previously, the "not in" path would incorrectly list all projects.

Change-Id: Ia153856f577035a51f538b7bf5d3135b70c69d52
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328199
Tested-by: LaMont Jones <lamontjones@google.com>
Reviewed-by: Xin Li <delphij@google.com>
This commit is contained in:
LaMont Jones 2022-01-13 21:08:24 +00:00
parent 67d6cdf2bc
commit a535ae4418

View File

@ -151,7 +151,7 @@ is shown, then the branch appears in all projects.
fmt = out.write fmt = out.write
paths = [] paths = []
non_cur_paths = [] non_cur_paths = []
if i.IsSplitCurrent or (in_cnt < project_cnt - in_cnt): if i.IsSplitCurrent or (in_cnt <= project_cnt - in_cnt):
in_type = 'in' in_type = 'in'
for b in i.projects: for b in i.projects:
if not i.IsSplitCurrent or b.current: if not i.IsSplitCurrent or b.current:
@ -163,9 +163,9 @@ is shown, then the branch appears in all projects.
in_type = 'not in' in_type = 'not in'
have = set() have = set()
for b in i.projects: for b in i.projects:
have.add(b.project) have.add(b.project.relpath)
for p in projects: for p in projects:
if p not in have: if p.relpath not in have:
paths.append(p.relpath) paths.append(p.relpath)
s = ' %s %s' % (in_type, ', '.join(paths)) s = ' %s %s' % (in_type, ', '.join(paths))