Changeset 56632 in webkit


Ignore:
Timestamp:
Mar 26, 2010 10:32:31 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-26 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove some evil statics from CommitInfo
https://bugs.webkit.org/show_bug.cgi?id=36637

These methods should really be on checkout. You can tell because they
know about ChangeLogs and take an SCM as an argument. :)

  • Scripts/webkitpy/common/checkout/api.py:
  • Scripts/webkitpy/common/checkout/changelog.py:
  • Scripts/webkitpy/common/checkout/commitinfo.py:
  • Scripts/webkitpy/tool/commands/queries.py:
Location:
trunk/WebKitTools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r56618 r56632  
     12010-03-26  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Remove some evil statics from CommitInfo
     6        https://bugs.webkit.org/show_bug.cgi?id=36637
     7
     8        These methods should really be on checkout.  You can tell because they
     9        know about ChangeLogs and take an SCM as an argument.  :)
     10
     11        * Scripts/webkitpy/common/checkout/api.py:
     12        * Scripts/webkitpy/common/checkout/changelog.py:
     13        * Scripts/webkitpy/common/checkout/commitinfo.py:
     14        * Scripts/webkitpy/tool/commands/queries.py:
     15
    1162010-03-23  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
    217
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/api.py

    r56601 r56632  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29import os
    2930import subprocess
    3031
    31 from webkitpy.common.checkout.changelog import ChangeLog, is_path_to_changelog
     32from webkitpy.common.checkout.changelog import ChangeLog
    3233from webkitpy.common.checkout.commitinfo import CommitInfo
    3334from webkitpy.common.checkout.scm import CommitMessage
     
    4344        self._scm = scm
    4445
    45     def commit_info_for_revision(self, svn_revision):
    46         return CommitInfo.commit_info_for_revision(self._scm, svn_revision)
     46    def _is_path_to_changelog(self, path):
     47        return os.path.basename(path) == "ChangeLog"
     48
     49    def _latest_entry_for_changelog_at_revision(self, changelog_path, revision):
     50        changelog_contents = self._scm.contents_at_revision(changelog_path, revision)
     51        return ChangeLog.parse_latest_entry_from_file(StringIO.StringIO(changelog_contents))
     52
     53    def changelog_entries_for_revision(self, revision):
     54        changed_files = self._scm.changed_files_for_revision(revision)
     55        return [self._latest_entry_for_changelog_at_revision(path, revision) for path in changed_files if self._is_path_to_changelog(path)]
     56
     57    def commit_info_for_revision(self, revision):
     58        committer_email = self._scm.committer_email_for_revision(revision)
     59        changelog_entries = self.changelog_entries_for_revision(revision)
     60        # Assume for now that the first entry has everything we need:
     61        changelog_entry = changelog_entries[0]
     62        changelog_data = {
     63            "bug_id": parse_bug_id(changelog_entry.contents()),
     64            "author_name": changelog_entry.author_name(),
     65            "author_email": changelog_entry.author_email(),
     66            "author": changelog_entry.author(),
     67            "reviewer_text": changelog_entry.reviewer_text(),
     68            "reviewer": changelog_entry.reviewer(),
     69        }
     70        # We could pass the changelog_entry instead of a dictionary here, but that makes
     71        # mocking slightly more involved, and would make aggregating data from multiple
     72        # entries more difficult to wire in if we need to do that in the future.
     73        return CommitInfo(revision, committer_email, changelog_data)
    4774
    4875    def modified_changelogs(self):
    49         return [path for path in self._scm.changed_files() if is_path_to_changelog(path)]
     76        return [path for path in self._scm.changed_files() if self._is_path_to_changelog(path)]
    5077
    5178    # FIXME: Requires unit test
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/changelog.py

    r56601 r56632  
    4242    # Maybe eventually a webkit_config.py?
    4343    return "http://trac.webkit.org/changeset/%s" % revision_number
    44 
    45 # Used by Checkout.modified_changelogs()
    46 def is_path_to_changelog(path):
    47     return os.path.basename(path) == "ChangeLog"
    4844
    4945
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/commitinfo.py

    r56510 r56632  
    3131import StringIO
    3232
    33 from webkitpy.common.checkout.changelog import ChangeLog, is_path_to_changelog
    3433from webkitpy.common.config.committers import CommitterList
    3534from webkitpy.common.net.bugzilla import parse_bug_id
     
    3736
    3837class CommitInfo(object):
    39     @classmethod
    40     def _latest_entry_for_changelog_at_revision(cls, scm, changelog_path, revision):
    41         changelog_contents = scm.contents_at_revision(changelog_path, revision)
    42         return ChangeLog.parse_latest_entry_from_file(StringIO.StringIO(changelog_contents))
    43 
    44     @classmethod
    45     def _changelog_entries_for_revision(cls, scm, revision):
    46         changed_files = scm.changed_files_for_revision(revision)
    47         return [cls._latest_entry_for_changelog_at_revision(scm, path, revision) for path in changed_files if is_path_to_changelog(path)]
    48 
    49     @classmethod
    50     def commit_info_for_revision(cls, scm, revision):
    51         committer_email = scm.committer_email_for_revision(revision)
    52         changelog_entries = cls._changelog_entries_for_revision(scm, revision)
    53         # Assume for now that the first entry has everything we need:
    54         changelog_entry = changelog_entries[0]
    55         changelog_data = {
    56             "bug_id": parse_bug_id(changelog_entry.contents()),
    57             "author_name": changelog_entry.author_name(),
    58             "author_email": changelog_entry.author_email(),
    59             "author": changelog_entry.author(),
    60             "reviewer_text": changelog_entry.reviewer_text(),
    61             "reviewer": changelog_entry.reviewer(),
    62         }
    63         # We could pass the changelog_entry instead of a dictionary here, but that makes
    64         # mocking slightly more involved, and would make aggregating data from multiple
    65         # entries more difficult to wire in if we need to do that in the future.
    66         return cls(revision, committer_email, changelog_data)
    67 
    6838    def __init__(self, revision, committer_email, changelog_data, committer_list=CommitterList()):
    6939        self._revision = revision
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/queries.py

    r56602 r56632  
    147147        self._print_builder_line(builder.name(), name_width, "FAIL (blame-list: %s%s)" % (suspect_revisions, first_failure_message))
    148148        for revision in suspect_revisions:
    149             commit_info = CommitInfo.commit_info_for_revision(self.tool.scm(), revision)
     149            commit_info = self.tool.checkout().commit_info_for_revision(revision)
    150150            self._print_blame_information_for_commit(commit_info)
    151151
Note: See TracChangeset for help on using the changeset viewer.