Title: [228303] trunk/Tools
Revision
228303
Author
[email protected]
Date
2018-02-08 17:24:36 -0800 (Thu, 08 Feb 2018)

Log Message

webkit-patch suggest-reviewers dies with AttributeError: 'NoneType' object has no attribute 'revision'
https://bugs.webkit.org/show_bug.cgi?id=182584

Reviewed by Daniel Bates.

It is possible that a specific revision has an empty ChangeLog. In this case, Checkout.commit_info_for_revision
will return 'None'. Checkout.recent_commit_infos_for_files should never return a set with 'None' in it.

* Scripts/webkitpy/common/checkout/checkout.py:
(Checkout.recent_commit_infos_for_files): Remove any empty commit information from the set.
* Scripts/webkitpy/common/checkout/checkout_unittest.py: Add a file which references an empty ChangeLog.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (228302 => 228303)


--- trunk/Tools/ChangeLog	2018-02-09 01:09:37 UTC (rev 228302)
+++ trunk/Tools/ChangeLog	2018-02-09 01:24:36 UTC (rev 228303)
@@ -1,3 +1,17 @@
+2018-02-08  Jonathan Bedard  <[email protected]>
+
+        webkit-patch suggest-reviewers dies with AttributeError: 'NoneType' object has no attribute 'revision'
+        https://bugs.webkit.org/show_bug.cgi?id=182584
+
+        Reviewed by Daniel Bates.
+
+        It is possible that a specific revision has an empty ChangeLog. In this case, Checkout.commit_info_for_revision
+        will return 'None'. Checkout.recent_commit_infos_for_files should never return a set with 'None' in it.
+
+        * Scripts/webkitpy/common/checkout/checkout.py:
+        (Checkout.recent_commit_infos_for_files): Remove any empty commit information from the set.
+        * Scripts/webkitpy/common/checkout/checkout_unittest.py: Add a file which references an empty ChangeLog.
+
 2018-02-08  Matt Lewis  <[email protected]>
 
         Unreviewed, rolling out r228261.

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py (228302 => 228303)


--- trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py	2018-02-09 01:09:37 UTC (rev 228302)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py	2018-02-09 01:24:36 UTC (rev 228303)
@@ -137,7 +137,8 @@
 
     def recent_commit_infos_for_files(self, paths):
         revisions = set(sum(map(self._scm.revisions_changing_file, paths), []))
-        return set(map(self.commit_info_for_revision, revisions))
+        # Remove a None entry from the set. This can happen if a revision does have an associated ChangeLog entry (e.g. r185745).
+        return set(map(self.commit_info_for_revision, revisions)) - set([None])
 
     def suggested_reviewers(self, git_commit, changed_files=None):
         changed_files = self.modified_non_changelogs(git_commit, changed_files)

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py (228302 => 228303)


--- trunk/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py	2018-02-09 01:09:37 UTC (rev 228302)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py	2018-02-09 01:24:36 UTC (rev 228303)
@@ -418,18 +418,22 @@
 
     def test_suggested_reviewers(self):
         def mock_changelog_entries_for_revision(revision, changed_files=None):
+            if revision == 27:
+                return []
             if revision % 2 == 0:
                 return [ChangeLogEntry(_changelog1entry1)]
             return [ChangeLogEntry(_changelog1entry2)]
 
         def mock_revisions_changing_file(path, limit=5):
-            if path.endswith("ChangeLog"):
+            if path.endswith('ChangeLog'):
                 return [3]
+            if path.endswith('file_with_empty_changelog'):
+                return [27]
             return [4, 8]
 
         checkout = self._make_checkout()
-        checkout._scm.checkout_root = "/foo/bar"
-        checkout._scm.changed_files = lambda git_commit: ["file1", "file2", "relative/path/ChangeLog"]
+        checkout._scm.checkout_root = '/foo/bar'
+        checkout._scm.changed_files = lambda git_commit: ['file1', 'file2', 'relative/path/ChangeLog', 'file_with_empty_changelog']
         checkout._scm.revisions_changing_file = mock_revisions_changing_file
         checkout.changelog_entries_for_revision = mock_changelog_entries_for_revision
         reviewers = checkout.suggested_reviewers(git_commit=None)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to