The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2008 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Ben Komalo | 08a3f68 | 2010-07-15 16:03:02 -0700 | [diff] [blame] | 16 | import copy |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 17 | import re |
| 18 | import sys |
| 19 | |
| 20 | from command import InteractiveCommand |
| 21 | from editor import Editor |
| 22 | from error import UploadError |
| 23 | |
Dan Morrill | f0a9a1a | 2010-05-05 08:18:35 -0700 | [diff] [blame] | 24 | UNUSUAL_COMMIT_THRESHOLD = 5 |
Dan Morrill | 879a9a5 | 2010-05-04 16:56:07 -0700 | [diff] [blame] | 25 | |
| 26 | def _ConfirmManyUploads(multiple_branches=False): |
| 27 | if multiple_branches: |
| 28 | print "ATTENTION: One or more branches has an unusually high number of commits." |
| 29 | else: |
| 30 | print "ATTENTION: You are uploading an unusually high number of commits." |
| 31 | print "YOU PROBABLY DO NOT MEAN TO DO THIS. (Did you rebase across branches?)" |
| 32 | answer = raw_input("If you are sure you intend to do this, type 'yes': ").strip() |
| 33 | return answer == "yes" |
| 34 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 35 | def _die(fmt, *args): |
| 36 | msg = fmt % args |
| 37 | print >>sys.stderr, 'error: %s' % msg |
| 38 | sys.exit(1) |
| 39 | |
Joe Onorato | 2896a79 | 2008-11-17 16:56:36 -0500 | [diff] [blame] | 40 | def _SplitEmails(values): |
| 41 | result = [] |
| 42 | for str in values: |
| 43 | result.extend([s.strip() for s in str.split(',')]) |
| 44 | return result |
| 45 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 46 | class Upload(InteractiveCommand): |
| 47 | common = True |
| 48 | helpSummary = "Upload changes for code review" |
| 49 | helpUsage=""" |
Joe Onorato | 2896a79 | 2008-11-17 16:56:36 -0500 | [diff] [blame] | 50 | %prog [--re --cc] {[<project>]... | --replace <project>} |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 51 | """ |
| 52 | helpDescription = """ |
Shawn O. Pearce | 337fb9c | 2009-04-18 10:59:33 -0700 | [diff] [blame] | 53 | The '%prog' command is used to send changes to the Gerrit Code |
| 54 | Review system. It searches for topic branches in local projects |
| 55 | that have not yet been published for review. If multiple topic |
| 56 | branches are found, '%prog' opens an editor to allow the user to |
| 57 | select which branches to upload. |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 58 | |
Shawn O. Pearce | 337fb9c | 2009-04-18 10:59:33 -0700 | [diff] [blame] | 59 | '%prog' searches for uploadable changes in all projects listed at |
| 60 | the command line. Projects can be specified either by name, or by |
| 61 | a relative or absolute path to the project's local directory. If no |
| 62 | projects are specified, '%prog' will search for uploadable changes |
| 63 | in all projects listed in the manifest. |
Joe Onorato | 2896a79 | 2008-11-17 16:56:36 -0500 | [diff] [blame] | 64 | |
| 65 | If the --reviewers or --cc options are passed, those emails are |
| 66 | added to the respective list of users, and emails are sent to any |
Shawn O. Pearce | 337fb9c | 2009-04-18 10:59:33 -0700 | [diff] [blame] | 67 | new users. Users passed as --reviewers must already be registered |
Joe Onorato | 2896a79 | 2008-11-17 16:56:36 -0500 | [diff] [blame] | 68 | with the code review system, or the upload will fail. |
Shawn O. Pearce | a6df7d2 | 2008-12-12 08:04:07 -0800 | [diff] [blame] | 69 | |
| 70 | If the --replace option is passed the user can designate which |
| 71 | existing change(s) in Gerrit match up to the commits in the branch |
| 72 | being uploaded. For each matched pair of change,commit the commit |
| 73 | will be added as a new patch set, completely replacing the set of |
| 74 | files and description associated with the change in Gerrit. |
Shawn O. Pearce | a608fb0 | 2009-04-17 12:11:24 -0700 | [diff] [blame] | 75 | |
| 76 | Configuration |
| 77 | ------------- |
| 78 | |
| 79 | review.URL.autoupload: |
| 80 | |
| 81 | To disable the "Upload ... (y/n)?" prompt, you can set a per-project |
| 82 | or global Git configuration option. If review.URL.autoupload is set |
| 83 | to "true" then repo will assume you always answer "y" at the prompt, |
| 84 | and will not prompt you further. If it is set to "false" then repo |
| 85 | will assume you always answer "n", and will abort. |
| 86 | |
Ben Komalo | 08a3f68 | 2010-07-15 16:03:02 -0700 | [diff] [blame] | 87 | review.URL.autocopy: |
| 88 | |
| 89 | To automatically copy a user or mailing list to all uploaded reviews, |
| 90 | you can set a per-project or global Git option to do so. Specifically, |
| 91 | review.URL.autocopy can be set to a comma separated list of reviewers |
| 92 | who you always want copied on all uploads with a non-empty --re |
| 93 | argument. |
| 94 | |
Shawn O. Pearce | 3575b8f | 2010-07-15 17:00:14 -0700 | [diff] [blame] | 95 | review.URL.username: |
| 96 | |
| 97 | Override the username used to connect to Gerrit Code Review. |
| 98 | By default the local part of the email address is used. |
| 99 | |
Shawn O. Pearce | a608fb0 | 2009-04-17 12:11:24 -0700 | [diff] [blame] | 100 | The URL must match the review URL listed in the manifest XML file, |
| 101 | or in the .git/config within the project. For example: |
| 102 | |
| 103 | [remote "origin"] |
| 104 | url = git://git.example.com/project.git |
| 105 | review = http://review.example.com/ |
| 106 | |
| 107 | [review "http://review.example.com/"] |
| 108 | autoupload = true |
Ben Komalo | 08a3f68 | 2010-07-15 16:03:02 -0700 | [diff] [blame] | 109 | autocopy = johndoe@company.com,my-team-alias@company.com |
Shawn O. Pearce | a608fb0 | 2009-04-17 12:11:24 -0700 | [diff] [blame] | 110 | |
Shawn O. Pearce | 337fb9c | 2009-04-18 10:59:33 -0700 | [diff] [blame] | 111 | References |
| 112 | ---------- |
| 113 | |
| 114 | Gerrit Code Review: http://code.google.com/p/gerrit/ |
| 115 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 116 | """ |
| 117 | |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 118 | def _Options(self, p): |
Shawn O. Pearce | a5ece0e | 2010-07-15 16:52:42 -0700 | [diff] [blame] | 119 | p.add_option('-t', |
| 120 | dest='auto_topic', action='store_true', |
| 121 | help='Send local branch name to Gerrit Code Review') |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 122 | p.add_option('--replace', |
| 123 | dest='replace', action='store_true', |
| 124 | help='Upload replacement patchesets from this branch') |
Joe Onorato | 2896a79 | 2008-11-17 16:56:36 -0500 | [diff] [blame] | 125 | p.add_option('--re', '--reviewers', |
| 126 | type='string', action='append', dest='reviewers', |
| 127 | help='Request reviews from these people.') |
| 128 | p.add_option('--cc', |
| 129 | type='string', action='append', dest='cc', |
| 130 | help='Also send email to these email addresses.') |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 131 | |
Shawn O. Pearce | a5ece0e | 2010-07-15 16:52:42 -0700 | [diff] [blame] | 132 | def _SingleBranch(self, opt, branch, people): |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 133 | project = branch.project |
| 134 | name = branch.name |
Shawn O. Pearce | a608fb0 | 2009-04-17 12:11:24 -0700 | [diff] [blame] | 135 | remote = project.GetBranch(name).remote |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 136 | |
Shawn O. Pearce | a608fb0 | 2009-04-17 12:11:24 -0700 | [diff] [blame] | 137 | key = 'review.%s.autoupload' % remote.review |
| 138 | answer = project.config.GetBoolean(key) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 139 | |
Shawn O. Pearce | a608fb0 | 2009-04-17 12:11:24 -0700 | [diff] [blame] | 140 | if answer is False: |
| 141 | _die("upload blocked by %s = false" % key) |
| 142 | |
| 143 | if answer is None: |
Shawn O. Pearce | 66bdd46 | 2009-04-17 18:47:22 -0700 | [diff] [blame] | 144 | date = branch.date |
| 145 | list = branch.commits |
| 146 | |
Shawn O. Pearce | a608fb0 | 2009-04-17 12:11:24 -0700 | [diff] [blame] | 147 | print 'Upload project %s/:' % project.relpath |
| 148 | print ' branch %s (%2d commit%s, %s):' % ( |
| 149 | name, |
| 150 | len(list), |
| 151 | len(list) != 1 and 's' or '', |
| 152 | date) |
| 153 | for commit in list: |
| 154 | print ' %s' % commit |
| 155 | |
Shawn O. Pearce | 8225cdc | 2009-04-18 11:00:35 -0700 | [diff] [blame] | 156 | sys.stdout.write('to %s (y/n)? ' % remote.review) |
Shawn O. Pearce | a608fb0 | 2009-04-17 12:11:24 -0700 | [diff] [blame] | 157 | answer = sys.stdin.readline().strip() |
| 158 | answer = answer in ('y', 'Y', 'yes', '1', 'true', 't') |
| 159 | |
| 160 | if answer: |
Dan Morrill | 879a9a5 | 2010-05-04 16:56:07 -0700 | [diff] [blame] | 161 | if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD: |
| 162 | answer = _ConfirmManyUploads() |
| 163 | |
| 164 | if answer: |
Shawn O. Pearce | a5ece0e | 2010-07-15 16:52:42 -0700 | [diff] [blame] | 165 | self._UploadAndReport(opt, [branch], people) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 166 | else: |
| 167 | _die("upload aborted by user") |
| 168 | |
Shawn O. Pearce | a5ece0e | 2010-07-15 16:52:42 -0700 | [diff] [blame] | 169 | def _MultipleBranches(self, opt, pending, people): |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 170 | projects = {} |
| 171 | branches = {} |
| 172 | |
| 173 | script = [] |
| 174 | script.append('# Uncomment the branches to upload:') |
| 175 | for project, avail in pending: |
| 176 | script.append('#') |
| 177 | script.append('# project %s/:' % project.relpath) |
| 178 | |
| 179 | b = {} |
| 180 | for branch in avail: |
| 181 | name = branch.name |
| 182 | date = branch.date |
| 183 | list = branch.commits |
| 184 | |
| 185 | if b: |
| 186 | script.append('#') |
| 187 | script.append('# branch %s (%2d commit%s, %s):' % ( |
| 188 | name, |
| 189 | len(list), |
| 190 | len(list) != 1 and 's' or '', |
| 191 | date)) |
| 192 | for commit in list: |
| 193 | script.append('# %s' % commit) |
| 194 | b[name] = branch |
| 195 | |
| 196 | projects[project.relpath] = project |
| 197 | branches[project.name] = b |
| 198 | script.append('') |
| 199 | |
| 200 | script = Editor.EditString("\n".join(script)).split("\n") |
| 201 | |
| 202 | project_re = re.compile(r'^#?\s*project\s*([^\s]+)/:$') |
| 203 | branch_re = re.compile(r'^\s*branch\s*([^\s(]+)\s*\(.*') |
| 204 | |
| 205 | project = None |
| 206 | todo = [] |
| 207 | |
| 208 | for line in script: |
| 209 | m = project_re.match(line) |
| 210 | if m: |
| 211 | name = m.group(1) |
| 212 | project = projects.get(name) |
| 213 | if not project: |
| 214 | _die('project %s not available for upload', name) |
| 215 | continue |
| 216 | |
| 217 | m = branch_re.match(line) |
| 218 | if m: |
| 219 | name = m.group(1) |
| 220 | if not project: |
| 221 | _die('project for branch %s not in script', name) |
| 222 | branch = branches[project.name].get(name) |
| 223 | if not branch: |
| 224 | _die('branch %s not in %s', name, project.relpath) |
| 225 | todo.append(branch) |
| 226 | if not todo: |
| 227 | _die("nothing uncommented for upload") |
Dan Morrill | 879a9a5 | 2010-05-04 16:56:07 -0700 | [diff] [blame] | 228 | |
| 229 | many_commits = False |
| 230 | for branch in todo: |
| 231 | if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD: |
| 232 | many_commits = True |
| 233 | break |
| 234 | if many_commits: |
| 235 | if not _ConfirmManyUploads(multiple_branches=True): |
| 236 | _die("upload aborted by user") |
| 237 | |
Shawn O. Pearce | a5ece0e | 2010-07-15 16:52:42 -0700 | [diff] [blame] | 238 | self._UploadAndReport(opt, todo, people) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 239 | |
Ben Komalo | 08a3f68 | 2010-07-15 16:03:02 -0700 | [diff] [blame] | 240 | def _AppendAutoCcList(self, branch, people): |
| 241 | """ |
| 242 | Appends the list of users in the CC list in the git project's config if a |
| 243 | non-empty reviewer list was found. |
| 244 | """ |
| 245 | |
| 246 | name = branch.name |
| 247 | project = branch.project |
| 248 | key = 'review.%s.autocopy' % project.GetBranch(name).remote.review |
| 249 | raw_list = project.config.GetString(key) |
| 250 | if not raw_list is None and len(people[0]) > 0: |
| 251 | people[1].extend([entry.strip() for entry in raw_list.split(',')]) |
| 252 | |
Ficus Kirkpatrick | bc7ef67 | 2009-05-04 12:45:11 -0700 | [diff] [blame] | 253 | def _FindGerritChange(self, branch): |
| 254 | last_pub = branch.project.WasPublished(branch.name) |
| 255 | if last_pub is None: |
| 256 | return "" |
| 257 | |
| 258 | refs = branch.GetPublishedRefs() |
| 259 | try: |
| 260 | # refs/changes/XYZ/N --> XYZ |
| 261 | return refs.get(last_pub).split('/')[-2] |
| 262 | except: |
| 263 | return "" |
| 264 | |
Shawn O. Pearce | 60829ba | 2010-07-16 07:42:45 -0700 | [diff] [blame] | 265 | def _ReplaceBranch(self, opt, project, people): |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 266 | branch = project.CurrentBranch |
| 267 | if not branch: |
| 268 | print >>sys.stdout, "no branches ready for upload" |
| 269 | return |
| 270 | branch = project.GetUploadableBranch(branch) |
| 271 | if not branch: |
| 272 | print >>sys.stdout, "no branches ready for upload" |
| 273 | return |
| 274 | |
| 275 | script = [] |
| 276 | script.append('# Replacing from branch %s' % branch.name) |
Ficus Kirkpatrick | bc7ef67 | 2009-05-04 12:45:11 -0700 | [diff] [blame] | 277 | |
| 278 | if len(branch.commits) == 1: |
| 279 | change = self._FindGerritChange(branch) |
| 280 | script.append('[%-6s] %s' % (change, branch.commits[0])) |
| 281 | else: |
| 282 | for commit in branch.commits: |
| 283 | script.append('[ ] %s' % commit) |
| 284 | |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 285 | script.append('') |
| 286 | script.append('# Insert change numbers in the brackets to add a new patch set.') |
| 287 | script.append('# To create a new change record, leave the brackets empty.') |
| 288 | |
| 289 | script = Editor.EditString("\n".join(script)).split("\n") |
| 290 | |
| 291 | change_re = re.compile(r'^\[\s*(\d{1,})\s*\]\s*([0-9a-f]{1,}) .*$') |
| 292 | to_replace = dict() |
| 293 | full_hashes = branch.unabbrev_commits |
| 294 | |
| 295 | for line in script: |
| 296 | m = change_re.match(line) |
| 297 | if m: |
Shawn O. Pearce | 6709244 | 2008-12-12 08:01:12 -0800 | [diff] [blame] | 298 | c = m.group(1) |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 299 | f = m.group(2) |
| 300 | try: |
| 301 | f = full_hashes[f] |
| 302 | except KeyError: |
| 303 | print 'fh = %s' % full_hashes |
| 304 | print >>sys.stderr, "error: commit %s not found" % f |
| 305 | sys.exit(1) |
Shawn O. Pearce | 6709244 | 2008-12-12 08:01:12 -0800 | [diff] [blame] | 306 | if c in to_replace: |
| 307 | print >>sys.stderr,\ |
| 308 | "error: change %s cannot accept multiple commits" % c |
| 309 | sys.exit(1) |
| 310 | to_replace[c] = f |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 311 | |
| 312 | if not to_replace: |
| 313 | print >>sys.stderr, "error: no replacements specified" |
| 314 | print >>sys.stderr, " use 'repo upload' without --replace" |
| 315 | sys.exit(1) |
| 316 | |
Dan Morrill | 879a9a5 | 2010-05-04 16:56:07 -0700 | [diff] [blame] | 317 | if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD: |
| 318 | if not _ConfirmManyUploads(multiple_branches=True): |
| 319 | _die("upload aborted by user") |
| 320 | |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 321 | branch.replace_changes = to_replace |
Shawn O. Pearce | a5ece0e | 2010-07-15 16:52:42 -0700 | [diff] [blame] | 322 | self._UploadAndReport(opt, [branch], people) |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 323 | |
Shawn O. Pearce | a5ece0e | 2010-07-15 16:52:42 -0700 | [diff] [blame] | 324 | def _UploadAndReport(self, opt, todo, original_people): |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 325 | have_errors = False |
| 326 | for branch in todo: |
| 327 | try: |
Ben Komalo | 08a3f68 | 2010-07-15 16:03:02 -0700 | [diff] [blame] | 328 | people = copy.deepcopy(original_people) |
| 329 | self._AppendAutoCcList(branch, people) |
| 330 | |
Anthony Newnam | cc50bac | 2010-04-08 10:28:59 -0500 | [diff] [blame] | 331 | # Check if there are local changes that may have been forgotten |
| 332 | if branch.project.HasChanges(): |
| 333 | key = 'review.%s.autoupload' % branch.project.remote.review |
| 334 | answer = branch.project.config.GetBoolean(key) |
| 335 | |
| 336 | # if they want to auto upload, let's not ask because it could be automated |
| 337 | if answer is None: |
| 338 | sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/n) ') |
| 339 | a = sys.stdin.readline().strip().lower() |
| 340 | if a not in ('y', 'yes', 't', 'true', 'on'): |
| 341 | print >>sys.stderr, "skipping upload" |
| 342 | branch.uploaded = False |
| 343 | branch.error = 'User aborted' |
| 344 | continue |
| 345 | |
Shawn O. Pearce | a5ece0e | 2010-07-15 16:52:42 -0700 | [diff] [blame] | 346 | branch.UploadForReview(people, auto_topic=opt.auto_topic) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 347 | branch.uploaded = True |
| 348 | except UploadError, e: |
| 349 | branch.error = e |
| 350 | branch.uploaded = False |
| 351 | have_errors = True |
| 352 | |
| 353 | print >>sys.stderr, '' |
| 354 | print >>sys.stderr, '--------------------------------------------' |
| 355 | |
| 356 | if have_errors: |
| 357 | for branch in todo: |
| 358 | if not branch.uploaded: |
| 359 | print >>sys.stderr, '[FAILED] %-15s %-15s (%s)' % ( |
| 360 | branch.project.relpath + '/', \ |
| 361 | branch.name, \ |
| 362 | branch.error) |
| 363 | print >>sys.stderr, '' |
| 364 | |
| 365 | for branch in todo: |
| 366 | if branch.uploaded: |
| 367 | print >>sys.stderr, '[OK ] %-15s %s' % ( |
| 368 | branch.project.relpath + '/', |
| 369 | branch.name) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 370 | |
| 371 | if have_errors: |
| 372 | sys.exit(1) |
| 373 | |
| 374 | def Execute(self, opt, args): |
| 375 | project_list = self.GetProjects(args) |
| 376 | pending = [] |
Joe Onorato | 2896a79 | 2008-11-17 16:56:36 -0500 | [diff] [blame] | 377 | reviewers = [] |
| 378 | cc = [] |
| 379 | |
| 380 | if opt.reviewers: |
| 381 | reviewers = _SplitEmails(opt.reviewers) |
| 382 | if opt.cc: |
| 383 | cc = _SplitEmails(opt.cc) |
| 384 | people = (reviewers,cc) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 385 | |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 386 | if opt.replace: |
| 387 | if len(project_list) != 1: |
| 388 | print >>sys.stderr, \ |
| 389 | 'error: --replace requires exactly one project' |
| 390 | sys.exit(1) |
Shawn O. Pearce | 60829ba | 2010-07-16 07:42:45 -0700 | [diff] [blame] | 391 | self._ReplaceBranch(opt, project_list[0], people) |
Shawn O. Pearce | c99883f | 2008-11-11 17:12:43 -0800 | [diff] [blame] | 392 | return |
| 393 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 394 | for project in project_list: |
| 395 | avail = project.GetUploadableBranches() |
| 396 | if avail: |
| 397 | pending.append((project, avail)) |
| 398 | |
| 399 | if not pending: |
| 400 | print >>sys.stdout, "no branches ready for upload" |
| 401 | elif len(pending) == 1 and len(pending[0][1]) == 1: |
Shawn O. Pearce | a5ece0e | 2010-07-15 16:52:42 -0700 | [diff] [blame] | 402 | self._SingleBranch(opt, pending[0][1][0], people) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 403 | else: |
Shawn O. Pearce | a5ece0e | 2010-07-15 16:52:42 -0700 | [diff] [blame] | 404 | self._MultipleBranches(opt, pending, people) |