upload: track projects by path, rather than name

Since the same project can be checked out in multiple paths, we need to
track the "to be uploaded" projects by path, rather than project name.

Bug: crbug.com/gerrit/16260
Test: manual
Change-Id: Ic3dc81bb8acb34886baa6299e90a49c7ba372957
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/351054
Reviewed-by: Xin Li <delphij@google.com>
Tested-by: LaMont Jones <lamontjones@google.com>
This commit is contained in:
LaMont Jones 2022-11-08 23:10:27 +00:00
parent 47020ba249
commit b240d28bc0

View File

@ -278,8 +278,9 @@ Gerrit Code Review: https://www.gerritcodereview.com/
script = [] script = []
script.append('# Uncomment the branches to upload:') script.append('# Uncomment the branches to upload:')
for project, avail in pending: for project, avail in pending:
project_path = project.RelPath(local=opt.this_manifest_only)
script.append('#') script.append('#')
script.append('# project %s/:' % project.RelPath(local=opt.this_manifest_only)) script.append(f'# project {project_path}/:')
b = {} b = {}
for branch in avail: for branch in avail:
@ -302,8 +303,8 @@ Gerrit Code Review: https://www.gerritcodereview.com/
script.append('# %s' % commit) script.append('# %s' % commit)
b[name] = branch b[name] = branch
projects[project.RelPath(local=opt.this_manifest_only)] = project projects[project_path] = project
branches[project.name] = b branches[project_path] = b
script.append('') script.append('')
script = Editor.EditString("\n".join(script)).split("\n") script = Editor.EditString("\n".join(script)).split("\n")
@ -328,9 +329,10 @@ Gerrit Code Review: https://www.gerritcodereview.com/
name = m.group(1) name = m.group(1)
if not project: if not project:
_die('project for branch %s not in script', name) _die('project for branch %s not in script', name)
branch = branches[project.name].get(name) project_path = project.RelPath(local=opt.this_manifest_only)
branch = branches[project_path].get(name)
if not branch: if not branch:
_die('branch %s not in %s', name, project.RelPath(local=opt.this_manifest_only)) _die('branch %s not in %s', name, project_path)
todo.append(branch) todo.append(branch)
if not todo: if not todo:
_die("nothing uncommented for upload") _die("nothing uncommented for upload")