Changeset 52148 in webkit


Ignore:
Timestamp:
Dec 15, 2009 3:12:22 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2009-12-15 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

We have two mark-fixed commands
https://bugs.webkit.org/show_bug.cgi?id=32073

  • Scripts/mark-bug-fixed: Removed.
  • Scripts/modules/commands/upload.py:
  • Scripts/modules/commands/upload_unittest.py:
Location:
trunk/WebKitTools
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r52147 r52148  
     12009-12-15  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        We have two mark-fixed commands
     6        https://bugs.webkit.org/show_bug.cgi?id=32073
     7
     8        * Scripts/mark-bug-fixed: Removed.
     9        * Scripts/modules/commands/upload.py:
     10        * Scripts/modules/commands/upload_unittest.py:
     11
    1122009-12-15  Eric Seidel  <eric@webkit.org>
    213
  • trunk/WebKitTools/Scripts/modules/commands/upload.py

    r51590 r52148  
    3030
    3131import os
     32import re
    3233import StringIO
    3334import sys
     
    3637
    3738from modules.bugzilla import parse_bug_id
     39from modules.comments import bug_comment_from_svn_revision
    3840from modules.grammar import pluralize
    3941from modules.logging import error, log
     
    157159
    158160
    159 class MarkFixed(Command):
    160     name = "mark-fixed"
    161     show_in_main_help = False
    162     def __init__(self):
    163         Command.__init__(self, "Mark the specified bug as fixed", "BUG_ID REASON")
    164 
    165     def execute(self, options, args, tool):
    166         tool.bugs.close_bug_as_fixed(args[0], args[1])
     161# FIXME: Requires unit test.  Blocking issue: too complex for now.
     162class MarkBugFixed(Command):
     163    name = "mark-bug-fixed"
     164    show_in_main_help = True
     165    def __init__(self):
     166        options = [
     167            make_option("--bug-id", action="store", type="string", dest="bug_id", help="Specify bug id if no URL is provided in the commit log."),
     168            make_option("--comment", action="store", type="string", dest="comment", help="Text to include in bug comment."),
     169            make_option("--open", action="store_true", default=False, dest="open_bug", help="Open bug in default web browser (Mac only)."),
     170            make_option("--update-only", action="store_true", default=False, dest="update_only", help="Add comment to the bug, but do not close it."),
     171        ]
     172        Command.__init__(self, "Mark the specified bug as fixed", "[SVN_REVISION]", options=options)
     173
     174    def _fetch_commit_log(self, tool, svn_revision):
     175        if not svn_revision:
     176            return tool.scm().last_svn_commit_log()
     177        return tool.scm().svn_commit_log(svn_revision)
     178
     179    def _determine_bug_id_and_svn_revision(self, tool, bug_id, svn_revision):
     180        commit_log = self._fetch_commit_log(tool, svn_revision)
     181
     182        if not bug_id:
     183            bug_id = parse_bug_id(commit_log)
     184
     185        if not svn_revision:
     186            match = re.search("^r(?P<svn_revision>\d+) \|", commit_log, re.MULTILINE)
     187            if match:
     188                svn_revision = match.group('svn_revision')
     189
     190        if not bug_id or not svn_revision:
     191            not_found = []
     192            if not bug_id:
     193                not_found.append("bug id")
     194            if not svn_revision:
     195                not_found.append("svn revision")
     196            error("Could not find %s on command-line or in %s."
     197                  % (" or ".join(not_found), "r%s" % svn_revision if svn_revision else "last commit"))
     198
     199        return (bug_id, svn_revision)
     200
     201    def _open_bug_in_web_browser(self, tool, bug_id):
     202        if sys.platform == "darwin":
     203            tool.executive.run_command(["open", tool.bugs.short_bug_url_for_bug_id(bug_id)])
     204            return
     205        log("WARNING: --open is only supported on Mac OS X.")
     206
     207    def _prompt_user_for_correctness(self, bug_id, svn_revision):
     208        answer = raw_input("Is this correct (y/N)? ")
     209        if not re.match("^\s*y(es)?", answer, re.IGNORECASE):
     210            exit(1)
     211
     212    def execute(self, options, args, tool):
     213        bug_id = options.bug_id
     214
     215        svn_revision = args and args[0]
     216        if svn_revision:
     217            if re.match("^r[0-9]+$", svn_revision, re.IGNORECASE):
     218                svn_revision = svn_revision[1:]
     219            if not re.match("^[0-9]+$", svn_revision):
     220                error("Invalid svn revision: '%s'" % svn_revision)
     221
     222        needs_prompt = False
     223        if not bug_id or not svn_revision:
     224            needs_prompt = True
     225            (bug_id, svn_revision) = self._determine_bug_id_and_svn_revision(tool, bug_id, svn_revision)
     226
     227        log("Bug: <%s> %s" % (tool.bugs.short_bug_url_for_bug_id(bug_id), tool.bugs.fetch_title_from_bug(bug_id)))
     228        log("Revision: %s" % svn_revision)
     229
     230        if options.open_bug:
     231            self._open_bug_in_web_browser(tool, bug_id)
     232
     233        if needs_prompt:
     234            self._prompt_user_for_correctness(bug_id, svn_revision)
     235
     236        bug_comment = bug_comment_from_svn_revision(svn_revision)
     237        if options.comment:
     238            bug_comment = "%s\n\n%s" % (options.comment, bug_comment)
     239
     240        if options.update_only:
     241            log("Adding comment to Bug %s." % bug_id)
     242            tool.bugs.post_comment_to_bug(bug_id, bug_comment)
     243        else:
     244            log("Adding comment to Bug %s and marking as Resolved/Fixed." % bug_id)
     245            tool.bugs.close_bug_as_fixed(bug_id, bug_comment)
    167246
    168247
  • trunk/WebKitTools/Scripts/modules/commands/upload_unittest.py

    r52025 r52148  
    3333
    3434class UploadCommandsTest(CommandsTest):
    35     def test_mark_fixed(self):
    36         self.assert_execute_outputs(MarkFixed(), [43, "Test comment"])
    37 
    3835    def test_obsolete_attachments(self):
    3936        self.assert_execute_outputs(ObsoleteAttachments(), [42])
Note: See TracChangeset for help on using the changeset viewer.