[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

abarth at webkit.org abarth at webkit.org
Wed Dec 22 14:44:38 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit b8bdbaa8df0da17daaa41d7e90827e504991b01d
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 19 02:44:21 2010 +0000

    2010-10-18  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            Implement webkit-patch suggest-reviewers
            https://bugs.webkit.org/show_bug.cgi?id=47866
    
            * Scripts/webkitpy/common/checkout/api.py:
                - The main logic.  We look at the last five changes to each
                  modified (non-ChangeLog) file and collect up the reviewers of
                  those changes as well as the authors of those changes who are
                  reviewers.
            * Scripts/webkitpy/common/checkout/api_unittest.py:
                - Test the logic with some fun mocks.
            * Scripts/webkitpy/common/checkout/scm.py:
                - Fix a bug when you have local git commits.
            * Scripts/webkitpy/common/checkout/scm_unittest.py:
                - Test that the bug is fixed.
            * Scripts/webkitpy/tool/commands/queries.py:
                - Add the query.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70020 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 5f40925..e44368c 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,24 @@
+2010-10-18  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Implement webkit-patch suggest-reviewers
+        https://bugs.webkit.org/show_bug.cgi?id=47866
+
+        * Scripts/webkitpy/common/checkout/api.py:
+            - The main logic.  We look at the last five changes to each
+              modified (non-ChangeLog) file and collect up the reviewers of
+              those changes as well as the authors of those changes who are
+              reviewers.
+        * Scripts/webkitpy/common/checkout/api_unittest.py:
+            - Test the logic with some fun mocks.
+        * Scripts/webkitpy/common/checkout/scm.py:
+            - Fix a bug when you have local git commits.
+        * Scripts/webkitpy/common/checkout/scm_unittest.py:
+            - Test that the bug is fixed.
+        * Scripts/webkitpy/tool/commands/queries.py:
+            - Add the query.
+
 2010-10-18  Kenneth Russell  <kbr at google.com>
 
         Reviewed by Eric Seidel.
diff --git a/WebKitTools/Scripts/webkitpy/common/checkout/api.py b/WebKitTools/Scripts/webkitpy/common/checkout/api.py
index ca28e32..e040488 100644
--- a/WebKitTools/Scripts/webkitpy/common/checkout/api.py
+++ b/WebKitTools/Scripts/webkitpy/common/checkout/api.py
@@ -83,13 +83,19 @@ class Checkout(object):
     def bug_id_for_revision(self, revision):
         return self.commit_info_for_revision(revision).bug_id()
 
-    def modified_changelogs(self, git_commit):
+    def _modified_files_matching_predicate(self, git_commit, predicate):
         # SCM returns paths relative to scm.checkout_root
         # Callers (especially those using the ChangeLog class) may
         # expect absolute paths, so this method returns absolute paths.
         changed_files = self._scm.changed_files(git_commit)
         absolute_paths = [os.path.join(self._scm.checkout_root, path) for path in changed_files]
-        return [path for path in absolute_paths if self._is_path_to_changelog(path)]
+        return [path for path in absolute_paths if predicate(path)]
+
+    def modified_changelogs(self, git_commit):
+        return self._modified_files_matching_predicate(git_commit, self._is_path_to_changelog)
+
+    def modified_non_changelogs(self, git_commit):
+        return self._modified_files_matching_predicate(git_commit, lambda path: not self._is_path_to_changelog(path))
 
     def commit_message_for_this_commit(self, git_commit):
         changelog_paths = self.modified_changelogs(git_commit)
@@ -109,6 +115,14 @@ class Checkout(object):
         # FIXME: We should sort and label the ChangeLog messages like commit-log-editor does.
         return CommitMessage("".join(changelog_messages).splitlines())
 
+    def suggested_reviewers(self, git_commit):
+        changed_files = self.modified_non_changelogs(git_commit)
+        revisions = set(sum(map(self._scm.revisions_changing_file, changed_files), []))
+        commit_infos = set(map(self.commit_info_for_revision, revisions))
+        reviewers = [commit_info.reviewer() for commit_info in commit_infos if commit_info.reviewer()]
+        reviewers.extend([commit_info.author() for commit_info in commit_infos if commit_info.author() and commit_info.author().can_review])
+        return sorted(set(reviewers))
+
     def bug_id_for_this_commit(self, git_commit):
         try:
             return parse_bug_id(self.commit_message_for_this_commit(git_commit).message())
diff --git a/WebKitTools/Scripts/webkitpy/common/checkout/api_unittest.py b/WebKitTools/Scripts/webkitpy/common/checkout/api_unittest.py
index fdfd879..d7bd95e 100644
--- a/WebKitTools/Scripts/webkitpy/common/checkout/api_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/common/checkout/api_unittest.py
@@ -173,3 +173,24 @@ class CheckoutTest(unittest.TestCase):
         checkout = Checkout(scm)
         expected_changlogs = ["/foo/bar/ChangeLog", "/foo/bar/relative/path/ChangeLog"]
         self.assertEqual(checkout.modified_changelogs(git_commit=None), expected_changlogs)
+
+    def test_suggested_reviewers(self):
+        def mock_changelog_entries_for_revision(revision):
+            if revision % 2 == 0:
+                return [ChangeLogEntry(_changelog1entry1)]
+            return [ChangeLogEntry(_changelog1entry2)]
+
+        def mock_revisions_changing_file(path, limit=5):
+            if path.endswith("ChangeLog"):
+                return [3]
+            return [4, 8]
+
+        scm = Mock()
+        scm.checkout_root = "/foo/bar"
+        scm.changed_files = lambda git_commit: ["file1", "file2", "relative/path/ChangeLog"]
+        scm.revisions_changing_file = mock_revisions_changing_file
+        checkout = Checkout(scm)
+        checkout.changelog_entries_for_revision = mock_changelog_entries_for_revision
+        reviewers = checkout.suggested_reviewers(git_commit=None)
+        reviewer_names = [reviewer.full_name for reviewer in reviewers]
+        self.assertEqual(reviewer_names, [u'Tor Arne Vestb\xf8'])
diff --git a/WebKitTools/Scripts/webkitpy/common/checkout/scm.py b/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
index 6c2c189..a71201e 100644
--- a/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
+++ b/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
@@ -668,7 +668,7 @@ class Git(SCM):
 
     def revisions_changing_file(self, path, limit=5):
         commit_ids = self.run(["git", "log", "--pretty=format:%H", "-%s" % limit, path]).splitlines()
-        return map(self.svn_revision_from_git_commit, commit_ids)
+        return filter(lambda revision: revision, map(self.svn_revision_from_git_commit, commit_ids))
 
     def conflicted_files(self):
         # We do not need to pass decode_output for this diff command
@@ -706,7 +706,10 @@ class Git(SCM):
         return git_commit
 
     def svn_revision_from_git_commit(self, commit_id):
-        return int(self.run(['git', 'svn', 'find-rev', commit_id]).rstrip())
+        try:
+            return int(self.run(['git', 'svn', 'find-rev', commit_id]).rstrip())
+        except ValueError, e:
+            return None
 
     def contents_at_revision(self, path, revision):
         """Returns a byte array (str()) containing the contents
diff --git a/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py b/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
index ed8f009..1cfeee8 100644
--- a/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
@@ -971,6 +971,10 @@ class GitSVNTest(SCMTest):
         self.scm.commit_locally_with_message("another test commit")
         self._two_local_commits()
 
+    def test_revisions_changing_files_with_local_commit(self):
+        self._one_local_commit()
+        self.assertEquals(self.scm.revisions_changing_file('test_file_commit1'), [])
+
     def test_commit_with_message(self):
         self._one_local_commit_plus_working_copy_changes()
         scm = detect_scm_system(self.git_checkout_path)
diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/queries.py b/WebKitTools/Scripts/webkitpy/tool/commands/queries.py
index 478fac2..16ddc2c 100644
--- a/WebKitTools/Scripts/webkitpy/tool/commands/queries.py
+++ b/WebKitTools/Scripts/webkitpy/tool/commands/queries.py
@@ -30,6 +30,8 @@
 
 from optparse import make_option
 
+import webkitpy.tool.steps as steps
+
 from webkitpy.common.checkout.commitinfo import CommitInfo
 from webkitpy.common.config.committers import CommitterList
 from webkitpy.common.net.buildbot import BuildBot
@@ -41,6 +43,21 @@ from webkitpy.common.system.deprecated_logging import log
 from webkitpy.layout_tests import port
 
 
+class SuggestReviewers(AbstractDeclarativeCommand):
+    name = "suggest-reviewers"
+    help_text = "Suggest reviewers for a patch based on recent changes to the modified files."
+
+    def __init__(self):
+        options = [
+            steps.Options.git_commit,
+        ]
+        AbstractDeclarativeCommand.__init__(self, options=options)
+
+    def execute(self, options, args, tool):
+        reviewers = tool.checkout().suggested_reviewers(options.git_commit)
+        print "\n".join([reviewer.full_name for reviewer in reviewers])
+
+
 class BugsToCommit(AbstractDeclarativeCommand):
     name = "bugs-to-commit"
     help_text = "List bugs in the commit-queue"

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list