Changeset 45654 in webkit
- Timestamp:
- Jul 8, 2009 6:25:00 PM (15 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r45647 r45654 1 2009-07-08 David Kilzer <ddkilzer@apple.com> 2 3 Bug 27062: bugzilla-tool: post-commits should read bug id from commit log and actually work 4 5 <https://bugs.webkit.org/show_bug.cgi?id=27062> 6 7 Reviewed by Eric Seidel. 8 9 Removed the required BUGID argument from the "post-commits" 10 command and replaced it with a -b|--bug-id switch or parsing the 11 commit log message for the bug URL. Fixed a bug in the 12 "post-commits" that would ignore the COMMITISH used and post a 13 patch of local changes against HEAD. Added --no-commit switch 14 to disable using the bulk of the ChangeLog entry as the comment 15 for the new patch. 16 17 * Scripts/bugzilla-tool: 18 (bug_id_from_commit_message): Added. Returns a bug id from the 19 commit log message, thus enforcing the need for a bug URL in the 20 message. 21 (PostCommitsAsPatchesToBug.__init__): Updated help description 22 to match new behavior of pulling bug ids from commit log 23 messages instead of from the command line. Added -b|--bug-id 24 switch and --no-comment switch. 25 (PostCommitsAsPatchesToBug.execute): Updated to use 26 bug_id_from_commit_message() to pull bug ids from commit log 27 messages. Also switched from SCM.create_patch() to use 28 SCM.create_patch_from_local_commit() to fix a bug where local 29 repository changes were posted as a patch instead of the 30 specific COMMITISH. Fall back to -b|--bug-id if no URL is found 31 in the commit log message. Don't specify a comment for the 32 patch if --no-comment is used. Set cherry_pick argument to True 33 for Git.commit_ids_from_range_arguments() since we don't want 34 implicit commit range behavior for this command. 35 36 * Scripts/modules/bugzilla.py: Import datetime module. 37 (timestamp): Added. Returns a timestamp in the form of 38 "YYYYMMDDhhmmss". 39 (Bugzilla.bug_server_regex): Added static attribute. 40 (Bugzilla.add_patch_to_bug): Construct a more meaningful patch 41 file name using the bug_id and timestamp(). 42 43 * Scripts/modules/scm.py: 44 (SCM.create_patch_from_local_commit): Added. 45 (Git.create_patch_from_local_commit): Added. Runs "git diff" to 46 return a patch for the given commit_id. 47 1 48 2009-07-08 Maciej Stachowiak <mjs@apple.com> 2 49 -
trunk/WebKitTools/Scripts/bugzilla-tool
r45469 r45654 1 1 #!/usr/bin/python 2 2 # Copyright (c) 2009, Google Inc. All rights reserved. 3 # Copyright (c) 2009 Apple Inc. All rights reserved. 3 4 # 4 5 # Redistribution and use in source and binary forms, with or without … … 102 103 return changelog_paths 103 104 105 def bug_id_from_commit_message(commit_message): 106 match = re.search(Bugzilla.bug_server_regex + "show_bug\.cgi\?id=(?P<bug_id>\d+)", commit_message, re.MULTILINE) 107 return match.group('bug_id') 108 104 109 def commit_message_for_this_commit(scm): 105 110 changelog_paths = modified_changelogs(scm) … … 408 413 def __init__(self): 409 414 options = [ 415 make_option("-b", "--bug-id", action="store", type="string", dest="bug_id", help="Specify bug id if no URL is provided in the commit log."), 416 make_option("--no-comment", action="store_false", dest="comment", default=True, help="Do not use commit log message as a comment for the patch."), 410 417 make_option("--no-obsolete", action="store_false", dest="obsolete_patches", default=True, help="Do not obsolete old patches before posting new ones."), 411 418 make_option("--no-review", action="store_false", dest="review", default=True, help="Do not mark the patch for review."), 412 419 ] 413 Command.__init__(self, 'Attaches a range of local commits to a bug as patch files.', 'BUGID COMMITISH', options=options) 414 415 def execute(self, options, args, tool): 416 bug_id = args[0] 417 420 Command.__init__(self, 'Attaches a range of local commits to bugs as patch files.', 'COMMITISH', options=options) 421 422 def execute(self, options, args, tool): 418 423 if not tool.scm().supports_local_commits(): 419 424 error(tool.scm().display_name() + " does not support local commits.") 420 421 commit_ids = tool.scm().commit_ids_from_range_arguments(args [1:])422 425 426 commit_ids = tool.scm().commit_ids_from_range_arguments(args, cherry_pick=True) 427 423 428 if len(commit_ids) > 10: 424 error("Are you sure you want to attach %s to bug %s?" % (pluralize('patch', len(commit_ids)), bug_id))429 error("Are you sure you want to attach %s patches?" % (pluralize('patch', len(commit_ids)))) 425 430 # Could add a --patches-limit option. 426 431 427 if options.obsolete_patches: 428 PostDiffAsPatchToBug.obsolete_patches_on_bug(bug_id, tool.bugs) 429 430 log("Attaching %s as patches to bug %s" % (pluralize('commit', len(commit_ids)), bug_id)) 432 have_obsoleted_patches = set() 431 433 for commit_id in commit_ids: 432 434 commit_message = tool.scm().commit_message_for_commit(commit_id) 433 435 commit_lines = commit_message.splitlines() 434 436 437 bug_id = options.bug_id or bug_id_from_commit_message(commit_message) 438 if not bug_id: 439 log("Skipping %s: No bug id found in commit log or specified with --bug-id." % commit_id) 440 continue 441 442 if options.obsolete_patches and bug_id not in have_obsoleted_patches: 443 PostDiffAsPatchToBug.obsolete_patches_on_bug(bug_id, tool.bugs) 444 have_obsoleted_patches.update(bug_id) 445 435 446 description = commit_lines[0] 436 comment_text = "\n".join(commit_lines[1:]) 437 comment_text += "---\n" 438 comment_text += tool.scm().files_changed_summary_for_commit(commit_id) 439 440 diff = tool.scm().create_patch() 447 comment_text = None 448 if (options.comment): 449 comment_text = "\n".join(commit_lines[1:]) 450 comment_text += "\n---\n" 451 comment_text += tool.scm().files_changed_summary_for_commit(commit_id) 452 453 diff = tool.scm().create_patch_from_local_commit(commit_id) 441 454 diff_file = StringIO.StringIO(diff) # add_patch_to_bug expects a file-like object 442 455 tool.bugs.add_patch_to_bug(bug_id, diff_file, description, comment_text, mark_for_review=options.review) -
trunk/WebKitTools/Scripts/modules/bugzilla.py
r45638 r45654 1 1 # Copyright (c) 2009, Google Inc. All rights reserved. 2 # Copyright (c) 2009 Apple Inc. All rights reserved. 2 3 # 3 4 # Redistribution and use in source and binary forms, with or without … … 35 36 import urllib2 36 37 38 from datetime import datetime # used in timestamp() 39 37 40 # WebKit includes a built copy of BeautifulSoup in Scripts/modules 38 41 # so this import should always succeed. … … 70 73 return None 71 74 return value.rstrip('\n') 75 76 def timestamp(): 77 return datetime.now().strftime("%Y%m%d%H%M%S") 72 78 73 79 class Bugzilla: … … 82 88 # Ignore bugs.webkit.org/robots.txt until we fix it to allow this script 83 89 self.browser.set_handle_robots(False) 90 91 bug_server_regex = "https?\://bugs\.webkit\.org/" 84 92 85 93 # This could eventually be a text file … … 247 255 self.browser['comment'] = comment_text 248 256 self.browser['flag_type-1'] = ('?',) if mark_for_review else ('X',) 249 self.browser.add_file(patch_file_object, "text/plain", "bug zilla_requires_a_filename.patch")257 self.browser.add_file(patch_file_object, "text/plain", "bug-%s-%s.patch" % (bug_id, timestamp())) 250 258 self.browser.submit() 251 259 -
trunk/WebKitTools/Scripts/modules/scm.py
r45580 r45654 1 1 # Copyright (c) 2009, Google Inc. All rights reserved. 2 # Copyright (c) 2009 Apple Inc. All rights reserved. 2 3 # 3 4 # Redistribution and use in source and binary forms, with or without … … 155 156 raise NotImplementedError, "subclasses must implement" 156 157 158 def create_patch_from_local_commit(self, commit_id): 159 pass 160 157 161 def commit_locally_with_message(self, message): 158 162 pass … … 291 295 292 296 # Git-specific methods: 293 297 298 def create_patch_from_local_commit(self, commit_id): 299 return self.run_command(['git', 'diff', commit_id + "^.." + commit_id]) 300 294 301 def commit_locally_with_message(self, message): 295 302 self.run_command(['git', 'commit', '--all', '-F', '-'], input=message)
Note: See TracChangeset
for help on using the changeset viewer.