summaryrefslogtreecommitdiffstats
path: root/subcmds/upload.py
diff options
context:
space:
mode:
authorLaMont Jones <lamontjones@google.com>2021-11-18 22:40:18 +0000
committerLaMont Jones <lamontjones@google.com>2022-02-17 21:57:55 +0000
commitcc879a97c3e2614d19b15b4661c3cab4d33139c9 (patch)
tree69d225e9f0e9d79fec8f423d9c40c275f0bf3b8c /subcmds/upload.py
parent87cce68b28c34fa86895baa8d7f48307382e6c75 (diff)
downloadgit-repo-cc879a97c3e2614d19b15b4661c3cab4d33139c9.tar.gz
Add multi-manifest support with <submanifest> elementv2.22
To be addressed in another change: - a partial `repo sync` (with a list of projects/paths to sync) requires `--this-tree-only`. Change-Id: I6c7400bf001540e9d7694fa70934f8f204cb5f57 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/322657 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/upload.py')
-rw-r--r--subcmds/upload.py44
1 files changed, 27 insertions, 17 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py
index c48deab6..ef3d8e9d 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -226,7 +226,8 @@ Gerrit Code Review: https://www.gerritcodereview.com/
226 226
227 destination = opt.dest_branch or project.dest_branch or project.revisionExpr 227 destination = opt.dest_branch or project.dest_branch or project.revisionExpr
228 print('Upload project %s/ to remote branch %s%s:' % 228 print('Upload project %s/ to remote branch %s%s:' %
229 (project.relpath, destination, ' (private)' if opt.private else '')) 229 (project.RelPath(local=opt.this_manifest_only), destination,
230 ' (private)' if opt.private else ''))
230 print(' branch %s (%2d commit%s, %s):' % ( 231 print(' branch %s (%2d commit%s, %s):' % (
231 name, 232 name,
232 len(commit_list), 233 len(commit_list),
@@ -262,7 +263,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
262 script.append('# Uncomment the branches to upload:') 263 script.append('# Uncomment the branches to upload:')
263 for project, avail in pending: 264 for project, avail in pending:
264 script.append('#') 265 script.append('#')
265 script.append('# project %s/:' % project.relpath) 266 script.append('# project %s/:' % project.RelPath(local=opt.this_manifest_only))
266 267
267 b = {} 268 b = {}
268 for branch in avail: 269 for branch in avail:
@@ -285,7 +286,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
285 script.append('# %s' % commit) 286 script.append('# %s' % commit)
286 b[name] = branch 287 b[name] = branch
287 288
288 projects[project.relpath] = project 289 projects[project.RelPath(local=opt.this_manifest_only)] = project
289 branches[project.name] = b 290 branches[project.name] = b
290 script.append('') 291 script.append('')
291 292
@@ -313,7 +314,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
313 _die('project for branch %s not in script', name) 314 _die('project for branch %s not in script', name)
314 branch = branches[project.name].get(name) 315 branch = branches[project.name].get(name)
315 if not branch: 316 if not branch:
316 _die('branch %s not in %s', name, project.relpath) 317 _die('branch %s not in %s', name, project.RelPath(local=opt.this_manifest_only))
317 todo.append(branch) 318 todo.append(branch)
318 if not todo: 319 if not todo:
319 _die("nothing uncommented for upload") 320 _die("nothing uncommented for upload")
@@ -481,7 +482,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
481 else: 482 else:
482 fmt = '\n (%s)' 483 fmt = '\n (%s)'
483 print(('[FAILED] %-15s %-15s' + fmt) % ( 484 print(('[FAILED] %-15s %-15s' + fmt) % (
484 branch.project.relpath + '/', 485 branch.project.RelPath(local=opt.this_manifest_only) + '/',
485 branch.name, 486 branch.name,
486 str(branch.error)), 487 str(branch.error)),
487 file=sys.stderr) 488 file=sys.stderr)
@@ -490,7 +491,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
490 for branch in todo: 491 for branch in todo:
491 if branch.uploaded: 492 if branch.uploaded:
492 print('[OK ] %-15s %s' % ( 493 print('[OK ] %-15s %s' % (
493 branch.project.relpath + '/', 494 branch.project.RelPath(local=opt.this_manifest_only) + '/',
494 branch.name), 495 branch.name),
495 file=sys.stderr) 496 file=sys.stderr)
496 497
@@ -524,7 +525,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
524 return (project, avail) 525 return (project, avail)
525 526
526 def Execute(self, opt, args): 527 def Execute(self, opt, args):
527 projects = self.GetProjects(args) 528 projects = self.GetProjects(args, all_manifests=not opt.this_manifest_only)
528 529
529 def _ProcessResults(_pool, _out, results): 530 def _ProcessResults(_pool, _out, results):
530 pending = [] 531 pending = []
@@ -534,7 +535,8 @@ Gerrit Code Review: https://www.gerritcodereview.com/
534 print('repo: error: %s: Unable to upload branch "%s". ' 535 print('repo: error: %s: Unable to upload branch "%s". '
535 'You might be able to fix the branch by running:\n' 536 'You might be able to fix the branch by running:\n'
536 ' git branch --set-upstream-to m/%s' % 537 ' git branch --set-upstream-to m/%s' %
537 (project.relpath, project.CurrentBranch, self.manifest.branch), 538 (project.RelPath(local=opt.this_manifest_only), project.CurrentBranch,
539 project.manifest.branch),
538 file=sys.stderr) 540 file=sys.stderr)
539 elif avail: 541 elif avail:
540 pending.append(result) 542 pending.append(result)
@@ -554,15 +556,23 @@ Gerrit Code Review: https://www.gerritcodereview.com/
554 (opt.branch,), file=sys.stderr) 556 (opt.branch,), file=sys.stderr)
555 return 1 557 return 1
556 558
557 pending_proj_names = [project.name for (project, available) in pending] 559 manifests = {project.manifest.topdir: project.manifest
558 pending_worktrees = [project.worktree for (project, available) in pending] 560 for (project, available) in pending}
559 hook = RepoHook.FromSubcmd( 561 ret = 0
560 hook_type='pre-upload', manifest=self.manifest, 562 for manifest in manifests.values():
561 opt=opt, abort_if_user_denies=True) 563 pending_proj_names = [project.name for (project, available) in pending
562 if not hook.Run( 564 if project.manifest.topdir == manifest.topdir]
563 project_list=pending_proj_names, 565 pending_worktrees = [project.worktree for (project, available) in pending
564 worktree_list=pending_worktrees): 566 if project.manifest.topdir == manifest.topdir]
565 return 1 567 hook = RepoHook.FromSubcmd(
568 hook_type='pre-upload', manifest=manifest,
569 opt=opt, abort_if_user_denies=True)
570 if not hook.Run(
571 project_list=pending_proj_names,
572 worktree_list=pending_worktrees):
573 ret = 1
574 if ret:
575 return ret
566 576
567 reviewers = _SplitEmails(opt.reviewers) if opt.reviewers else [] 577 reviewers = _SplitEmails(opt.reviewers) if opt.reviewers else []
568 cc = _SplitEmails(opt.cc) if opt.cc else [] 578 cc = _SplitEmails(opt.cc) if opt.cc else []