Remove Account class from committers.py
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Apr 2013 09:26:10 +0000 (09:26 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Apr 2013 09:26:10 +0000 (09:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114671

Reviewed by Csaba Osztrogon√°c.

Account class was added to support watch list email addresses that are not associated with
a particular contributor but nobody uses these email address since Chromium port forked.

Remove it.

Also removed account_by_login from CommitterList since it was never called except its unittests.

* Scripts/webkitpy/common/checkout/changelog.py:
* Scripts/webkitpy/common/config/committers.py:
(Contributor):
(Contributor.matches_glob):
(Reviewer.__init__):
(CommitterList.__init__):
(CommitterList._email_to_account_map):
(CommitterList._login_to_account_map):
(CommitterList.contributors_by_fuzzy_match):
(CommitterList.contributor_by_email):
(CommitterList.contributor_by_name):
(CommitterList.committer_by_email):
(CommitterList.reviewer_by_email):
* Scripts/webkitpy/common/config/committers_unittest.py:
(CommittersTest.test_committer_lookup):
* Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
(Bugzilla._commit_queue_flag):
* Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py:
(test_commit_queue_flag):
* Scripts/webkitpy/common/watchlist/watchlistparser.py:
(WatchListParser._validate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148504 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/checkout/changelog.py
Tools/Scripts/webkitpy/common/config/committers.py
Tools/Scripts/webkitpy/common/config/committers_unittest.py
Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py
Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py
Tools/Scripts/webkitpy/common/watchlist/watchlistparser.py

index a7556b030ce22aff9e55ec2d38004c4d55a4fd65..d8c674e3af1293dc63a3a3efb30cd097b7388349 100644 (file)
@@ -1,3 +1,39 @@
+2013-04-16  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Remove Account class from committers.py
+        https://bugs.webkit.org/show_bug.cgi?id=114671
+
+        Reviewed by Csaba Osztrogon√°c.
+
+        Account class was added to support watch list email addresses that are not associated with
+        a particular contributor but nobody uses these email address since Chromium port forked.
+
+        Remove it.
+
+        Also removed account_by_login from CommitterList since it was never called except its unittests.
+
+        * Scripts/webkitpy/common/checkout/changelog.py:
+        * Scripts/webkitpy/common/config/committers.py:
+        (Contributor):
+        (Contributor.matches_glob):
+        (Reviewer.__init__):
+        (CommitterList.__init__):
+        (CommitterList._email_to_account_map):
+        (CommitterList._login_to_account_map):
+        (CommitterList.contributors_by_fuzzy_match):
+        (CommitterList.contributor_by_email):
+        (CommitterList.contributor_by_name):
+        (CommitterList.committer_by_email):
+        (CommitterList.reviewer_by_email):
+        * Scripts/webkitpy/common/config/committers_unittest.py:
+        (CommittersTest.test_committer_lookup):
+        * Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
+        (Bugzilla._commit_queue_flag):
+        * Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py:
+        (test_commit_queue_flag):
+        * Scripts/webkitpy/common/watchlist/watchlistparser.py:
+        (WatchListParser._validate):
+
 2013-04-16  Mike West  <mkwst@chromium.org>
 
         Unreviewed update to the watchlist.
index e927b3398cf30ac1783a527cae0e0909e8a2e22e..47c6b64c586cef266faa5b9b0d57b22bbfe772f9 100644 (file)
@@ -34,7 +34,6 @@ from StringIO import StringIO
 import textwrap
 
 from webkitpy.common.config.committers import CommitterList
-from webkitpy.common.config.committers import Account
 from webkitpy.common.system.filesystem import FileSystem
 import webkitpy.common.config.urls as config_urls
 
index 583fb48b395aee44a4ad7d288d6453d24e78171b..93099361c1cb1eed27743a3db7c68ddf5db3bfa5 100644 (file)
@@ -32,7 +32,8 @@
 from webkitpy.common.editdistance import edit_distance
 import fnmatch
 
-class Account(object):
+
+class Contributor(object):
     def __init__(self, name, email_or_emails, irc_nickname_or_nicknames=None):
         assert(name)
         assert(email_or_emails)
@@ -83,12 +84,6 @@ class Account(object):
         return False
 
 
-class Contributor(Account):
-    def __init__(self, name, email_or_emails, irc_nickname=None):
-        Account.__init__(self, name, email_or_emails, irc_nickname)
-        self.is_contributor = True
-
-
 class Committer(Contributor):
     def __init__(self, name, email_or_emails, irc_nickname=None):
         Contributor.__init__(self, name, email_or_emails, irc_nickname)
@@ -101,16 +96,6 @@ class Reviewer(Committer):
         self.can_review = True
 
 
-# This is a list of email addresses that have bugzilla accounts but are not
-# used for contributing (such as mailing lists).
-
-
-watchers_who_are_not_contributors = [
-    Account("Chromium Compositor Bugs", ["cc-bugs@chromium.org"], ""),
-    Account("Chromium Media Reviews", ["feature-media-reviews@chromium.org"], ""),
-    Account("Kent Tamura", ["tkent+wkapi@chromium.org"], ""),
-]
-
 
 # This is a list of people (or bots) who are neither committers nor reviewers, but get
 # frequently CC'ed by others on Bugzilla bugs, so their names should be
@@ -615,9 +600,7 @@ class CommitterList(object):
     def __init__(self,
                  committers=committers_unable_to_review,
                  reviewers=reviewers_list,
-                 contributors=contributors_who_are_not_committers,
-                 watchers=watchers_who_are_not_contributors):
-        self._accounts = watchers + contributors + committers + reviewers
+                 contributors=contributors_who_are_not_committers):
         self._contributors = contributors + committers + reviewers
         self._committers = committers + reviewers
         self._reviewers = reviewers
@@ -625,9 +608,6 @@ class CommitterList(object):
         self._accounts_by_email = {}
         self._accounts_by_login = {}
 
-    def accounts(self):
-        return self._accounts
-
     def contributors(self):
         return self._contributors
 
@@ -647,7 +627,7 @@ class CommitterList(object):
 
     def _email_to_account_map(self):
         if not len(self._accounts_by_email):
-            for account in self._accounts:
+            for account in self._contributors:
                 for email in account.emails:
                     assert(email not in self._accounts_by_email)  # We should never have duplicate emails.
                     self._accounts_by_email[email] = account
@@ -655,18 +635,13 @@ class CommitterList(object):
 
     def _login_to_account_map(self):
         if not len(self._accounts_by_login):
-            for account in self._accounts:
+            for account in self._contributors:
                 if account.emails:
                     login = account.bugzilla_email()
                     assert(login not in self._accounts_by_login)  # We should never have duplicate emails.
                     self._accounts_by_login[login] = account
         return self._accounts_by_login
 
-    def _contributor_only(self, record):
-        if record and not record.is_contributor:
-            return None
-        return record
-
     def _committer_only(self, record):
         if record and not record.can_commit:
             return None
@@ -720,7 +695,7 @@ class CommitterList(object):
         string_in_lowercase = string.lower()
 
         # 1. Exact match for fullname, email and irc_nicknames
-        account = self.contributor_by_name(string_in_lowercase) or self.account_by_email(string_in_lowercase) or self.contributor_by_irc_nickname(string_in_lowercase)
+        account = self.contributor_by_name(string_in_lowercase) or self.contributor_by_email(string_in_lowercase) or self.contributor_by_irc_nickname(string_in_lowercase)
         if account:
             return [account], 0
 
@@ -753,20 +728,14 @@ class CommitterList(object):
             return [], len(string)
         return contributorWithMinDistance, minDistance
 
-    def account_by_login(self, login):
-        return self._login_to_account_map().get(login.lower()) if login else None
-
-    def account_by_email(self, email):
+    def contributor_by_email(self, email):
         return self._email_to_account_map().get(email.lower()) if email else None
 
     def contributor_by_name(self, name):
         return self._name_to_contributor_map().get(name.lower()) if name else None
 
-    def contributor_by_email(self, email):
-        return self._contributor_only(self.account_by_email(email))
-
     def committer_by_email(self, email):
-        return self._committer_only(self.account_by_email(email))
+        return self._committer_only(self.contributor_by_email(email))
 
     def reviewer_by_email(self, email):
-        return self._reviewer_only(self.account_by_email(email))
+        return self._reviewer_only(self.contributor_by_email(email))
index ce9335b79b5c2690a168ba1c943d0aafc5b9b54e..3992f13ef9adcfa9966dbcd3c7eacbda2ddf0f4c 100644 (file)
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import unittest2 as unittest
-from webkitpy.common.config.committers import Account, CommitterList, Contributor, Committer, Reviewer
+from webkitpy.common.config.committers import CommitterList, Contributor, Committer, Reviewer
 
 class CommittersTest(unittest.TestCase):
     def test_committer_lookup(self):
-        account = Account('Test Zero', ['zero@test.com', 'zero@gmail.com'], 'zero')
         committer = Committer('Test One', 'one@test.com', 'one')
         reviewer = Reviewer('Test Two', ['two@test.com', 'Two@rad.com', 'so_two@gmail.com'])
         contributor = Contributor('Test Three', ['Three@test.com'], 'three')
         contributor_with_two_nicknames = Contributor('Other Four', ['otherfour@webkit.org', 'otherfour@webkit2.org'], ['four', 'otherfour'])
         contributor_with_same_email_username = Contributor('Yet Another Four', ['otherfour@webkit.com'], ['yetanotherfour'])
-        committer_list = CommitterList(watchers=[account], committers=[committer], reviewers=[reviewer],
+        committer_list = CommitterList(committers=[committer], reviewers=[reviewer],
             contributors=[contributor, contributor_with_two_nicknames, contributor_with_same_email_username])
 
         # Test valid committer, reviewer and contributor lookup
-        self.assertEqual(committer_list.account_by_email('zero@test.com'), account)
         self.assertEqual(committer_list.committer_by_email('one@test.com'), committer)
         self.assertEqual(committer_list.reviewer_by_email('two@test.com'), reviewer)
         self.assertEqual(committer_list.committer_by_email('two@test.com'), reviewer)
@@ -60,14 +58,6 @@ class CommittersTest(unittest.TestCase):
         # Test that the first email is assumed to be the Bugzilla email address (for now)
         self.assertEqual(committer_list.committer_by_email('two@rad.com').bugzilla_email(), 'two@test.com')
 
-        # Test lookup by login email address
-        self.assertEqual(committer_list.account_by_login('zero@test.com'), account)
-        self.assertIsNone(committer_list.account_by_login('zero@gmail.com'))
-        self.assertEqual(committer_list.account_by_login('one@test.com'), committer)
-        self.assertEqual(committer_list.account_by_login('two@test.com'), reviewer)
-        self.assertIsNone(committer_list.account_by_login('Two@rad.com'))
-        self.assertIsNone(committer_list.account_by_login('so_two@gmail.com'))
-
         # Test that a known committer is not returned during reviewer lookup
         self.assertIsNone(committer_list.reviewer_by_email('one@test.com'))
         self.assertIsNone(committer_list.reviewer_by_email('three@test.com'))
index 8fe63a3cb80b84547f07c27cc9b220b66fe06750..c71f310f9ba98d722ca8a0622d2fc50de9f2e89c 100644 (file)
@@ -531,7 +531,7 @@ class Bugzilla(object):
     # FIXME: Use enum instead of two booleans
     def _commit_queue_flag(self, mark_for_landing, mark_for_commit_queue):
         if mark_for_landing:
-            user = self.committers.account_by_email(self.username)
+            user = self.committers.contributor_by_email(self.username)
             mark_for_commit_queue = True
             if not user:
                 _log.warning("Your Bugzilla login is not listed in committers.py. Uploading with cq? instead of cq+")
index 09efbeebe32c144583a902a3e085f29b804767e9..136b014871f86d86a43db7e4b27d6ede892a57fe 100644 (file)
@@ -305,8 +305,7 @@ Ignore this bug.  Just for testing failure modes of webkit-patch and the commit-
 
         bugzilla.committers = CommitterList(reviewers=[Reviewer("WebKit Reviewer", "reviewer@webkit.org")],
             committers=[Committer("WebKit Committer", "committer@webkit.org")],
-            contributors=[Contributor("WebKit Contributor", "contributor@webkit.org")],
-            watchers=[])
+            contributors=[Contributor("WebKit Contributor", "contributor@webkit.org")])
 
         def assert_commit_queue_flag(mark_for_landing, mark_for_commit_queue, expected, username=None):
             bugzilla.username = username
index bc00c541e38dc3f399e1bb4450de62823e4ed76b..1d3f581b6e2a8f27b7e6ecef5a51a909ce4cc5d4 100644 (file)
@@ -152,7 +152,7 @@ class WatchListParser(object):
             # modifying a list while iterating through it leads to undefined behavior.
             intructions_copy = cc_rule.instructions()[:]
             for email in intructions_copy:
-                if not accounts.account_by_email(email):
+                if not accounts.contributor_by_email(email):
                     cc_rule.remove_instruction(email)
                     self._log_error("The email alias %s which is in the watchlist is not listed as a contributor in committers.py" % email)
                     continue