From ea87d2309c9e332aa5af8e97d7640b9d4d26e1f1 Mon Sep 17 00:00:00 2001 From: "jbedard@apple.com" Date: Fri, 2 Oct 2020 20:44:34 +0000 Subject: [PATCH] [webkitscmpy] Remove "i" from canonical identifier https://bugs.webkit.org/show_bug.cgi?id=217238 Reviewed by Dewei Zhu. * Scripts/libraries/webkitscmpy/webkitscmpy/commit.py: (Commit): (Commit.pretty_print): Remove "i" from canonical identifier, add branch point. (Commit.__repr__): Remove "i" from canonical identifier. * Scripts/libraries/webkitscmpy/webkitscmpy/test/commit_unittest.py: (TestCommit.test_parse_revision): (TestCommit.test_parse_identifier): (TestCommit.test_parse): (TestCommit.test_pretty_print): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@267895 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Tools/ChangeLog | 18 ++++++ .../webkitscmpy/webkitscmpy/__init__.py | 2 +- .../webkitscmpy/webkitscmpy/commit.py | 14 +++-- .../webkitscmpy/test/commit_unittest.py | 60 +++++++++---------- 4 files changed, 56 insertions(+), 38 deletions(-) diff --git a/Tools/ChangeLog b/Tools/ChangeLog index eb14b6ceabeee..b7b2a7869f90a 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,21 @@ +2020-10-02 Jonathan Bedard + + [webkitscmpy] Remove "i" from canonical identifier + https://bugs.webkit.org/show_bug.cgi?id=217238 + + + Reviewed by Dewei Zhu. + + * Scripts/libraries/webkitscmpy/webkitscmpy/commit.py: + (Commit): + (Commit.pretty_print): Remove "i" from canonical identifier, add branch point. + (Commit.__repr__): Remove "i" from canonical identifier. + * Scripts/libraries/webkitscmpy/webkitscmpy/test/commit_unittest.py: + (TestCommit.test_parse_revision): + (TestCommit.test_parse_identifier): + (TestCommit.test_parse): + (TestCommit.test_pretty_print): + 2020-10-02 Philippe Normand [CMake] unused variable warning spam in UIScriptController.h diff --git a/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py b/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py index b645f4eef8d7d..70d2165ae0aa3 100644 --- a/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py +++ b/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py @@ -46,7 +46,7 @@ def _maybe_add_webkitcorepy_path(): "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url `" ) -version = Version(0, 0, 7) +version = Version(0, 0, 8) from webkitscmpy.contributor import Contributor from webkitscmpy.commit import Commit diff --git a/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/commit.py b/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/commit.py index 07c8c7a8d9f80..4497ae19f5b62 100644 --- a/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/commit.py +++ b/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/commit.py @@ -30,7 +30,7 @@ class Commit(object): HASH_RE = re.compile(r'^[a-f0-9A-F]+$') REVISION_RE = re.compile(r'^[Rr]?(?P\d+)$') - IDENTIFIER_RE = re.compile(r'^[Ii]?((?P\d+)\.)?(?P-?\d+)(@(?P\S+))?$') + IDENTIFIER_RE = re.compile(r'^((?P\d+)\.)?(?P-?\d+)(@(?P\S+))?$') NUMBER_RE = re.compile(r'^-?\d*$') @classmethod @@ -195,9 +195,11 @@ def pretty_print(self, message=False): result += ' on {}'.format(self.branch) result += '\n' if self.identifier: - result += ' identifier: i{}'.format(self.identifier) - if self.identifier: + result += ' identifier: {}'.format(self.identifier) + if self.branch: result += ' on {}'.format(self.branch) + if self.branch_point: + result += ' branched from {}'.format(self.branch_point) result += '\n' if self.author: result += ' by {}'.format(self.author) @@ -213,15 +215,15 @@ def pretty_print(self, message=False): def __repr__(self): if self.branch_point and self.identifier and self.branch: - return 'i{}.{}@{}'.format(self.branch_point, self.identifier, self.branch) + return '{}.{}@{}'.format(self.branch_point, self.identifier, self.branch) if self.identifier and self.branch: - return 'i{}@{}'.format(self.identifier, self.branch) + return '{}@{}'.format(self.identifier, self.branch) if self.revision: return 'r{}'.format(self.revision) if self.hash: return self.hash[:12] if self.identifier: - return 'i{}'.format(self.identifier) + return str(self.identifier) raise ValueError('Incomplete commit format') def __hash__(self): diff --git a/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/commit_unittest.py b/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/commit_unittest.py index 9f8516e6b1fec..e78556550322e 100644 --- a/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/commit_unittest.py +++ b/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/commit_unittest.py @@ -46,7 +46,6 @@ def test_parse_revision(self): self.assertEqual(266896, Commit._parse_revision('266896')) self.assertEqual(266896, Commit._parse_revision(266896)) - self.assertEqual(None, Commit._parse_revision('i1234')) self.assertEqual(None, Commit._parse_revision('c3bd784f8b88bd03')) self.assertEqual(None, Commit._parse_revision('0')) self.assertEqual(None, Commit._parse_revision('-1')) @@ -54,42 +53,26 @@ def test_parse_revision(self): self.assertEqual(None, Commit._parse_revision(3.141592)) def test_parse_identifier(self): - self.assertEqual((None, 1234, None), Commit._parse_identifier('i1234')) - self.assertEqual((None, 1234, None), Commit._parse_identifier('I1234')) self.assertEqual((None, 1234, None), Commit._parse_identifier('1234')) self.assertEqual((None, 1234, None), Commit._parse_identifier(1234)) - self.assertEqual((None, 1234, 'main'), Commit._parse_identifier('i1234@main')) - self.assertEqual((None, 1234, 'main'), Commit._parse_identifier('I1234@main')) self.assertEqual((None, 1234, 'main'), Commit._parse_identifier('1234@main')) - - self.assertEqual((None, 1234, 'eng/bug'), Commit._parse_identifier('i1234@eng/bug')) - self.assertEqual((None, 1234, 'eng/bug'), Commit._parse_identifier('I1234@eng/bug')) self.assertEqual((None, 1234, 'eng/bug'), Commit._parse_identifier('1234@eng/bug')) - - self.assertEqual((1234, 1, 'eng/bug'), Commit._parse_identifier('i1234.1@eng/bug')) - self.assertEqual((1234, 1, 'eng/bug'), Commit._parse_identifier('I1234.1@eng/bug')) self.assertEqual((1234, 1, 'eng/bug'), Commit._parse_identifier('1234.1@eng/bug')) self.assertEqual((None, 0, None), Commit._parse_identifier('0')) self.assertEqual((None, -1, None), Commit._parse_identifier('-1')) - self.assertEqual((None, 0, 'eng/bug'), Commit._parse_identifier('i0@eng/bug')) - self.assertEqual((None, 0, 'eng/bug'), Commit._parse_identifier('I0@eng/bug')) self.assertEqual((None, 0, 'eng/bug'), Commit._parse_identifier('0@eng/bug')) - - self.assertEqual((None, -1, 'eng/bug'), Commit._parse_identifier('i-1@eng/bug')) - self.assertEqual((None, -1, 'eng/bug'), Commit._parse_identifier('I-1@eng/bug')) self.assertEqual((None, -1, 'eng/bug'), Commit._parse_identifier('-1@eng/bug')) - self.assertEqual(None, Commit._parse_identifier('i1234-invalid')) + self.assertEqual(None, Commit._parse_identifier('1234-invalid')) self.assertEqual(None, Commit._parse_identifier('r266896')) self.assertEqual(None, Commit._parse_identifier('c3bd784f8b88bd03')) self.assertEqual(None, Commit._parse_identifier(3.141592)) def test_parse(self): - self.assertEqual(Commit.parse('i123@main'), Commit(identifier=123, branch='main')) - self.assertEqual(Commit.parse('i123'), Commit(identifier=123)) + self.assertEqual(Commit.parse('123@main'), Commit(identifier=123, branch='main')) self.assertEqual(Commit.parse('123'), Commit(identifier=123)) self.assertEqual(Commit.parse('r123'), Commit(revision=123)) @@ -102,44 +85,59 @@ def test_parse(self): def test_pretty_print(self): self.assertEqual( Commit( - identifier='i123@master', + identifier='123@master', hash='c3bd784f8b88bd03f64467ddd3304ed8be28acbe', author=Contributor('Jonathan Bedard', ['jbedard@apple.com']), message='NOT PRINTED', ).pretty_print(), - '''i123@master + '''123@master git hash: c3bd784f8b88 on master - identifier: i123 on master + identifier: 123 on master by Jonathan Bedard ''', ) self.assertEqual( Commit( - identifier='i123@trunk', + identifier='123@trunk', revision='r123', author=Contributor('Jonathan Bedard', ['jbedard@apple.com']), timestamp=1000, message='NOT PRINTED', ).pretty_print(), - '''i123@trunk + '''123@trunk SVN revision: r123 on trunk - identifier: i123 on trunk + identifier: 123 on trunk + by Jonathan Bedard @ {} +'''.format(datetime.utcfromtimestamp(1000)), + ) + + self.assertEqual( + Commit( + identifier='123.1@branch-a', + revision='r124', + author=Contributor('Jonathan Bedard', ['jbedard@apple.com']), + timestamp=1000, + message='NOT PRINTED', + ).pretty_print(), + '''123.1@branch-a + SVN revision: r124 on branch-a + identifier: 1 on branch-a branched from 123 by Jonathan Bedard @ {} '''.format(datetime.utcfromtimestamp(1000)), ) self.assertEqual( Commit( - identifier='i123@trunk', + identifier='123@trunk', revision='r123', author=Contributor('Jonathan Bedard', ['jbedard@apple.com']), timestamp=1000, message='PRINTED\n', ).pretty_print(message=True), - '''i123@trunk + '''123@trunk SVN revision: r123 on trunk - identifier: i123 on trunk + identifier: 123 on trunk by Jonathan Bedard @ {} PRINTED @@ -147,9 +145,9 @@ def test_pretty_print(self): ) def test_repr(self): - self.assertEqual(str(Commit(identifier=123, branch='main')), 'i123@main') - self.assertEqual(str(Commit(branch_point=1234, identifier=1, branch='eng/1234')), 'i1234.1@eng/1234') - self.assertEqual(str(Commit(identifier=123)), 'i123') + self.assertEqual(str(Commit(identifier=123, branch='main')), '123@main') + self.assertEqual(str(Commit(branch_point=1234, identifier=1, branch='eng/1234')), '1234.1@eng/1234') + self.assertEqual(str(Commit(identifier=123)), '123') self.assertEqual(str(Commit(revision=123)), 'r123')