Changeset 56216 in webkit


Ignore:
Timestamp:
Mar 18, 2010 11:46:10 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-18 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Split out CommitInfo class and add unit tests
https://bugs.webkit.org/show_bug.cgi?id=36343

Move more logic out of "what-broke" into a shared CommitInfo
class so that it can be used by other commands and unit tested.

  • Scripts/webkitpy/commands/queries.py:
  • Scripts/webkitpy/commitinfo.py: Added.
  • Scripts/webkitpy/commitinfo_unittest.py: Added.
  • Scripts/webkitpy/unittests.py:
Location:
trunk/WebKitTools
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r56211 r56216  
     12010-03-18  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Split out CommitInfo class and add unit tests
     6        https://bugs.webkit.org/show_bug.cgi?id=36343
     7
     8        Move more logic out of "what-broke" into a shared CommitInfo
     9        class so that it can be used by other commands and unit tested.
     10
     11        * Scripts/webkitpy/commands/queries.py:
     12        * Scripts/webkitpy/commitinfo.py: Added.
     13        * Scripts/webkitpy/commitinfo_unittest.py: Added.
     14        * Scripts/webkitpy/unittests.py:
     15
    1162010-03-18  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
    217
  • trunk/WebKitTools/Scripts/webkitpy/commands/queries.py

    r56176 r56216  
    3131
    3232from optparse import make_option
    33 import StringIO
    3433
    3534from webkitpy.buildbot import BuildBot
    36 from webkitpy.bugzilla import parse_bug_id
    37 from webkitpy.changelogs import ChangeLog, is_path_to_changelog, view_source_url
     35from webkitpy.changelogs import view_source_url
     36from webkitpy.commitinfo import CommitInfo
    3837from webkitpy.committers import CommitterList
    3938from webkitpy.grammar import pluralize
     
    141140        print "%s : %s" % (builder_name.ljust(max_name_width), status_message)
    142141
    143     def _changelog_entries_for_revision(self, revision):
    144         changed_files = self.tool.scm().changed_files_for_revision(revision)
    145         changelog_paths = [path for path in changed_files if is_path_to_changelog(path)]
    146         changelog_entries = []
    147         for changelog_path in changelog_paths:
    148             changelog_contents = self.tool.scm().contents_at_revision(changelog_path, revision)
    149             changelog_file = StringIO.StringIO(changelog_contents)
    150             changelog_entry = ChangeLog.parse_latest_entry_from_file(changelog_file)
    151             changelog_entries.append(changelog_entry)
    152         return changelog_entries
    153 
    154     def _commit_info_for_revision(self, revision):
    155         committer_email = self.tool.scm().committer_email_for_revision(revision)
    156         changelog_entries = self._changelog_entries_for_revision(revision)
    157         # Assume for now that the first entry has everything we need:
    158         changelog_entry = changelog_entries[0]
    159         committer_list = CommitterList()
    160         # FIXME: This should be a CommitInfo object.
    161         return {
    162             "bug_id" : parse_bug_id(changelog_entry.contents()),
    163             "revision" : revision,
    164             "author_name" : changelog_entry.author_name(),
    165             "author_email" : changelog_entry.author_email(),
    166             "author" : committer_list.committer_by_email(changelog_entry.author_email()) or committer_list.committer_by_name(changelog_entry.author_name()),
    167             "reviewer_text" : changelog_entry.reviewer_text(), # FIXME: Eventualy we should return an object here.
    168             "reviewer" : committer_list.committer_by_name(changelog_entry.reviewer_text()),
    169             "committer_email" : committer_email,
    170             "committer" : committer_list.committer_by_email(committer_email) if committer_email else None
    171         }
    172 
    173     # FIXME: This should be on some CommitInfo object.
    174142    def _print_blame_information_for_commit(self, commit_info):
    175         print "r%s:" % commit_info["revision"]
    176         print "  %s" % view_source_url(commit_info["revision"])
    177         print "  Bug: %s (%s)" % (commit_info["bug_id"], self.tool.bugs.bug_url_for_bug_id(commit_info["bug_id"]))
    178         author_line = "\"%s\" <%s>" % (commit_info["author_name"], commit_info["author_email"])
    179         print "  Author: %s" % (commit_info["author"] or author_line)
    180         print "  Reviewer: %s" % (commit_info["reviewer"] or commit_info["reviewer_text"])
    181         print "  Committer: %s" % (commit_info["committer"] or commit_info["committer_email"])
     143        print "r%s:" % commit_info.revision()
     144        print "  %s" % view_source_url(commit_info.revision())
     145        print "  Bug: %s (%s)" % (commit_info.bug_id(), self.tool.bugs.bug_url_for_bug_id(commit_info.bug_id()))
     146        author_line = "\"%s\" <%s>" % (commit_info.author_name(), commit_info.author_email())
     147        print "  Author: %s" % (commit_info.author() or author_line)
     148        print "  Reviewer: %s" % (commit_info.reviewer() or commit_info.reviewer_text())
     149        print "  Committer: %s" % commit_info.committer()
    182150
    183151    def _print_blame_information_for_builder(self, builder_status, name_width):
     
    192160        self._print_builder_line(builder_status["name"], name_width, "FAIL (blame-list: %s)" % suspect_revisions)
    193161        for revision in suspect_revisions:
    194             commit_info = self._commit_info_for_revision(revision)
     162            commit_info = CommitInfo.commit_info_for_revision(self.tool.scm(), revision)
    195163            self._print_blame_information_for_commit(commit_info)
    196164
  • trunk/WebKitTools/Scripts/webkitpy/unittests.py

    r56181 r56216  
    4242from webkitpy.commands.queues_unittest import *
    4343from webkitpy.commands.sheriffbot_unittest import *
     44from webkitpy.commitinfo_unittest import *
    4445from webkitpy.committers_unittest import *
    4546from webkitpy.credentials_unittest import *
Note: See TracChangeset for help on using the changeset viewer.