Changeset 52599 in webkit


Ignore:
Timestamp:
Dec 28, 2009 9:06:28 AM (14 years ago)
Author:
eric@webkit.org
Message:

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

Reviewed by Eric Seidel.

[bzt] Create an ASAD command for uploading a patch
https://bugs.webkit.org/show_bug.cgi?id=32979

The create-review command goes through the whole process of preparing a
code review, including creating a bug, editing the ChangeLogs, and
uploading the patch. It is indeed the All Sing, All Dance upload
command.

  • Scripts/modules/buildsteps.py:
  • Scripts/modules/commands/upload.py:
  • Scripts/modules/commands/upload_unittest.py:
  • Scripts/modules/mock_bugzillatool.py:
  • Scripts/modules/user.py:
Location:
trunk/WebKitTools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r52595 r52599  
     12009-12-28  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [bzt] Create an ASAD command for uploading a patch
     6        https://bugs.webkit.org/show_bug.cgi?id=32979
     7
     8        The create-review command goes through the whole process of preparing a
     9        code review, including creating a bug, editing the ChangeLogs, and
     10        uploading the patch.  It is indeed the All Sing, All Dance upload
     11        command.
     12
     13        * Scripts/modules/buildsteps.py:
     14        * Scripts/modules/commands/upload.py:
     15        * Scripts/modules/commands/upload_unittest.py:
     16        * Scripts/modules/mock_bugzillatool.py:
     17        * Scripts/modules/user.py:
     18
    1192009-12-28  Adam Barth  <abarth@webkit.org>
    220
  • trunk/WebKitTools/Scripts/modules/buildsteps.py

    r52528 r52599  
    6060    cc = make_option("--cc", action="store", type="string", dest="cc", help="Comma-separated list of email addresses to carbon-copy.")
    6161    component = make_option("--component", action="store", type="string", dest="component", help="Component for the new bug.")
     62    confirm = make_option("--no-confirm", action="store_false", dest="confirm", default=True, help="Skip confirmation steps.")
    6263
    6364
     
    161162
    162163
     164class EditChangeLogStep(AbstractStep):
     165    def run(self, state):
     166        self._tool.user.edit(self._tool.scm().modified_changelogs())
     167
     168
    163169class ObsoletePatchesOnBugStep(AbstractStep):
    164170    @classmethod
     
    180186
    181187
    182 class PostDiffToBugStep(AbstractStep):
     188class AbstractDiffStep(AbstractStep):
     189    def diff(self, state):
     190        diff = state.get("diff")
     191        if not diff:
     192            diff = self._tool.scm().create_patch()
     193            state["diff"] = diff
     194        return diff
     195
     196
     197class ConfirmDiffStep(AbstractDiffStep):
     198    @classmethod
     199    def options(cls):
     200        return [
     201            CommandOptions.confirm,
     202        ]
     203
     204    def run(self, state):
     205        if not self._options.confirm:
     206            return
     207        diff = self.diff(state)
     208        self._tool.user.page(diff)
     209        if not self._tool.user.confirm():
     210            error("User declined to continue.")
     211
     212
     213class PostDiffToBugStep(AbstractDiffStep):
    183214    @classmethod
    184215    def options(cls):
     
    190221
    191222    def run(self, state):
    192         diff = state.get("diff") or self._tool.scm().create_patch()
     223        diff = self.diff(state)
    193224        diff_file = StringIO.StringIO(diff) # add_patch_to_bug expects a file-like object
    194225        description = self._options.description or "Patch"
  • trunk/WebKitTools/Scripts/modules/commands/upload.py

    r52594 r52599  
    3737
    3838from modules.bugzilla import parse_bug_id
    39 from modules.buildsteps import PrepareChangeLogStep, CommandOptions, ObsoletePatchesOnBugStep, PostDiffToBugStep, PromptForBugOrTitleStep, CreateBugStep
     39from modules.buildsteps import PrepareChangeLogStep, EditChangeLogStep, ConfirmDiffStep, CommandOptions, ObsoletePatchesOnBugStep, PostDiffToBugStep, PromptForBugOrTitleStep, CreateBugStep
    4040from modules.commands.download import AbstractSequencedCommmand
    4141from modules.comments import bug_comment_from_svn_revision
     
    7373    show_in_main_help = True
    7474    steps = [
     75        ConfirmDiffStep,
    7576        ObsoletePatchesOnBugStep,
    7677        PostDiffToBugStep,
     
    9899        CreateBugStep,
    99100        PrepareChangeLogStep,
     101    ]
     102
     103    def _prepare_state(self, options, args, tool):
     104        bug_id = args and args[0]
     105        return { "bug_id" : bug_id }
     106
     107
     108class CreateReview(AbstractSequencedCommmand):
     109    name = "create-review"
     110    help_text = "Adds a ChangeLog to the current diff and posts it to a (possibly new) bug"
     111    argument_names = "[BUGID]"
     112    steps = [
     113        PromptForBugOrTitleStep,
     114        CreateBugStep,
     115        PrepareChangeLogStep,
     116        EditChangeLogStep,
     117        ConfirmDiffStep,
     118        ObsoletePatchesOnBugStep,
     119        PostDiffToBugStep,
    100120    ]
    101121
  • trunk/WebKitTools/Scripts/modules/commands/upload_unittest.py

    r52528 r52599  
    4646    def test_prepare_diff(self):
    4747        self.assert_execute_outputs(PrepareDiff(), [])
     48
     49    def test_create_review(self):
     50        expected_stderr = "Obsoleting 2 old patches on bug 42\n"
     51        self.assert_execute_outputs(CreateReview(), [42], expected_stderr=expected_stderr)
  • trunk/WebKitTools/Scripts/modules/mock_bugzillatool.py

    r52480 r52599  
    148148        return "Mock user response"
    149149
     150    def edit(self, files):
     151        pass
     152
     153    def page(self, message):
     154        pass
     155
     156    def confirm(self):
     157        return True
     158
    150159
    151160class MockStatusBot(object):
  • trunk/WebKitTools/Scripts/modules/user.py

    r52480 r52599  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29import os
     30import subprocess
     31
    2932class User(object):
    3033    def prompt(self, message):
    3134        return raw_input(message)
     35
     36    def edit(self, files):
     37        editor = os.environ.get("EDITOR") or "vi"
     38        subprocess.call([editor] + files)
     39
     40    def page(self, message):
     41        pager = os.environ.get("PAGER") or "less"
     42        child_process = subprocess.Popen([pager], stdin=subprocess.PIPE)
     43        child_process.communicate(input=message)
     44
     45    def confirm(self):
     46        response = raw_input("\nContinue? [Y/n]: ")
     47        return not response or response.lower() == "y"
Note: See TracChangeset for help on using the changeset viewer.