Diff
Modified: trunk/Tools/ChangeLog (273764 => 273765)
--- trunk/Tools/ChangeLog 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/ChangeLog 2021-03-02 23:27:06 UTC (rev 273765)
@@ -1,3 +1,35 @@
+2021-03-02 Jonathan Bedard <[email protected]>
+
+ [webkitscmpy] Add UUID
+ https://bugs.webkit.org/show_bug.cgi?id=222602
+ <rdar://problem/74931488>
+
+ Reviewed by Dewei Zhu.
+
+ * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/commit.py:
+ (Commit):
+ (Commit.Encoder.default): Add order member.
+ (Commit.__init__): Ditto.
+ (Commit.uuid): Compute UUID from timestamp and order.
+ (Commit.__cmp__): Use UUID instead of timestamp for comparison.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
+ (Git.commit): Compute commit order.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/git-repo.json: Add "order" to colliding commit.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py: Correct case where comparison fails.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py: Ditto.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py:
+ (BitBucket.commit): Compute commit order.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py:
+ (GitHub.commit): Compute commit order.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/commit_unittest.py:
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py:
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
+ (TestGit.test_order): Added.
+ (TestGitHub.test_order): Added.
+ (TestBitBucket.test_order): Added.
+
2021-03-02 Sam Sneddon <[email protected]>
Remove the ability to run tests via webkit-patch
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -29,7 +29,7 @@
setup(
name='webkitscmpy',
- version='0.11.4',
+ version='0.12.0',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(0, 11, 4)
+version = Version(0, 12, 0)
AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('monotonic', Version(1, 5)))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/commit.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/commit.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/commit.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -34,6 +34,7 @@
IDENTIFIER_RE = re.compile(r'^((?P<branch_point>\d+)\.)?(?P<identifier>-?\d+)(@(?P<branch>\S*))?$')
NUMBER_RE = re.compile(r'^-?\d*$')
HASH_LABEL_SIZE = 12
+ UUID_MULTIPLIER = 100
class Encoder(json.JSONEncoder):
@@ -42,7 +43,7 @@
return super(Commit.Encoder, self).default(obj)
result = dict()
- for attribute in ['hash', 'revision', 'branch', 'timestamp', 'message']:
+ for attribute in ['hash', 'revision', 'branch', 'timestamp', 'order', 'message']:
value = getattr(obj, attribute, None)
if value is not None:
result[attribute] = value
@@ -150,7 +151,7 @@
hash=None,
revision=None,
identifier=None, branch=None, branch_point=None,
- timestamp=None, author=None, message=None,
+ timestamp=None, author=None, message=None, order=None,
):
self.hash = self._parse_hash(hash, do_assert=True)
self.revision = self._parse_revision(revision, do_assert=True)
@@ -187,6 +188,10 @@
raise TypeError("Expected 'timestamp' to be of type int, got '{}'".format(timestamp))
self.timestamp = timestamp
+ if order and not isinstance(order, int):
+ raise TypeError("Expected 'order' to be of type int, got '{}'".format(order))
+ self.order = order or 0
+
if author and isinstance(author, dict) and author.get('name'):
self.author = Contributor(author.get('name'), author.get('emails'))
elif author and not isinstance(author, Contributor):
@@ -232,6 +237,12 @@
return result
+ @property
+ def uuid(self):
+ if not self.timestamp:
+ return None
+ return self.timestamp * self.UUID_MULTIPLIER + self.order
+
def __repr__(self):
if self.branch_point and self.identifier is not None and self.branch:
return '{}.{}@{}'.format(self.branch_point, self.identifier, self.branch)
@@ -259,8 +270,8 @@
def __cmp__(self, other):
if not isinstance(other, Commit):
raise ValueError('Cannot compare commit and {}'.format(type(other)))
- if self.timestamp and other.timestamp and self.timestamp != other.timestamp:
- return self.timestamp - other.timestamp
+ if self.uuid and other.uuid and self.uuid != other.uuid:
+ return self.uuid - other.uuid
if self.revision and other.revision:
return self.revision - other.revision
if self.identifier and other.identifier and self.branch == other.branch:
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -256,7 +256,20 @@
)
if commit_time.returncode:
raise self.Exception('Failed to retrieve commit time for {}'.format(hash))
+ timestamp = int(commit_time.stdout.lstrip())
+ order = 0
+ while not identifier or order + 1 < identifier + (branch_point or 0):
+ commit_time = run(
+ [self.executable(), 'show', '-s', '--format=%ct', '{}~{}'.format(hash, order + 1)],
+ cwd=self.root_path, capture_output=True, encoding='utf-8',
+ )
+ if commit_time.returncode:
+ break
+ if int(commit_time.stdout.lstrip()) != timestamp:
+ break
+ order += 1
+
return Commit(
hash=hash,
revision=revision,
@@ -263,7 +276,8 @@
identifier=identifier if include_identifier else None,
branch_point=branch_point,
branch=branch,
- timestamp=int(commit_time.stdout.lstrip()),
+ timestamp=timestamp,
+ order=order,
author=Contributor.from_scm_log(log.stdout.splitlines()[1], self.contributors),
message='\n'.join(line[4:] for line in log.stdout.splitlines()[4:]) if include_log else None,
)
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/git-repo.json (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/git-repo.json 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/git-repo.json 2021-03-02 23:27:06 UTC (rev 273765)
@@ -68,7 +68,8 @@
"branch": "main",
"message": "Patch Series\n",
"identifier": "5@main",
- "revision": 9
+ "revision": 9,
+ "order": 1
}
],
"branch-b": [
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -313,7 +313,7 @@
if difference < found.identifier:
return self.commits[found.branch][found.identifier - difference - 1]
difference -= found.identifier
- if difference < found.branch_point:
+ if found.branch_point and difference < found.branch_point:
return self.commits[self.default_branch][found.branch_point - difference - 1]
return None
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -104,7 +104,7 @@
if delta < commit.identifier:
return self.commits[commit.branch][commit.identifier - delta - 1]
delta -= commit.identifier
- if delta < commit.branch_point:
+ if commit.branch_point and delta < commit.branch_point:
return self.commits[self.default_branch][commit.branch_point - delta - 1]
return None
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -226,6 +226,17 @@
matches = self.GIT_SVN_REVISION.findall(commit_data['message'])
revision = int(matches[-1].split('@')[0]) if matches else None
+ timestamp = int(commit_data['committerTimestamp'] / 100)
+ order = 0
+ while not identifier or order + 1 < identifier + (branch_point or 0):
+ response = self.request('commits/{}'.format('{}~{}'.format(commit_data['id'], order + 1)))
+ if not response:
+ break
+ parent_timestamp = int(response['committerTimestamp'] / 100)
+ if parent_timestamp != timestamp:
+ break
+ order += 1
+
return Commit(
hash=commit_data['id'],
revision=revision,
@@ -232,7 +243,8 @@
branch_point=branch_point,
identifier=identifier if include_identifier else None,
branch=branch,
- timestamp=int(commit_data['committerTimestamp'] / 100),
+ timestamp=timestamp,
+ order=order,
author=self.contributors.create(
commit_data.get('committer', {}).get('displayName', None),
commit_data.get('committer', {}).get('emailAddress', None),
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -267,9 +267,23 @@
matches = self.GIT_SVN_REVISION.findall(commit_data['commit']['message'])
revision = int(matches[-1].split('@')[0]) if matches else None
- date = datetime.strptime(commit_data['commit']['committer']['date'], '%Y-%m-%dT%H:%M:%SZ')
email_match = self.EMAIL_RE.match(commit_data['commit']['author']['email'])
+ timestamp = int(calendar.timegm(datetime.strptime(
+ commit_data['commit']['committer']['date'], '%Y-%m-%dT%H:%M:%SZ',
+ ).timetuple()))
+ order = 0
+ while not identifier or order + 1 < identifier + (branch_point or 0):
+ response = self.request('commits/{}'.format('{}~{}'.format(commit_data['sha'], order + 1)))
+ if not response:
+ break
+ parent_timestamp = int(calendar.timegm(datetime.strptime(
+ response['commit']['committer']['date'], '%Y-%m-%dT%H:%M:%SZ',
+ ).timetuple()))
+ if parent_timestamp != timestamp:
+ break
+ order += 1
+
return Commit(
hash=commit_data['sha'],
revision=revision,
@@ -276,7 +290,8 @@
branch_point=branch_point,
identifier=identifier if include_identifier else None,
branch=branch,
- timestamp=int(calendar.timegm(date.timetuple())),
+ timestamp=timestamp,
+ order=order,
author=self.contributors.create(
commit_data['commit']['author']['name'],
email_match.group('email') if email_match else None,
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/commit_unittest.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/commit_unittest.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/commit_unittest.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -222,6 +222,7 @@
branch='main',
identifier='1@main',
timestamp=1000,
+ order=0,
author=dict(
name='Jonathan Bedard',
emails=['[email protected]'],
@@ -232,7 +233,7 @@
identifier='1@main',
timestamp=1000,
author=contributor,
- message='Message'
+ message='Message',
), cls=Commit.Encoder))
)
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -179,6 +179,7 @@
name='Jonathan Bedard',
emails=['[email protected]'],
), timestamp=1601663000,
+ order=0,
branch='main',
message='4th commit\nsvn-id: https://svn.example.org/repository/repository/trunk@4 268f45cc-cd09-0410-ab3c-d52691b4dbfc',
))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py (273764 => 273765)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py 2021-03-02 23:22:20 UTC (rev 273764)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py 2021-03-02 23:27:06 UTC (rev 273765)
@@ -277,7 +277,13 @@
with mock:
self.assertIsNone(local.Git(self.path).find('main', include_identifier=False).identifier)
+ def test_order(self):
+ for mock in [mocks.local.Git(self.path), mocks.local.Git(self.path, git_svn=True)]:
+ with mock:
+ self.assertEqual(0, local.Git(self.path).commit(hash='bae5d1e90999').order)
+ self.assertEqual(1, local.Git(self.path).commit(hash='d8bce26fa65c').order)
+
class TestGitHub(unittest.TestCase):
remote = 'https://github.example.com/WebKit/webkit'
@@ -390,7 +396,12 @@
with mocks.remote.GitHub():
self.assertIsNone(remote.GitHub(self.remote).find('main', include_identifier=False).identifier)
+ def test_order(self):
+ with mocks.remote.GitHub():
+ self.assertEqual(0, remote.GitHub(self.remote).commit(hash='bae5d1e90999').order)
+ self.assertEqual(1, remote.GitHub(self.remote).commit(hash='d8bce26fa65c').order)
+
class TestBitBucket(unittest.TestCase):
remote = 'https://bitbucket.example.com/projects/WEBKIT/repos/webkit'
@@ -502,3 +513,8 @@
def test_no_identifier(self):
with mocks.remote.BitBucket():
self.assertIsNone(remote.BitBucket(self.remote).find('main', include_identifier=False).identifier)
+
+ def test_order(self):
+ with mocks.remote.BitBucket():
+ self.assertEqual(0, remote.BitBucket(self.remote).commit(hash='bae5d1e90999').order)
+ self.assertEqual(1, remote.BitBucket(self.remote).commit(hash='d8bce26fa65c').order)