Changeset 51176 in webkit


Ignore:
Timestamp:
Nov 18, 2009 10:18:59 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-11-18 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Normalize ' and " in bugzilla-tool
https://bugs.webkit.org/show_bug.cgi?id=31655

We decided " is better than ' and we should be consistent.

  • Scripts/bugzilla-tool:
Location:
trunk/WebKitTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r51174 r51176  
     12009-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
    1122009-11-18  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
    213
  • trunk/WebKitTools/Scripts/bugzilla-tool

    r51160 r51176  
    5454def plural(noun):
    5555    # 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"
    5858    else:
    59         return noun + 's'
     59        return noun + "s"
    6060
    6161def pluralize(noun, count):
     
    8080
    8181    # 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())
    8383
    8484
     
    108108class BugsInCommitQueue(Command):
    109109    def __init__(self):
    110         Command.__init__(self, 'Bugs in the commit queue')
     110        Command.__init__(self, "Bugs in the commit queue")
    111111
    112112    def execute(self, options, args, tool):
     
    118118class PatchesInCommitQueue(Command):
    119119    def __init__(self):
    120         Command.__init__(self, 'Patches in the commit queue')
     120        Command.__init__(self, "Patches in the commit queue")
    121121
    122122    def execute(self, options, args, tool):
     
    124124        log("Patches in commit queue:")
    125125        for patch in patches:
    126             print "%s" % patch['url']
     126            print "%s" % patch["url"]
    127127
    128128
    129129class ReviewedPatchesOnBug(Command):
    130130    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")
    132132
    133133    def execute(self, options, args, tool):
     
    135135        patches_to_land = tool.bugs.fetch_reviewed_patches_from_bug(bug_id)
    136136        for patch in patches_to_land:
    137             print "%s" % patch['url']
     137            print "%s" % patch["url"]
    138138
    139139
     
    141141    def __init__(self):
    142142        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)
    144144
    145145    @classmethod
    146146    def check_style(cls, patch, options, tool):
    147147        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"]))
    149149        try:
    150150            # FIXME: check-webkit-style shouldn't really have to apply the patch to check the style.
     
    152152            WebKitLandingScripts.run_webkit_script("check-webkit-style")
    153153        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"]))
    155155            log(e.output)
    156156
     
    170170    def __init__(self):
    171171        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)
    173173
    174174    def execute(self, options, args, tool):
     
    182182    def __init__(self):
    183183        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)
    185185
    186186    def execute(self, options, args, tool):
     
    211211
    212212        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"]))
    214214            scm.apply_patch(patch)
    215215            if options.local_commit:
    216216                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"])
    218218
    219219
     
    245245        while True:
    246246            output_line = child_process.stdout.readline()
    247             if output_line == '' and child_process.poll() != None:
     247            if output_line == "" and child_process.poll() != None:
    248248                return child_process.poll()
    249249            teed_output.write(output_line)
     
    322322        patches = bugs.fetch_patches_from_bug(bug_id)
    323323        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))
    327327                return
    328328        bugs.close_bug_as_fixed(bug_id, "All reviewed patches have been landed.  Closing bug.")
     
    331331    def _land_patch(cls, patch, options, tool):
    332332        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"]))
    334334        tool.scm().apply_patch(patch, force=options.non_interactive)
    335335
     
    338338        WebKitLandingScripts.ensure_builders_are_green(tool.buildbot, options)
    339339        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)
    341341
    342342    @classmethod
     
    345345            cls._land_patch(patch, options, tool)
    346346            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"])
    348348        except CheckoutNeedsUpdate, e:
    349349            log("Commit failed because the checkout is out of date.  Please update and try again.")
     
    352352        except ScriptError, e:
    353353            # 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())
    355355            WorkQueue.exit_after_handled_error(e)
    356356
     
    362362        ]
    363363        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)
    365365
    366366    def guess_reviewer_from_bug(self, bugs, bug_id):
     
    370370            return None
    371371        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))
    374374        return reviewer
    375375
     
    423423        bugs_to_patches = {}
    424424        for patch in patches:
    425             bug_id = patch['bug_id']
     425            bug_id = patch["bug_id"]
    426426            bugs_to_patches[bug_id] = bugs_to_patches.get(bug_id, []).append(patch)
    427427        return bugs_to_patches
     
    447447class LandAttachment(AbstractPatchLandingCommand):
    448448    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]")
    450450
    451451    @staticmethod
     
    456456class LandPatchesFromBugs(AbstractPatchLandingCommand):
    457457    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]")
    459459
    460460    @staticmethod
     
    470470class CommitMessageForCurrentDiff(Command):
    471471    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.")
    473473
    474474    def execute(self, options, args, tool):
     
    479479class ObsoleteAttachmentsOnBug(Command):
    480480    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")
    482482
    483483    def execute(self, options, args, tool):
     
    485485        attachments = tool.bugs.fetch_attachments_from_bug(bug_id)
    486486        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"])
    489489
    490490
     
    492492    def __init__(self):
    493493        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\")"),
    495495        ]
    496496        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)
    498498
    499499    @staticmethod
     
    509509        patches = bugs.fetch_patches_from_bug(bug_id)
    510510        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))
    512512            for patch in patches:
    513                 bugs.obsolete_attachment(patch['id'])
     513                bugs.obsolete_attachment(patch["id"])
    514514
    515515    def execute(self, options, args, tool):
     
    537537        ]
    538538        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)
    540540
    541541    def _comment_text_for_commit(self, options, commit_message, tool, commit_id):
     
    557557        commit_ids = tool.scm().commit_ids_from_commitish_arguments(args)
    558558        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))))
    560560
    561561        have_obsoleted_patches = set()
     
    584584        options += WebKitLandingScripts.cleaning_options()
    585585        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)
    587587
    588588    @staticmethod
     
    630630        # Once we trust rollout we will remove this option.
    631631        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)
    633633        else:
    634634            comment_text = WebKitLandingScripts.build_and_commit(tool.scm(), options)
     
    645645            make_option("--request-commit", action="store_true", dest="request_commit", default=False, help="Mark the patch as needing auto-commit after review."),
    646646        ]
    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)
    648648
    649649    def create_bug_from_commit(self, options, args, tool):
     
    701701            # place.
    702702            pass
    703         comment_text = ''.join(lines)
     703        comment_text = "".join(lines)
    704704        return (bug_title, comment_text)
    705705
     
    715715class CheckTreeStatus(Command):
    716716    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.")
    718718
    719719    def execute(self, options, args, tool):
    720720        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"])
    723723
    724724
     
    730730            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."),
    731731        ]
    732         Command.__init__(self, 'Run the %s.' % self._name, options=options)
     732        Command.__init__(self, "Run the %s." % self._name, options=options)
    733733
    734734    def queue_log_path(self):
    735         return '%s.log' % self._name
     735        return "%s.log" % self._name
    736736
    737737    def work_logs_directory(self):
    738         return '%s-logs' % self._name
     738        return "%s-logs" % self._name
    739739
    740740    def status_host(self):
     
    744744        log("CAUTION: %s will discard all local changes in %s" % (self._name, self.tool.scm().checkout_root))
    745745        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"):
    748748                error("User declined.")
    749749        log("Running WebKit %s. %s" % (self._name, datetime.now().strftime(WorkQueue.log_date_format)))
     
    771771
    772772    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)))
    774774
    775775    def execute(self, options, args, tool):
     
    795795        red_builders_names = self.tool.buildbot.red_core_builders_names()
    796796        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.
    798798            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"])
    800800
    801801    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"]])
    803803
    804804    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)
    806806
    807807
     
    823823
    824824    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"])
    826826
    827827    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"]])
    829829
    830830    def handle_unexpected_error(self, patch, message):
     
    847847        self.print_usage(sys.stderr)
    848848        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"
    850850        self.exit(2, error_message)
    851851
     
    857857        self.buildbot = BuildBot()
    858858        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() },
    877877        ]
    878878
     
    882882    def scm(self):
    883883        # 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(".")
    885885        if not self.cached_scm:
    886886            self.cached_scm = detect_scm_system(original_cwd)
     
    907907        scm_supports_local_commits = self.scm().supports_local_commits()
    908908        for command in self.commands:
    909             command_object = command['object']
     909            command_object = command["object"]
    910910            if command_object.requires_local_commits and not scm_supports_local_commits:
    911911                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 })
    914914            longest_name_length = max([longest_name_length, len(command_name_and_args)])
    915915       
     
    920920       
    921921        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"
    924924            commands_text += command_object.option_parser.format_option_help(formatter)
    925925        return commands_text
     
    928928        (options, args) = self.global_option_parser.parse_args(args)
    929929        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 "-"
    931931            self.global_option_parser.error("Extra arguments before command: " + args)
    932932       
     
    937937    @staticmethod
    938938    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.
    940940        command_index = 0
    941941        for arg in args:
    942             if arg[0] != '-':
     942            if arg[0] != "-":
    943943                break
    944944            command_index += 1
     
    953953    def command_by_name(self, command_name):
    954954        for command in self.commands:
    955             if command_name == command['name']:
     955            if command_name == command["name"]:
    956956                return command
    957957        return None
     
    970970            self.global_option_parser.error(command_name + " is not a recognized command")
    971971
    972         command_object = command['object']
     972        command_object = command["object"]
    973973
    974974        if command_object.requires_local_commits and not self.scm().supports_local_commits():
Note: See TracChangeset for help on using the changeset viewer.