Changeset 51176 in webkit
- Timestamp:
- Nov 18, 2009 10:18:59 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r51174 r51176 1 2009-11-18 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Normalize ' and " in bugzilla-tool 6 https://bugs.webkit.org/show_bug.cgi?id=31655 7 8 We decided " is better than ' and we should be consistent. 9 10 * Scripts/bugzilla-tool: 11 1 12 2009-11-18 Laszlo Gombos <laszlo.1.gombos@nokia.com> 2 13 -
trunk/WebKitTools/Scripts/bugzilla-tool
r51160 r51176 54 54 def plural(noun): 55 55 # This is a dumb plural() implementation which was just enough for our uses. 56 if re.search( 'h$', noun):57 return noun + 'es'56 if re.search("h$", noun): 57 return noun + "es" 58 58 else: 59 return noun + 's'59 return noun + "s" 60 60 61 61 def pluralize(noun, count): … … 80 80 81 81 # FIXME: We should sort and label the ChangeLog messages like commit-log-editor does. 82 return CommitMessage( ''.join(changelog_messages).splitlines())82 return CommitMessage("".join(changelog_messages).splitlines()) 83 83 84 84 … … 108 108 class BugsInCommitQueue(Command): 109 109 def __init__(self): 110 Command.__init__(self, 'Bugs in the commit queue')110 Command.__init__(self, "Bugs in the commit queue") 111 111 112 112 def execute(self, options, args, tool): … … 118 118 class PatchesInCommitQueue(Command): 119 119 def __init__(self): 120 Command.__init__(self, 'Patches in the commit queue')120 Command.__init__(self, "Patches in the commit queue") 121 121 122 122 def execute(self, options, args, tool): … … 124 124 log("Patches in commit queue:") 125 125 for patch in patches: 126 print "%s" % patch[ 'url']126 print "%s" % patch["url"] 127 127 128 128 129 129 class ReviewedPatchesOnBug(Command): 130 130 def __init__(self): 131 Command.__init__(self, 'r+\'d patches on a bug', 'BUGID')131 Command.__init__(self, "r+\'d patches on a bug", "BUGID") 132 132 133 133 def execute(self, options, args, tool): … … 135 135 patches_to_land = tool.bugs.fetch_reviewed_patches_from_bug(bug_id) 136 136 for patch in patches_to_land: 137 print "%s" % patch[ 'url']137 print "%s" % patch["url"] 138 138 139 139 … … 141 141 def __init__(self): 142 142 options = WebKitLandingScripts.cleaning_options() 143 Command.__init__(self, 'Runs check-webkit-style on the specified attachment', 'ATTACHMENT_ID', options=options)143 Command.__init__(self, "Runs check-webkit-style on the specified attachment", "ATTACHMENT_ID", options=options) 144 144 145 145 @classmethod 146 146 def check_style(cls, patch, options, tool): 147 147 tool.scm().update_webkit() 148 log("Checking style for patch %s from bug %s." % (patch[ 'id'], patch['bug_id']))148 log("Checking style for patch %s from bug %s." % (patch["id"], patch["bug_id"])) 149 149 try: 150 150 # FIXME: check-webkit-style shouldn't really have to apply the patch to check the style. … … 152 152 WebKitLandingScripts.run_webkit_script("check-webkit-style") 153 153 except ScriptError, e: 154 log("Patch %s from bug %s failed to apply and check style." % (patch[ 'id'], patch['bug_id']))154 log("Patch %s from bug %s failed to apply and check style." % (patch["id"], patch["bug_id"])) 155 155 log(e.output) 156 156 … … 170 170 def __init__(self): 171 171 options = WebKitApplyingScripts.apply_options() + WebKitLandingScripts.cleaning_options() 172 Command.__init__(self, 'Applies an attachment to the local working directory.', 'ATTACHMENT_ID', options=options)172 Command.__init__(self, "Applies an attachment to the local working directory.", "ATTACHMENT_ID", options=options) 173 173 174 174 def execute(self, options, args, tool): … … 182 182 def __init__(self): 183 183 options = WebKitApplyingScripts.apply_options() + WebKitLandingScripts.cleaning_options() 184 Command.__init__(self, 'Applies all patches on a bug to the local working directory.', 'BUGID', options=options)184 Command.__init__(self, "Applies all patches on a bug to the local working directory.", "BUGID", options=options) 185 185 186 186 def execute(self, options, args, tool): … … 211 211 212 212 for patch in patches: 213 log("Applying attachment %s from bug %s" % (patch[ 'id'], patch['bug_id']))213 log("Applying attachment %s from bug %s" % (patch["id"], patch["bug_id"])) 214 214 scm.apply_patch(patch) 215 215 if options.local_commit: 216 216 commit_message = commit_message_for_this_commit(scm) 217 scm.commit_locally_with_message(commit_message.message() or patch[ 'name'])217 scm.commit_locally_with_message(commit_message.message() or patch["name"]) 218 218 219 219 … … 245 245 while True: 246 246 output_line = child_process.stdout.readline() 247 if output_line == ''and child_process.poll() != None:247 if output_line == "" and child_process.poll() != None: 248 248 return child_process.poll() 249 249 teed_output.write(output_line) … … 322 322 patches = bugs.fetch_patches_from_bug(bug_id) 323 323 for patch in patches: 324 review_flag = patch.get( 'review')325 if review_flag == '?' or review_flag == '+':326 log("Not closing bug %s as attachment %s has review=%s. Assuming there are more patches to land from this bug." % (patch[ 'bug_id'], patch['id'], review_flag))324 review_flag = patch.get("review") 325 if review_flag == "?" or review_flag == "+": 326 log("Not closing bug %s as attachment %s has review=%s. Assuming there are more patches to land from this bug." % (patch["bug_id"], patch["id"], review_flag)) 327 327 return 328 328 bugs.close_bug_as_fixed(bug_id, "All reviewed patches have been landed. Closing bug.") … … 331 331 def _land_patch(cls, patch, options, tool): 332 332 tool.scm().update_webkit() # Update before every patch in case the tree has changed 333 log("Applying patch %s from bug %s." % (patch[ 'id'], patch['bug_id']))333 log("Applying patch %s from bug %s." % (patch["id"], patch["bug_id"])) 334 334 tool.scm().apply_patch(patch, force=options.non_interactive) 335 335 … … 338 338 WebKitLandingScripts.ensure_builders_are_green(tool.buildbot, options) 339 339 comment_text = WebKitLandingScripts.build_and_commit(tool.scm(), options) 340 tool.bugs.clear_attachment_flags(patch[ 'id'], comment_text)340 tool.bugs.clear_attachment_flags(patch["id"], comment_text) 341 341 342 342 @classmethod … … 345 345 cls._land_patch(patch, options, tool) 346 346 if options.close_bug: 347 cls._close_bug_if_no_active_patches(tool.bugs, patch[ 'bug_id'])347 cls._close_bug_if_no_active_patches(tool.bugs, patch["bug_id"]) 348 348 except CheckoutNeedsUpdate, e: 349 349 log("Commit failed because the checkout is out of date. Please update and try again.") … … 352 352 except ScriptError, e: 353 353 # Mark the patch as commit-queue- and comment in the bug. 354 tool.bugs.reject_patch_from_commit_queue(patch[ 'id'], e.message_with_output())354 tool.bugs.reject_patch_from_commit_queue(patch["id"], e.message_with_output()) 355 355 WorkQueue.exit_after_handled_error(e) 356 356 … … 362 362 ] 363 363 options += WebKitLandingScripts.land_options() 364 Command.__init__(self, 'Lands the current working directory diff and updates the bug if provided.', '[BUGID]', options=options)364 Command.__init__(self, "Lands the current working directory diff and updates the bug if provided.", "[BUGID]", options=options) 365 365 366 366 def guess_reviewer_from_bug(self, bugs, bug_id): … … 370 370 return None 371 371 patch = patches[0] 372 reviewer = patch[ 'reviewer']373 log( 'Guessing "%s" as reviewer from attachment %s on bug %s.' % (reviewer, patch['id'], bug_id))372 reviewer = patch["reviewer"] 373 log("Guessing \"%s\" as reviewer from attachment %s on bug %s." % (reviewer, patch["id"], bug_id)) 374 374 return reviewer 375 375 … … 423 423 bugs_to_patches = {} 424 424 for patch in patches: 425 bug_id = patch[ 'bug_id']425 bug_id = patch["bug_id"] 426 426 bugs_to_patches[bug_id] = bugs_to_patches.get(bug_id, []).append(patch) 427 427 return bugs_to_patches … … 447 447 class LandAttachment(AbstractPatchLandingCommand): 448 448 def __init__(self): 449 AbstractPatchLandingCommand.__init__(self, 'Lands a patches from bugzilla, optionally building and testing them first', 'ATTACHMENT_ID [ATTACHMENT_IDS]')449 AbstractPatchLandingCommand.__init__(self, "Lands a patches from bugzilla, optionally building and testing them first", "ATTACHMENT_ID [ATTACHMENT_IDS]") 450 450 451 451 @staticmethod … … 456 456 class LandPatchesFromBugs(AbstractPatchLandingCommand): 457 457 def __init__(self): 458 AbstractPatchLandingCommand.__init__(self, 'Lands all patches on the given bugs, optionally building and testing them first', 'BUGID [BUGIDS]')458 AbstractPatchLandingCommand.__init__(self, "Lands all patches on the given bugs, optionally building and testing them first", "BUGID [BUGIDS]") 459 459 460 460 @staticmethod … … 470 470 class CommitMessageForCurrentDiff(Command): 471 471 def __init__(self): 472 Command.__init__(self, 'Prints a commit message suitable for the uncommitted changes.')472 Command.__init__(self, "Prints a commit message suitable for the uncommitted changes.") 473 473 474 474 def execute(self, options, args, tool): … … 479 479 class ObsoleteAttachmentsOnBug(Command): 480 480 def __init__(self): 481 Command.__init__(self, 'Marks all attachments on a bug as obsolete.', 'BUGID')481 Command.__init__(self, "Marks all attachments on a bug as obsolete.", "BUGID") 482 482 483 483 def execute(self, options, args, tool): … … 485 485 attachments = tool.bugs.fetch_attachments_from_bug(bug_id) 486 486 for attachment in attachments: 487 if not attachment[ 'is_obsolete']:488 tool.bugs.obsolete_attachment(attachment[ 'id'])487 if not attachment["is_obsolete"]: 488 tool.bugs.obsolete_attachment(attachment["id"]) 489 489 490 490 … … 492 492 def __init__(self): 493 493 options = [ 494 make_option("-m", "--description", action="store", type="string", dest="description", help="Description string for the attachment (default: 'patch')"),494 make_option("-m", "--description", action="store", type="string", dest="description", help="Description string for the attachment (default: \"patch\")"), 495 495 ] 496 496 options += self.posting_options() 497 Command.__init__(self, 'Attaches the current working directory diff to a bug as a patch file.', '[BUGID]', options=options)497 Command.__init__(self, "Attaches the current working directory diff to a bug as a patch file.", "[BUGID]", options=options) 498 498 499 499 @staticmethod … … 509 509 patches = bugs.fetch_patches_from_bug(bug_id) 510 510 if len(patches): 511 log("Obsoleting %s on bug %s" % (pluralize( 'old patch', len(patches)), bug_id))511 log("Obsoleting %s on bug %s" % (pluralize("old patch", len(patches)), bug_id)) 512 512 for patch in patches: 513 bugs.obsolete_attachment(patch[ 'id'])513 bugs.obsolete_attachment(patch["id"]) 514 514 515 515 def execute(self, options, args, tool): … … 537 537 ] 538 538 options += PostDiffAsPatchToBug.posting_options() 539 Command.__init__(self, 'Attaches a range of local commits to bugs as patch files.', 'COMMITISH', options=options, requires_local_commits=True)539 Command.__init__(self, "Attaches a range of local commits to bugs as patch files.", "COMMITISH", options=options, requires_local_commits=True) 540 540 541 541 def _comment_text_for_commit(self, options, commit_message, tool, commit_id): … … 557 557 commit_ids = tool.scm().commit_ids_from_commitish_arguments(args) 558 558 if len(commit_ids) > 10: # We could lower this limit, 10 is too many for one bug as-is. 559 error("bugzilla-tool does not support attaching %s at once. Are you sure you passed the right commit range?" % (pluralize( 'patch', len(commit_ids))))559 error("bugzilla-tool does not support attaching %s at once. Are you sure you passed the right commit range?" % (pluralize("patch", len(commit_ids)))) 560 560 561 561 have_obsoleted_patches = set() … … 584 584 options += WebKitLandingScripts.cleaning_options() 585 585 options.append(make_option("--complete-rollout", action="store_true", dest="complete_rollout", help="Experimental support for complete unsupervised rollouts, including re-opening the bug. Not recommended.")) 586 Command.__init__(self, 'Reverts the given revision and commits the revert and re-opens the original bug.', 'REVISION [BUGID]', options=options)586 Command.__init__(self, "Reverts the given revision and commits the revert and re-opens the original bug.", "REVISION [BUGID]", options=options) 587 587 588 588 @staticmethod … … 630 630 # Once we trust rollout we will remove this option. 631 631 if not options.complete_rollout: 632 log("\nNOTE: Rollout support is experimental.\nPlease verify the rollout diff and use 'bugzilla-tool land-diff %s'to commit the rollout." % bug_id)632 log("\nNOTE: Rollout support is experimental.\nPlease verify the rollout diff and use \"bugzilla-tool land-diff %s\" to commit the rollout." % bug_id) 633 633 else: 634 634 comment_text = WebKitLandingScripts.build_and_commit(tool.scm(), options) … … 645 645 make_option("--request-commit", action="store_true", dest="request_commit", default=False, help="Mark the patch as needing auto-commit after review."), 646 646 ] 647 Command.__init__(self, 'Create a bug from local changes or local commits.', '[COMMITISH]', options=options)647 Command.__init__(self, "Create a bug from local changes or local commits.", "[COMMITISH]", options=options) 648 648 649 649 def create_bug_from_commit(self, options, args, tool): … … 701 701 # place. 702 702 pass 703 comment_text = ''.join(lines)703 comment_text = "".join(lines) 704 704 return (bug_title, comment_text) 705 705 … … 715 715 class CheckTreeStatus(Command): 716 716 def __init__(self): 717 Command.__init__(self, 'Print out the status of the webkit builders.')717 Command.__init__(self, "Print out the status of the webkit builders.") 718 718 719 719 def execute(self, options, args, tool): 720 720 for builder in tool.buildbot.builder_statuses(): 721 status_string = "ok" if builder[ 'is_green'] else 'FAIL'722 print "%s : %s" % (status_string.ljust(4), builder[ 'name'])721 status_string = "ok" if builder["is_green"] else "FAIL" 722 print "%s : %s" % (status_string.ljust(4), builder["name"]) 723 723 724 724 … … 730 730 make_option("--status-host", action="store", type="string", dest="status_host", default=StatusBot.default_host, help="Hostname (e.g. localhost or commit.webkit.org) where status updates should be posted."), 731 731 ] 732 Command.__init__(self, 'Run the %s.'% self._name, options=options)732 Command.__init__(self, "Run the %s." % self._name, options=options) 733 733 734 734 def queue_log_path(self): 735 return '%s.log'% self._name735 return "%s.log" % self._name 736 736 737 737 def work_logs_directory(self): 738 return '%s-logs'% self._name738 return "%s-logs" % self._name 739 739 740 740 def status_host(self): … … 744 744 log("CAUTION: %s will discard all local changes in %s" % (self._name, self.tool.scm().checkout_root)) 745 745 if self.options.confirm: 746 response = raw_input("Are you sure? Type 'yes'to continue: ")747 if (response != 'yes'):746 response = raw_input("Are you sure? Type \"yes\" to continue: ") 747 if (response != "yes"): 748 748 error("User declined.") 749 749 log("Running WebKit %s. %s" % (self._name, datetime.now().strftime(WorkQueue.log_date_format))) … … 771 771 772 772 def log_progress(self, patch_ids): 773 log("%s in %s [%s]" % (pluralize( 'patch', len(patch_ids)), self._name, ", ".join(patch_ids)))773 log("%s in %s [%s]" % (pluralize("patch", len(patch_ids)), self._name, ", ".join(patch_ids))) 774 774 775 775 def execute(self, options, args, tool): … … 795 795 red_builders_names = self.tool.buildbot.red_core_builders_names() 796 796 if red_builders_names: 797 red_builders_names = map(lambda name: '"%s"'% name, red_builders_names) # Add quotes around the names.797 red_builders_names = map(lambda name: "\"%s\"" % name, red_builders_names) # Add quotes around the names. 798 798 return (False, "Builders [%s] are red. See http://build.webkit.org." % ", ".join(red_builders_names), None) 799 return (True, "Landing patch %s from bug %s." % (patch[ 'id'], patch['bug_id']), patch['bug_id'])799 return (True, "Landing patch %s from bug %s." % (patch["id"], patch["bug_id"]), patch["bug_id"]) 800 800 801 801 def process_work_item(self, patch): 802 self.run_bugzilla_tool([ 'land-attachment', '--force-clean', '--non-interactive', '--quiet', patch['id']])802 self.run_bugzilla_tool(["land-attachment", "--force-clean", "--non-interactive", "--quiet", patch["id"]]) 803 803 804 804 def handle_unexpected_error(self, patch, message): 805 self.tool.bugs.reject_patch_from_commit_queue(patch[ 'id'], message)805 self.tool.bugs.reject_patch_from_commit_queue(patch["id"], message) 806 806 807 807 … … 823 823 824 824 def should_proceed_with_work_item(self, patch): 825 return (True, "Checking style for patch %s on bug %s." % (patch[ 'id'], patch['bug_id']), patch['bug_id'])825 return (True, "Checking style for patch %s on bug %s." % (patch["id"], patch["bug_id"]), patch["bug_id"]) 826 826 827 827 def process_work_item(self, patch): 828 self.run_bugzilla_tool([ 'check-style', '--force-clean', patch['id']])828 self.run_bugzilla_tool(["check-style", "--force-clean", patch["id"]]) 829 829 830 830 def handle_unexpected_error(self, patch, message): … … 847 847 self.print_usage(sys.stderr) 848 848 error_message = "%s: error: %s\n" % (self.get_prog_name(), msg) 849 error_message += "\nType '" + self.get_prog_name() + " --help'to see usage.\n"849 error_message += "\nType \"" + self.get_prog_name() + " --help\" to see usage.\n" 850 850 self.exit(2, error_message) 851 851 … … 857 857 self.buildbot = BuildBot() 858 858 self.commands = [ 859 { 'name' : 'bugs-to-commit', 'object': BugsInCommitQueue() },860 { 'name' : 'patches-to-commit', 'object': PatchesInCommitQueue() },861 { 'name' : 'reviewed-patches', 'object': ReviewedPatchesOnBug() },862 { 'name' : 'create-bug', 'object': CreateBug() },863 { 'name' : 'apply-attachment', 'object': ApplyAttachment() },864 { 'name' : 'apply-patches', 'object': ApplyPatchesFromBug() },865 { 'name' : 'land-diff', 'object': LandAndUpdateBug() },866 { 'name' : 'land-attachment', 'object': LandAttachment() },867 { 'name' : 'land-patches', 'object': LandPatchesFromBugs() },868 { 'name' : 'check-style', 'object': CheckStyle() },869 { 'name' : 'commit-message', 'object': CommitMessageForCurrentDiff() },870 { 'name' : 'obsolete-attachments', 'object': ObsoleteAttachmentsOnBug() },871 { 'name' : 'post-diff', 'object': PostDiffAsPatchToBug() },872 { 'name' : 'post-commits', 'object': PostCommitsAsPatchesToBug() },873 { 'name' : 'tree-status', 'object': CheckTreeStatus() },874 { 'name' : 'commit-queue', 'object': CommitQueue() },875 { 'name' : 'style-queue', 'object': StyleQueue() },876 { 'name' : 'rollout', 'object': RolloutCommit() },859 { "name" : "bugs-to-commit", "object" : BugsInCommitQueue() }, 860 { "name" : "patches-to-commit", "object" : PatchesInCommitQueue() }, 861 { "name" : "reviewed-patches", "object" : ReviewedPatchesOnBug() }, 862 { "name" : "create-bug", "object" : CreateBug() }, 863 { "name" : "apply-attachment", "object" : ApplyAttachment() }, 864 { "name" : "apply-patches", "object" : ApplyPatchesFromBug() }, 865 { "name" : "land-diff", "object" : LandAndUpdateBug() }, 866 { "name" : "land-attachment", "object" : LandAttachment() }, 867 { "name" : "land-patches", "object" : LandPatchesFromBugs() }, 868 { "name" : "check-style", "object" : CheckStyle() }, 869 { "name" : "commit-message", "object" : CommitMessageForCurrentDiff() }, 870 { "name" : "obsolete-attachments", "object" : ObsoleteAttachmentsOnBug() }, 871 { "name" : "post-diff", "object" : PostDiffAsPatchToBug() }, 872 { "name" : "post-commits", "object" : PostCommitsAsPatchesToBug() }, 873 { "name" : "tree-status", "object" : CheckTreeStatus() }, 874 { "name" : "commit-queue", "object" : CommitQueue() }, 875 { "name" : "style-queue", "object" : StyleQueue() }, 876 { "name" : "rollout", "object" : RolloutCommit() }, 877 877 ] 878 878 … … 882 882 def scm(self): 883 883 # Lazily initialize SCM to not error-out before command line parsing (or when running non-scm commands). 884 original_cwd = os.path.abspath( '.')884 original_cwd = os.path.abspath(".") 885 885 if not self.cached_scm: 886 886 self.cached_scm = detect_scm_system(original_cwd) … … 907 907 scm_supports_local_commits = self.scm().supports_local_commits() 908 908 for command in self.commands: 909 command_object = command[ 'object']909 command_object = command["object"] 910 910 if command_object.requires_local_commits and not scm_supports_local_commits: 911 911 continue 912 command_name_and_args = command_object.name_with_arguments(command[ 'name'])913 command_rows.append({ 'name-and-args': command_name_and_args, 'object': command_object })912 command_name_and_args = command_object.name_with_arguments(command["name"]) 913 command_rows.append({ "name-and-args": command_name_and_args, "object": command_object }) 914 914 longest_name_length = max([longest_name_length, len(command_name_and_args)]) 915 915 … … 920 920 921 921 for row in command_rows: 922 command_object = row[ 'object']923 commands_text += " " + row[ 'name-and-args'].ljust(longest_name_length + 3) + command_object.help_text + "\n"922 command_object = row["object"] 923 commands_text += " " + row["name-and-args"].ljust(longest_name_length + 3) + command_object.help_text + "\n" 924 924 commands_text += command_object.option_parser.format_option_help(formatter) 925 925 return commands_text … … 928 928 (options, args) = self.global_option_parser.parse_args(args) 929 929 if len(args): 930 # We'll never hit this because split_args splits at the first arg without a leading '-'930 # We'll never hit this because split_args splits at the first arg without a leading "-" 931 931 self.global_option_parser.error("Extra arguments before command: " + args) 932 932 … … 937 937 @staticmethod 938 938 def split_args(args): 939 # Assume the first argument which doesn't start with '-'is the command name.939 # Assume the first argument which doesn't start with "-" is the command name. 940 940 command_index = 0 941 941 for arg in args: 942 if arg[0] != '-':942 if arg[0] != "-": 943 943 break 944 944 command_index += 1 … … 953 953 def command_by_name(self, command_name): 954 954 for command in self.commands: 955 if command_name == command[ 'name']:955 if command_name == command["name"]: 956 956 return command 957 957 return None … … 970 970 self.global_option_parser.error(command_name + " is not a recognized command") 971 971 972 command_object = command[ 'object']972 command_object = command["object"] 973 973 974 974 if command_object.requires_local_commits and not self.scm().supports_local_commits():
Note: See TracChangeset
for help on using the changeset viewer.