WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for landing
bug-216402-20200915124033.patch (text/plain), 11.64 KB, created by
Jonathan Bedard
on 2020-09-15 12:40:34 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Jonathan Bedard
Created:
2020-09-15 12:40:34 PDT
Size:
11.64 KB
patch
obsolete
>Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 267094) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,41 @@ >+2020-09-15 Jonathan Bedard <jbedard@apple.com> >+ >+ [webkitscmpy] Add Contributor object >+ https://bugs.webkit.org/show_bug.cgi?id=216402 >+ <rdar://problem/68702680> >+ >+ Reviewed by Dewei Zhu. >+ >+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: >+ * Scripts/libraries/webkitscmpy/webkitscmpy/contributor.py: Added. >+ (Contributor): Object mapping a contributor by name to their associated email addresses. >+ (Contributor.clear): Clear the in-memory cache of Contributor objects. >+ (Contributor.from_scm_log): Find or generate a Contributor object given a commit log line from >+ an SCM tool. >+ (Contributor.__init__): >+ (Contributor.email): Return a single email for a Contributor. >+ (Contributor.__repr__): >+ (Contributor.__hash__): >+ (Contributor.__cmp__): >+ (Contributor.__eq__): >+ (Contributor.__ne__): >+ (Contributor.__lt__): >+ (Contributor.__le__): >+ (Contributor.__gt__): >+ (Contributor.__ge__): >+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/contributor_unittest.py: Added. >+ (TestContributor): >+ (TestContributor.test_git_log): >+ (TestContributor.test_svn_log): >+ (TestContributor.test_svn_patch_by_log): >+ (TestContributor.test_author_mapping): >+ (TestContributor.test_email_mapping): >+ (TestContributor.test_invalid_log): >+ (TestContributor.test_comparison): >+ (TestContributor.test_string_comparison): >+ (TestContributor.test_hash): >+ (TestContributor.test_sorting): >+ > 2020-09-15 Jonathan Bedard <jbedard@apple.com> > > [webkitscmpy] Add default_branch for local SCM repositories >Index: Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py >=================================================================== >--- Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (revision 267094) >+++ Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (working copy) >@@ -46,7 +46,9 @@ except ImportError: > "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`" > ) > >-version = Version(0, 0, 3) >+version = Version(0, 0, 4) >+ >+from webkitscmpy.contributor import Contributor > > from webkitscmpy import local > from webkitscmpy import mocks >Index: Tools/Scripts/libraries/webkitscmpy/webkitscmpy/contributor.py >=================================================================== >--- Tools/Scripts/libraries/webkitscmpy/webkitscmpy/contributor.py (nonexistent) >+++ Tools/Scripts/libraries/webkitscmpy/webkitscmpy/contributor.py (working copy) >@@ -0,0 +1,109 @@ >+# Copyright (C) 2020 Apple Inc. All rights reserved. >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. Redistributions in binary form must reproduce the above copyright >+# notice, this list of conditions and the following disclaimer in the >+# documentation and/or other materials provided with the distribution. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS "AS IS" AND >+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR >+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR >+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER >+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, >+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ >+import re >+ >+ >+class Contributor(object): >+ GIT_AUTHOR_RE = re.compile(r'Author: (?P<author>.*) <(?P<email>.*)>') >+ SVN_AUTHOR_RE = re.compile(r'r\d+ \| (?P<email>.*) \| (?P<date>.*) \| \d+ lines') >+ SVN_PATCH_FROM_RE = re.compile(r'Patch by (?P<author>.*) <(?P<email>.*)> on \d+-\d+-\d+') >+ >+ by_email = dict() >+ by_name = dict() >+ >+ @classmethod >+ def clear(cls): >+ cls.by_email = dict() >+ cls.by_name = dict() >+ >+ @classmethod >+ def from_scm_log(cls, line): >+ author = None >+ >+ for expression in [cls.GIT_AUTHOR_RE, cls.SVN_AUTHOR_RE, cls.SVN_PATCH_FROM_RE]: >+ match = expression.match(line) >+ if match: >+ if 'author' in expression.groupindex: >+ author = match.group('author') >+ email = match.group('email') >+ break >+ else: >+ raise ValueError("'{}' does not match a known SCM log") >+ >+ contributor = cls.by_name.get(author or email) >+ if not contributor: >+ contributor = cls.by_email.get(email) >+ >+ if not contributor: >+ contributor = cls(author or email, emails=[email]) >+ cls.by_name[contributor.name] = contributor >+ elif email not in contributor.emails: >+ contributor.emails.append(email) >+ >+ cls.by_name[email] = contributor >+ return contributor >+ >+ def __init__(self, name, emails=None): >+ self.name = name >+ self.emails = emails or [] >+ >+ @property >+ def email(self): >+ if not self.emails: >+ return None >+ return self.emails[0] >+ >+ def __repr__(self): >+ return '{} <{}>'.format(self.name, self.email) >+ >+ def __hash__(self): >+ return hash(self.name) >+ >+ def __cmp__(self, other): >+ if isinstance(other, str): >+ ref_value = other >+ elif isinstance(other, Contributor): >+ ref_value = other.name >+ else: >+ raise ValueError('Cannot compare {} with {}'.format(Contributor, type(other))) >+ if self.name == ref_value: >+ return 0 >+ return 1 if self.name > ref_value else -1 >+ >+ def __eq__(self, other): >+ 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 >Index: Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/contributor_unittest.py >=================================================================== >--- Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/contributor_unittest.py (nonexistent) >+++ Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/contributor_unittest.py (working copy) >@@ -0,0 +1,108 @@ >+# Copyright (C) 2020 Apple Inc. All rights reserved. >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. Redistributions in binary form must reproduce the above copyright >+# notice, this list of conditions and the following disclaimer in the >+# documentation and/or other materials provided with the distribution. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS "AS IS" AND >+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR >+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR >+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER >+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, >+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ >+import unittest >+ >+from webkitscmpy import Contributor >+ >+ >+class TestContributor(unittest.TestCase): >+ def test_git_log(self): >+ Contributor.clear() >+ contributor = Contributor.from_scm_log('Author: Jonathan Bedard <jbedard@apple.com>') >+ >+ self.assertEqual(contributor.name, 'Jonathan Bedard') >+ self.assertEqual(contributor.emails, ['jbedard@apple.com']) >+ >+ def test_svn_log(self): >+ Contributor.clear() >+ contributor = Contributor.from_scm_log('r266751 | jbedard@apple.com | 2020-09-08 14:33:42 -0700 (Tue, 08 Sep 2020) | 10 lines') >+ >+ self.assertEqual(contributor.name, 'jbedard@apple.com') >+ self.assertEqual(contributor.emails, ['jbedard@apple.com']) >+ >+ def test_svn_patch_by_log(self): >+ Contributor.clear() >+ contributor = Contributor.from_scm_log('Patch by Jonathan Bedard <jbedard@apple.com> on 2020-09-10') >+ >+ self.assertEqual(contributor.name, 'Jonathan Bedard') >+ self.assertEqual(contributor.emails, ['jbedard@apple.com']) >+ >+ def test_author_mapping(self): >+ Contributor.clear() >+ Contributor.from_scm_log('Author: Jonathan Bedard <jbedard@apple.com>') >+ contributor = Contributor.from_scm_log('Author: Jonathan Bedard <jbedard@webkit.org>') >+ >+ self.assertEqual(contributor.name, 'Jonathan Bedard') >+ self.assertEqual(contributor.emails, ['jbedard@apple.com', 'jbedard@webkit.org']) >+ >+ def test_email_mapping(self): >+ Contributor.clear() >+ Contributor.from_scm_log('Author: Jonathan Bedard <jbedard@apple.com>') >+ contributor = Contributor.from_scm_log('r266751 | jbedard@apple.com | 2020-09-08 14:33:42 -0700 (Tue, 08 Sep 2020) | 10 lines') >+ >+ self.assertEqual(contributor.name, 'Jonathan Bedard') >+ self.assertEqual(contributor.emails, ['jbedard@apple.com']) >+ >+ def test_invalid_log(self): >+ Contributor.clear() >+ with self.assertRaises(ValueError): >+ Contributor.from_scm_log('Jonathan Bedard <jbedard@apple.com>') >+ >+ def test_comparison(self): >+ self.assertEqual( >+ Contributor('Jonathan Bedard', ['jbedard@apple.com']), >+ Contributor('Jonathan Bedard', ['jbedard@webkit.org']), >+ ) >+ >+ self.assertNotEqual( >+ Contributor('Jonathan Bedard', ['jbedard@apple.com']), >+ Contributor('Aakash Jain', ['aakashjain@apple.com']), >+ ) >+ >+ def test_string_comparison(self): >+ self.assertEqual( >+ Contributor('Jonathan Bedard', ['jbedard@apple.com']), >+ 'Jonathan Bedard', >+ ) >+ >+ self.assertNotEqual( >+ Contributor('Jonathan Bedard', ['jbedard@apple.com']), >+ 'Aakash Jain', >+ ) >+ >+ def test_hash(self): >+ self.assertEqual( >+ hash(Contributor('Jonathan Bedard', ['jbedard@apple.com'])), >+ hash(Contributor('Jonathan Bedard', ['jbedard@webkit.org'])), >+ ) >+ >+ self.assertNotEqual( >+ hash(Contributor('Jonathan Bedard', ['jbedard@apple.com'])), >+ hash(Contributor('Aakash Jain', ['aakashjain@apple.com'])), >+ ) >+ >+ def test_sorting(self): >+ self.assertEqual( >+ sorted([Contributor('Jonathan Bedard'), Contributor('Aakash Jain')]), >+ [Contributor('Aakash Jain'), Contributor('Jonathan Bedard')], >+ )
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 216402
:
408535
| 408845