diff options
| author | Mike Frysinger <vapier@google.com> | 2016-04-04 17:31:32 -0400 |
|---|---|---|
| committer | Mike Frysinger <vapier@google.com> | 2016-09-14 00:16:37 -0400 |
| commit | 163a3be18b92b9deb0a99795fab7b6ca819f1ecc (patch) | |
| tree | 947ff65483b92eddda1563fc1e46810ee31bf05a /subcmds | |
| parent | 7a77c16d376f504bd06d017ba10c91e3a6073b08 (diff) | |
| download | git-repo-163a3be18b92b9deb0a99795fab7b6ca819f1ecc.tar.gz | |
upload: short circuit when nothing is pending
When nothing is pending, most of this code is already short-circuited.
Hoist the single check up to make this more obvious/slightly faster.
Change-Id: Iec3a7e08eacd23a7c5f964900d5776bf5252c804
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/upload.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py index 4b05f1e8..1172dadc 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -454,7 +454,11 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 454 | if avail: | 454 | if avail: |
| 455 | pending.append((project, avail)) | 455 | pending.append((project, avail)) |
| 456 | 456 | ||
| 457 | if pending and (not opt.bypass_hooks): | 457 | if not pending: |
| 458 | print("no branches ready for upload", file=sys.stderr) | ||
| 459 | return | ||
| 460 | |||
| 461 | if not opt.bypass_hooks: | ||
| 458 | hook = RepoHook('pre-upload', self.manifest.repo_hooks_project, | 462 | hook = RepoHook('pre-upload', self.manifest.repo_hooks_project, |
| 459 | self.manifest.topdir, | 463 | self.manifest.topdir, |
| 460 | self.manifest.manifestProject.GetRemote('origin').url, | 464 | self.manifest.manifestProject.GetRemote('origin').url, |
| @@ -474,9 +478,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 474 | cc = _SplitEmails(opt.cc) | 478 | cc = _SplitEmails(opt.cc) |
| 475 | people = (reviewers, cc) | 479 | people = (reviewers, cc) |
| 476 | 480 | ||
| 477 | if not pending: | 481 | if len(pending) == 1 and len(pending[0][1]) == 1: |
| 478 | print("no branches ready for upload", file=sys.stderr) | ||
| 479 | elif len(pending) == 1 and len(pending[0][1]) == 1: | ||
| 480 | self._SingleBranch(opt, pending[0][1][0], people) | 482 | self._SingleBranch(opt, pending[0][1][0], people) |
| 481 | else: | 483 | else: |
| 482 | self._MultipleBranches(opt, pending, people) | 484 | self._MultipleBranches(opt, pending, people) |
