Changeset 47111 in webkit


Ignore:
Timestamp:
Aug 12, 2009 9:26:19 AM (15 years ago)
Author:
eric@webkit.org
Message:

2009-08-11 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

bugzilla-tool : various improvements for running the commit-queue
https://bugs.webkit.org/show_bug.cgi?id=28199

Make run_and_throw_if_fail silence STDERR as well as STDIN.
I also changed run_and_throw_if_fail to use the /dev/null trick instead of .communicate() to avoid ever buffering the out
Change a few "print" statements to "log" so they appear in the output.
Changed all string + uses to use string formatting instead (this is less error prone as it will automatically convert non
Added a little more logging so that --quiet mode is easier to understand.
Changed clear_attachment_review_flag to clear_attachment_flags and made it clear the commit-queue flag as well.
Added the ability for bugzilla-tool to reject patches from the commit-queue when they fail to compile/apply/etc.
Added _find_select_element_for_flag to make the code for finding flag <select> elements clearer.
Made curl call (downloading patch files) quieter.

  • Scripts/bugzilla-tool:
  • Scripts/modules/bugzilla.py:
  • Scripts/modules/scm.py:
Location:
trunk/WebKitTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r47109 r47111  
     12009-08-11  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        bugzilla-tool : various improvements for running the commit-queue
     6        https://bugs.webkit.org/show_bug.cgi?id=28199
     7
     8        Make run_and_throw_if_fail silence STDERR as well as STDIN.
     9        I also changed run_and_throw_if_fail to use the /dev/null trick instead of .communicate() to avoid ever buffering the out
     10        Change a few "print" statements to "log" so they appear in the output.
     11        Changed all string + uses to use string formatting instead (this is less error prone as it will automatically convert non
     12        Added a little more logging so that --quiet mode is easier to understand.
     13        Changed clear_attachment_review_flag to clear_attachment_flags and made it clear the commit-queue flag as well.
     14        Added the ability for bugzilla-tool to reject patches from the commit-queue when they fail to compile/apply/etc.
     15        Added _find_select_element_for_flag to make the code for finding flag <select> elements clearer.
     16        Made curl call (downloading patch files) quieter.
     17
     18        * Scripts/bugzilla-tool:
     19        * Scripts/modules/bugzilla.py:
     20        * Scripts/modules/scm.py:
     21
    1222009-08-11  Eric Seidel  <eric@webkit.org>
    223
  • trunk/WebKitTools/Scripts/bugzilla-tool

    r47069 r47111  
    243243     @staticmethod
    244244     def run_and_throw_if_fail(args, quiet=False):
    245          child_stdout = subprocess.PIPE if quiet else None
    246          child_process = subprocess.Popen(args, stdout=child_stdout)
    247          if child_process.stdout:
    248              child_process.communicate()
     245         # Passing None will use the default input/outputs
     246         child_output = open(os.devnull, "w") if quiet else None
     247
     248         child_process = subprocess.Popen(args, stdout=child_output, stderr=child_output)
    249249         return_code = child_process.wait()
     250
     251         if child_output:
     252             child_output.close()
     253
    250254         if return_code:
    251255             raise ScriptError("%s failed with exit code %d" % (" ".join(args), return_code))
     
    258262     @classmethod
    259263     def run_webkit_script(cls, script_name, quiet=False):
    260          print "Running WebKit Script " + script_name
     264         log("Running %s" % script_name)
    261265         cls.run_and_throw_if_fail(cls.webkit_script_path(script_name), quiet)
    262266
     
    357361            for patch in patches:
    358362                tool.scm().update_webkit() # Update before every patch in case the tree has changed
     363                log("Applying %s from bug %s." % (patch['id'], bug_id))
    359364                tool.scm().apply_patch(patch, force=options.commit_queue)
    360365                comment_text = WebKitLandingScripts.build_and_commit(tool.scm(), options)
    361                 tool.bugs.clear_attachment_review_flag(patch['id'], comment_text)
     366                tool.bugs.clear_attachment_flags(patch['id'], comment_text)
    362367
    363368            if options.close_bug:
    364369                tool.bugs.close_bug_as_fixed(bug_id, "All reviewed patches have been landed.  Closing bug.")
    365370        except ScriptError, e:
     371            tool.bugs.reject_patch_from_commit_queue(patch['id'], e)
    366372            # We should add a comment to the bug, and r- the patch on failure
    367373            error(e)
     
    379385            else:
    380386                patches = tool.bugs.fetch_reviewed_patches_from_bug(bug_id)
    381             if not len(patches):
    382                 log("No reviewed patches found on %s." % bug_id)
    383                 continue
    384             patch_count += len(patches)
    385             bugs_to_patches[bug_id] = patches
     387
     388            patches_found = len(patches)
     389            log("%s found on %s." % (pluralize("reviewed patch", patches_found), bug_id))
     390
     391            patch_count += patches_found
     392            if patches_found:
     393                bugs_to_patches[bug_id] = patches
    386394
    387395        log("Landing %s from %s." % (pluralize("patch", patch_count), pluralize("bug", len(args))))
     
    545553    def prompt_for_bug_title_and_comment(self):
    546554        bug_title = raw_input("Bug title: ")
    547         print("Bug comment (hit ^D on blank line to end):")
     555        print "Bug comment (hit ^D on blank line to end):"
    548556        lines = sys.stdin.readlines()
    549557        sys.stdin.seek(0, os.SEEK_END)
  • trunk/WebKitTools/Scripts/modules/bugzilla.py

    r46755 r47111  
    9696def read_config(key):
    9797    # Need a way to read from svn too
    98     config_process = subprocess.Popen("git config --get bugzilla." + key, stdout=subprocess.PIPE, shell=True)
     98    config_process = subprocess.Popen("git config --get bugzilla.%s" % key, stdout=subprocess.PIPE, shell=True)
    9999    value = config_process.communicate()[0]
    100100    return_code = config_process.wait()
     
    142142        action_param = ""
    143143        if action and action != "view":
    144             action_param = "&action=" + action
     144            action_param = "&action=%s" % action
    145145        return "%sattachment.cgi?id=%s%s" % (self.bug_server_url, attachment_id, action_param)
    146146
     
    171171    def fetch_attachments_from_bug(self, bug_id):
    172172        bug_url = self.bug_url_for_bug_id(bug_id, xml=True)
    173         log("Fetching: " + bug_url)
     173        log("Fetching: %s" % bug_url)
    174174
    175175        page = urllib2.urlopen(bug_url)
     
    258258            return
    259259       
    260         self.browser.open(self.bug_server_url + "attachment.cgi?action=enter&bugid=" + bug_id)
     260        self.browser.open("%sattachment.cgi?action=enter&bugid=%s" % (self.bug_server_url, bug_id))
    261261        self.browser.select_form(name="entryform")
    262262        self.browser['description'] = description
     
    318318        bug_id = self._check_create_bug_response(response.read())
    319319        log("Bug %s created." % bug_id)
    320         log(self.bug_server_url + "show_bug.cgi?id=" + bug_id)
     320        log("%sshow_bug.cgi?id=%s" % (self.bug_server_url, bug_id))
    321321        return bug_id
    322322
    323     def clear_attachment_review_flag(self, attachment_id, additional_comment_text=None):
    324         self.authenticate()
    325 
    326         comment_text = "Clearing review flag on attachment: %s" % attachment_id
     323    def _find_select_element_for_flag(self, flag_name):
     324        # FIXME: This will break if we ever re-order attachment flags
     325        if flag_name == "review":
     326            return self.browser.find_control(type='select', nr=0)
     327        if flag_name == "commit-queue":
     328            return self.browser.find_control(type='select', nr=1)
     329        raise Exception("Don't know how to find flag named \"%s\"" % flag_name)
     330
     331    def clear_attachment_flags(self, attachment_id, additional_comment_text=None):
     332        self.authenticate()
     333
     334        comment_text = "Clearing flags on attachment: %s" % attachment_id
    327335        if additional_comment_text:
    328             comment_text += "\n\n" + additional_comment_text
     336            comment_text += "\n\n%s" % additional_comment_text
    329337        log(comment_text)
    330338
     
    335343        self.browser.select_form(nr=1)
    336344        self.browser.set_value(comment_text, name='comment', nr=0)
    337         self.browser.find_control(type='select', nr=0).value = ("X",)
     345        self._find_select_element_for_flag('review').value = ("X",)
     346        self._find_select_element_for_flag('commit-queue').value = ("X",)
     347        self.browser.submit()
     348
     349    # FIXME: We need a way to test this on a live bugzilla instance.
     350    def reject_patch_from_commit_queue(self, attachment_id, additional_comment_text=None):
     351        self.authenticate()
     352
     353        comment_text = "Rejecting patch %s from commit-queue.  This patch will require manual commit." % attachment_id
     354        if additional_comment_text:
     355            comment_text += "\n\n%s" % additional_comment_text
     356        log(comment_text)
     357
     358        if self.dryrun:
     359            return
     360
     361        self.browser.open(self.attachment_url_for_id(attachment_id, 'edit'))
     362        self.browser.select_form(nr=1)
     363        self.browser.set_value(comment_text, name='comment', nr=0)
     364        self._find_select_element_for_flag('commit-queue').value = ("-",)
    338365        self.browser.submit()
    339366
     
    350377        self.browser.find_control('isobsolete').items[0].selected = True
    351378        # Also clear any review flag (to remove it from review/commit queues)
    352         self.browser.find_control(type='select', nr=0).value = ("X",)
     379        self._find_select_element_for_flag('review').value = ("X",)
     380        self._find_select_element_for_flag('commit-queue').value = ("X",)
    353381        if comment_text:
    354382            log(comment_text)
  • trunk/WebKitTools/Scripts/modules/scm.py

    r47005 r47111  
    124124        # It's possible that the patch was not made from the root directory.
    125125        # We should detect and handle that case.
    126         curl_process = subprocess.Popen(['curl', patch['url']], stdout=subprocess.PIPE)
     126        curl_process = subprocess.Popen(['curl', '--silent', '--show-error', patch['url']], stdout=subprocess.PIPE)
    127127        args = [self.script_path('svn-apply'), '--reviewer', patch['reviewer']]
    128128        if force:
Note: See TracChangeset for help on using the changeset viewer.