Title: [273358] trunk/Tools
Revision
273358
Author
[email protected]
Date
2021-02-23 16:26:38 -0800 (Tue, 23 Feb 2021)

Log Message

[check-webkit-style] Fix Contributor sorting in Python 3
https://bugs.webkit.org/show_bug.cgi?id=222329
<rdar://problem/74656667>

Reviewed by Dewei Zhu.

* Scripts/webkitpy/common/config/committers.py:
(Contributor.__cmp__): Return an integer to indicate ordering.
(Contributor.__eq__): Add rich comparison operators for sorting.
(Contributor.__ne__): Ditto.
(Contributor.__lt__): Ditto.
(Contributor.__le__): Ditto.
(Contributor.__gt__): Ditto.
(Contributor.__ge__): Ditto.
* Scripts/webkitpy/common/config/contributors.json:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (273357 => 273358)


--- trunk/Tools/ChangeLog	2021-02-24 00:26:11 UTC (rev 273357)
+++ trunk/Tools/ChangeLog	2021-02-24 00:26:38 UTC (rev 273358)
@@ -1,5 +1,23 @@
 2021-02-23  Jonathan Bedard  <[email protected]>
 
+        [check-webkit-style] Fix Contributor sorting in Python 3
+        https://bugs.webkit.org/show_bug.cgi?id=222329
+        <rdar://problem/74656667>
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/webkitpy/common/config/committers.py:
+        (Contributor.__cmp__): Return an integer to indicate ordering.
+        (Contributor.__eq__): Add rich comparison operators for sorting.
+        (Contributor.__ne__): Ditto.
+        (Contributor.__lt__): Ditto.
+        (Contributor.__le__): Ditto.
+        (Contributor.__gt__): Ditto.
+        (Contributor.__ge__): Ditto.
+        * Scripts/webkitpy/common/config/contributors.json:
+
+2021-02-23  Jonathan Bedard  <[email protected]>
+
         [webkitscmpy] Add remote BitBucket
         https://bugs.webkit.org/show_bug.cgi?id=222213
         <rdar://problem/74542626>

Modified: trunk/Tools/Scripts/webkitpy/common/config/committers.py (273357 => 273358)


--- trunk/Tools/Scripts/webkitpy/common/config/committers.py	2021-02-24 00:26:11 UTC (rev 273357)
+++ trunk/Tools/Scripts/webkitpy/common/config/committers.py	2021-02-24 00:26:38 UTC (rev 273358)
@@ -87,16 +87,44 @@
             ^ hash(self.can_commit) \
             ^ hash(self.can_review)
 
+    def __cmp__(self, other):
+        if other is None:
+            return 1
+
+        for member in ('full_name', 'emails', '_case_preserved_emails', 'irc_nicknames', 'can_commit', 'can_review', 'expertise'):
+            if member in ('emails', '_case_preserved_emails', 'irc_nicknames'):
+                self_list = sorted(getattr(self, member) or [])
+                other_list = sorted(getattr(other, member) or [])
+                for i in range(min(len(self_list), len(other_list))):
+                    if self_list[i] != other_list[i]:
+                        return 1 if self_list[i] > other_list[i] else -1
+                if len(self_list) != len(other_list):
+                    return len(self_list) - len(other_list)
+
+            else:
+                if getattr(self, member) != getattr(other, member):
+                    return 1 if getattr(self, member) > getattr(other, member) else -1
+
+        return 0
+
     def __eq__(self, other):
-        return (other is not None
-            and self.full_name == other.full_name
-            and self.emails == other.emails
-            and self._case_preserved_emails == other._case_preserved_emails
-            and self.irc_nicknames == other.irc_nicknames
-            and self.expertise == other.expertise
-            and self.can_commit == other.can_commit
-            and self.can_review == other.can_review)
+        return self.__cmp__(other) == 0
 
+    def __ne__(self, other):
+        return self.__cmp__(other) != 0
+
+    def __lt__(self, other):
+        return self.__cmp__(other) < 0
+
+    def __le__(self, other):
+        return self.__cmp__(other) <= 0
+
+    def __gt__(self, other):
+        return self.__cmp__(other) > 0
+
+    def __ge__(self, other):
+        return self.__cmp__(other) >= 0
+
     def contains_string(self, search_string):
         string = search_string.lower()
         if string in self.full_name.lower():

Modified: trunk/Tools/Scripts/webkitpy/common/config/contributors.json (273357 => 273358)


--- trunk/Tools/Scripts/webkitpy/common/config/contributors.json	2021-02-24 00:26:11 UTC (rev 273357)
+++ trunk/Tools/Scripts/webkitpy/common/config/contributors.json	2021-02-24 00:26:38 UTC (rev 273358)
@@ -4481,7 +4481,7 @@
          "pgriffis",
          "TingPing"
       ],
-      "status": "committer"
+      "status" : "committer"
    },
    "Paulo Matos" : {
       "emails" : [
@@ -4885,6 +4885,11 @@
       ],
       "status" : "reviewer"
    },
+   "Ruben Turcios" : {
+      "emails" : [
+         "[email protected]"
+      ]
+   },
    "Russell Epstein" : {
       "emails" : [
          "[email protected]"
@@ -5274,11 +5279,6 @@
          "szledan"
       ]
    },
-   "Ruben Turcios" : {
-      "emails" : [
-	 "[email protected]"
-      ]
-   },
    "Tab Atkins" : {
       "emails" : [
          "[email protected]",
@@ -6054,4 +6054,4 @@
       ],
       "status" : "reviewer"
    }
-}
+}
\ No newline at end of file
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to