Changeset 70020 in webkit
- Timestamp:
- Oct 18, 2010 7:44:21 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r70019 r70020 1 2010-10-18 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Implement webkit-patch suggest-reviewers 6 https://bugs.webkit.org/show_bug.cgi?id=47866 7 8 * Scripts/webkitpy/common/checkout/api.py: 9 - The main logic. We look at the last five changes to each 10 modified (non-ChangeLog) file and collect up the reviewers of 11 those changes as well as the authors of those changes who are 12 reviewers. 13 * Scripts/webkitpy/common/checkout/api_unittest.py: 14 - Test the logic with some fun mocks. 15 * Scripts/webkitpy/common/checkout/scm.py: 16 - Fix a bug when you have local git commits. 17 * Scripts/webkitpy/common/checkout/scm_unittest.py: 18 - Test that the bug is fixed. 19 * Scripts/webkitpy/tool/commands/queries.py: 20 - Add the query. 21 1 22 2010-10-18 Kenneth Russell <kbr@google.com> 2 23 -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/api.py
r63004 r70020 84 84 return self.commit_info_for_revision(revision).bug_id() 85 85 86 def modified_changelogs(self, git_commit):86 def _modified_files_matching_predicate(self, git_commit, predicate): 87 87 # SCM returns paths relative to scm.checkout_root 88 88 # Callers (especially those using the ChangeLog class) may … … 90 90 changed_files = self._scm.changed_files(git_commit) 91 91 absolute_paths = [os.path.join(self._scm.checkout_root, path) for path in changed_files] 92 return [path for path in absolute_paths if self._is_path_to_changelog(path)] 92 return [path for path in absolute_paths if predicate(path)] 93 94 def modified_changelogs(self, git_commit): 95 return self._modified_files_matching_predicate(git_commit, self._is_path_to_changelog) 96 97 def modified_non_changelogs(self, git_commit): 98 return self._modified_files_matching_predicate(git_commit, lambda path: not self._is_path_to_changelog(path)) 93 99 94 100 def commit_message_for_this_commit(self, git_commit): … … 109 115 # FIXME: We should sort and label the ChangeLog messages like commit-log-editor does. 110 116 return CommitMessage("".join(changelog_messages).splitlines()) 117 118 def suggested_reviewers(self, git_commit): 119 changed_files = self.modified_non_changelogs(git_commit) 120 revisions = set(sum(map(self._scm.revisions_changing_file, changed_files), [])) 121 commit_infos = set(map(self.commit_info_for_revision, revisions)) 122 reviewers = [commit_info.reviewer() for commit_info in commit_infos if commit_info.reviewer()] 123 reviewers.extend([commit_info.author() for commit_info in commit_infos if commit_info.author() and commit_info.author().can_review]) 124 return sorted(set(reviewers)) 111 125 112 126 def bug_id_for_this_commit(self, git_commit): -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/api_unittest.py
r63004 r70020 174 174 expected_changlogs = ["/foo/bar/ChangeLog", "/foo/bar/relative/path/ChangeLog"] 175 175 self.assertEqual(checkout.modified_changelogs(git_commit=None), expected_changlogs) 176 177 def test_suggested_reviewers(self): 178 def mock_changelog_entries_for_revision(revision): 179 if revision % 2 == 0: 180 return [ChangeLogEntry(_changelog1entry1)] 181 return [ChangeLogEntry(_changelog1entry2)] 182 183 def mock_revisions_changing_file(path, limit=5): 184 if path.endswith("ChangeLog"): 185 return [3] 186 return [4, 8] 187 188 scm = Mock() 189 scm.checkout_root = "/foo/bar" 190 scm.changed_files = lambda git_commit: ["file1", "file2", "relative/path/ChangeLog"] 191 scm.revisions_changing_file = mock_revisions_changing_file 192 checkout = Checkout(scm) 193 checkout.changelog_entries_for_revision = mock_changelog_entries_for_revision 194 reviewers = checkout.suggested_reviewers(git_commit=None) 195 reviewer_names = [reviewer.full_name for reviewer in reviewers] 196 self.assertEqual(reviewer_names, [u'Tor Arne Vestb\xf8']) -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
r70014 r70020 669 669 def revisions_changing_file(self, path, limit=5): 670 670 commit_ids = self.run(["git", "log", "--pretty=format:%H", "-%s" % limit, path]).splitlines() 671 return map(self.svn_revision_from_git_commit, commit_ids)671 return filter(lambda revision: revision, map(self.svn_revision_from_git_commit, commit_ids)) 672 672 673 673 def conflicted_files(self): … … 707 707 708 708 def svn_revision_from_git_commit(self, commit_id): 709 return int(self.run(['git', 'svn', 'find-rev', commit_id]).rstrip()) 709 try: 710 return int(self.run(['git', 'svn', 'find-rev', commit_id]).rstrip()) 711 except ValueError, e: 712 return None 710 713 711 714 def contents_at_revision(self, path, revision): -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
r70014 r70020 972 972 self._two_local_commits() 973 973 974 def test_revisions_changing_files_with_local_commit(self): 975 self._one_local_commit() 976 self.assertEquals(self.scm.revisions_changing_file('test_file_commit1'), []) 977 974 978 def test_commit_with_message(self): 975 979 self._one_local_commit_plus_working_copy_changes() -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/queries.py
r68813 r70020 31 31 from optparse import make_option 32 32 33 import webkitpy.tool.steps as steps 34 33 35 from webkitpy.common.checkout.commitinfo import CommitInfo 34 36 from webkitpy.common.config.committers import CommitterList … … 40 42 from webkitpy.common.system.deprecated_logging import log 41 43 from webkitpy.layout_tests import port 44 45 46 class SuggestReviewers(AbstractDeclarativeCommand): 47 name = "suggest-reviewers" 48 help_text = "Suggest reviewers for a patch based on recent changes to the modified files." 49 50 def __init__(self): 51 options = [ 52 steps.Options.git_commit, 53 ] 54 AbstractDeclarativeCommand.__init__(self, options=options) 55 56 def execute(self, options, args, tool): 57 reviewers = tool.checkout().suggested_reviewers(options.git_commit) 58 print "\n".join([reviewer.full_name for reviewer in reviewers]) 42 59 43 60
Note: See TracChangeset
for help on using the changeset viewer.