Changeset 46538 in webkit
- Timestamp:
- Jul 29, 2009 4:35:09 AM (15 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r46537 r46538 1 2009-07-29 David Kilzer <ddkilzer@apple.com> 2 3 <http://webkit.org/b/27119> bugzilla-tool: Add create-bug command 4 5 Reviewed by David Levin. 6 7 Implement "create-bug" command for bugzilla-tool. 8 9 * Scripts/bugzilla-tool: Added CreateBug class. 10 (CreateBug.__init__): Added. 11 (CreateBug.create_bug_from_commit): Added. 12 (CreateBug.create_bug_from_patch): Added. 13 (CreateBug.prompt_for_bug_title_and_comment): Added. 14 (CreateBug.execute): Added. 15 (BugzillaTool.__init__): Added create-bug command. 16 * Scripts/modules/bugzilla.py: 17 (Bugzilla.prompt_for_component): Added. 18 (Bugzilla.check_create_bug_response_returning_bug_id_on_success): Added. 19 (Bugzilla.create_bug_with_patch): Added. 20 1 21 2009-07-29 Jan Michael Alonzo <jmalonzo@webkit.org> 2 22 -
trunk/WebKitTools/Scripts/bugzilla-tool
r45978 r46538 455 455 456 456 457 class CreateBug(Command): 458 def __init__(self): 459 options = [ 460 make_option("--cc", action="store", type="string", dest="cc", help="Comma-separated list of email addresses to carbon-copy."), 461 make_option("--component", action="store", type="string", dest="component", help="Component for the new bug."), 462 make_option("--no-prompt", action="store_false", dest="prompt", default=True, help="Do not prompt for bug title and comment; use commit log instead."), 463 make_option("--no-review", action="store_false", dest="review", default=True, help="Do not mark the patch for review."), 464 ] 465 Command.__init__(self, 'Create a bug from local changes or local commits.', '[COMMITISH]', options=options) 466 467 def create_bug_from_commit(self, options, args, tool): 468 commit_ids = tool.scm().commit_ids_from_range_arguments(args, cherry_pick=True) 469 470 if len(commit_ids) > 3: 471 error("Are you sure you want to create one bug with %s patches?" % len(commit_ids)) 472 473 commit_id = commit_ids[0] 474 475 bug_title = "" 476 comment_text = "" 477 if options.prompt: 478 (bug_title, comment_text) = self.prompt_for_bug_title_and_comment() 479 else: 480 commit_message = tool.scm().commit_message_for_local_commit(commit_id) 481 bug_title = commit_message.description(lstrip=True, strip_url=True) 482 comment_text = commit_message.body(lstrip=True) 483 comment_text += "---\n" 484 comment_text += tool.scm().files_changed_summary_for_commit(commit_id) 485 486 diff = tool.scm().create_patch_from_local_commit(commit_id) 487 diff_file = StringIO.StringIO(diff) # create_bug_with_patch expects a file-like object 488 bug_id = tool.bugs.create_bug_with_patch(bug_title, comment_text, options.component, diff_file, "Patch v1", cc=options.cc, mark_for_review=options.review) 489 490 if bug_id and len(commit_ids) > 1: 491 options.bug_id = bug_id 492 options.obsolete_patches = False 493 # FIXME: We should pass through --no-comment switch as well. 494 PostCommitsAsPatchesToBug.execute(self, options, commit_ids[1:], tool) 495 496 def create_bug_from_patch(self, options, args, tool): 497 bug_title = "" 498 comment_text = "" 499 if options.prompt: 500 (bug_title, comment_text) = self.prompt_for_bug_title_and_comment() 501 else: 502 commit_message = commit_message_for_this_commit(tool.scm()) 503 bug_title = commit_message.description(lstrip=True, strip_url=True) 504 comment_text = commit_message.body(lstrip=True) 505 506 diff = tool.scm().create_patch() 507 diff_file = StringIO.StringIO(diff) # create_bug_with_patch expects a file-like object 508 bug_id = tool.bugs.create_bug_with_patch(bug_title, comment_text, options.component, diff_file, "Patch v1", cc=options.cc, mark_for_review=options.review) 509 510 def prompt_for_bug_title_and_comment(self): 511 bug_title = raw_input("Bug title: ") 512 print("Bug comment (hit ^D on blank line to end):") 513 lines = sys.stdin.readlines() 514 sys.stdin.seek(0, os.SEEK_END) 515 comment_text = ''.join(lines) 516 return (bug_title, comment_text) 517 518 def execute(self, options, args, tool): 519 if len(args): 520 if (not tool.scm().supports_local_commits()): 521 error("Extra arguments not supported; patch is taken from working directory.") 522 self.create_bug_from_commit(options, args, tool) 523 else: 524 self.create_bug_from_patch(options, args, tool) 525 526 457 527 class NonWrappingEpilogIndentedHelpFormatter(IndentedHelpFormatter): 458 528 def __init__(self): … … 482 552 { 'name' : 'patches-to-commit', 'object' : PatchesInCommitQueue() }, 483 553 { 'name' : 'reviewed-patches', 'object' : ReviewedPatchesOnBug() }, 554 { 'name' : 'create-bug', 'object' : CreateBug() }, 484 555 { 'name' : 'apply-patches', 'object' : ApplyPatchesFromBug() }, 485 556 { 'name' : 'land-diff', 'object' : LandAndUpdateBug() }, -
trunk/WebKitTools/Scripts/modules/bugzilla.py
r46477 r46538 299 299 self.browser.submit() 300 300 301 def prompt_for_component(self, components): 302 log("Please pick a component:") 303 i = 0 304 for name in components: 305 i += 1 306 log("%2d. %s" % (i, name)) 307 result = int(raw_input("Enter a number: ")) - 1 308 return components[result] 309 310 def _check_create_bug_response(self, response_html): 311 match = re.search("<title>Bug (?P<bug_id>\d+) Submitted</title>", response_html) 312 if match: 313 return match.group('bug_id') 314 315 match = re.search('<div id="bugzilla-body">(?P<error_message>.+)<div id="footer">', response_html, re.DOTALL) 316 error_message = "FAIL" 317 if match: 318 text_lines = BeautifulSoup(match.group('error_message')).findAll(text=True) 319 error_message = "\n" + '\n'.join([" " + line.strip() for line in text_lines if line.strip()]) 320 error("Bug not created: %s" % error_message) 321 322 def create_bug_with_patch(self, bug_title, bug_description, component, patch_file_object, patch_description, cc, mark_for_review=False): 323 self.authenticate() 324 325 log('Creating bug with patch description "%s"' % patch_description) 326 if self.dryrun: 327 log(bug_description) 328 return 329 330 self.browser.open(self.bug_server_url + "enter_bug.cgi?product=WebKit") 331 self.browser.select_form(name="Create") 332 component_items = self.browser.find_control('component').items 333 component_names = map(lambda item: item.name, component_items) 334 if not component or component not in component_names: 335 component = self.prompt_for_component(component_names) 336 self.browser['component'] = [component] 337 self.browser['cc'] = cc 338 self.browser['short_desc'] = bug_title 339 if bug_description: 340 log(bug_description) 341 self.browser['comment'] = bug_description 342 self.browser['description'] = patch_description 343 self.browser['ispatch'] = ("1",) 344 self.browser['flag_type-1'] = ('?',) if mark_for_review else ('X',) 345 self.browser.add_file(patch_file_object, "text/plain", "%s.patch" % timestamp(), 'data') 346 response = self.browser.submit() 347 348 bug_id = self._check_create_bug_response(response.read()) 349 log("Bug %s created." % bug_id) 350 log(self.bug_server_url + "show_bug.cgi?id=" + bug_id) 351 return bug_id 352 301 353 def obsolete_attachment(self, attachment_id, comment_text = None): 302 354 self.authenticate()
Note: See TracChangeset
for help on using the changeset viewer.