Diff
Modified: trunk/Tools/ChangeLog (278962 => 278963)
--- trunk/Tools/ChangeLog 2021-06-16 22:39:29 UTC (rev 278962)
+++ trunk/Tools/ChangeLog 2021-06-16 22:41:35 UTC (rev 278963)
@@ -1,5 +1,21 @@
2021-06-16 Jonathan Bedard <jbed...@apple.com>
+ [webkitscmpy] Support branch queries in mock git log
+ https://bugs.webkit.org/show_bug.cgi?id=225889
+ <rdar://problem/78122705>
+
+ Reviewed by Stephanie Lewis.
+
+ * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py: Add support for branches in
+ `git log` commands.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
+ (TestGit.test_log):
+ (TestGit.test_branch_log):
+
+2021-06-16 Jonathan Bedard <jbed...@apple.com>
+
[webkitscmpy] Cache more Git commands
https://bugs.webkit.org/show_bug.cgi?id=227082
<rdar://problem/79405244>
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (278962 => 278963)
--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2021-06-16 22:39:29 UTC (rev 278962)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2021-06-16 22:41:35 UTC (rev 278963)
@@ -29,7 +29,7 @@
setup(
name='webkitscmpy',
- version='0.14.5',
+ version='0.14.6',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (278962 => 278963)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2021-06-16 22:39:29 UTC (rev 278962)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2021-06-16 22:41:35 UTC (rev 278963)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(0, 14, 5)
+version = Version(0, 14, 6)
AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('monotonic', Version(1, 5)))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py (278962 => 278963)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2021-06-16 22:39:29 UTC (rev 278962)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2021-06-16 22:41:35 UTC (rev 278963)
@@ -253,7 +253,7 @@
'AuthorDate: {date}\n'
'Commit: {author} <{email}>\n'
'CommitDate: {date}\n'
- '\n{log}'.format(
+ '\n{log}\n'.format(
hash=commit.hash,
author=commit.author.name,
email=commit.author.email,
@@ -353,7 +353,7 @@
return self.commits[self.default_branch][found.branch_point - difference - 1]
return None
- something = str(something)
+ something = str(something).replace('remotes/', '')
if '..' in something:
a, b = something.split('..')
a = self.find(a)
@@ -501,28 +501,43 @@
)
def commits_in_range(self, begin, end):
+ begin = begin.replace('remotes/', '') if begin else begin
+ end = end.replace('remotes/', '') if end else end
+
+ if begin and self.remotes.get(begin):
+ begin = self.remotes.get(begin).hash
+ if end and self.remotes.get(end):
+ end = self.remotes.get(end).hash
+
branches = [self.default_branch]
- for branch, commits in self.commits.items():
- if branch == self.default_branch:
- continue
- for commit in commits:
- if commit.hash == end:
- branches.insert(0, branch)
+ if end in self.commits.keys() and end != self.default_branch:
+ branches.append(end)
+ else:
+ for branch, commits in self.commits.items():
+ if branch == self.default_branch:
+ continue
+ for commit in commits:
+ if commit.hash.startswith(end):
+ branches.insert(0, branch)
+ break
+ if len(branches) > 1:
break
- if len(branches) > 1:
- break
in_range = False
previous = None
for branch in branches:
for commit in reversed(self.commits[branch]):
- if commit.hash == end:
+ if branch == begin:
+ break
+ if commit.hash.startswith(end) or end == branch:
in_range = True
if in_range and (not previous or commit.hash != previous.hash):
yield commit
previous = commit
- if commit.hash == begin:
+ if begin and commit.hash.startswith(begin):
in_range = False
+ break
+
in_range = False
if not previous or branch == self.default_branch:
continue
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py (278962 => 278963)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py 2021-06-16 22:39:29 UTC (rev 278962)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py 2021-06-16 22:41:35 UTC (rev 278963)
@@ -26,7 +26,7 @@
import unittest
from datetime import datetime
-from webkitcorepy import LoggerCapture, OutputCapture
+from webkitcorepy import run, LoggerCapture, OutputCapture
from webkitcorepy.mocks import Time as MockTime
from webkitscmpy import Commit, local, mocks, remote
@@ -305,7 +305,79 @@
git.commit(hash='9b8311f2'),
]), Commit.Encoder().default(list(git.commits(begin=dict(argument='9b8311f2'), end=dict(argument='621652ad')))))
+ def test_log(self):
+ with mocks.local.Git(self.path, git_svn=True):
+ self.assertEqual(
+ run([
+ local.Git.executable(), 'log', '--format=fuller', 'remotes/origin/main...1abe25b4',
+ ], cwd=self.path, capture_output=True, encoding='utf-8').stdout,
+ '''commit d8bce26fa65c6fc8f39c17927abb77f69fab82fc
+Author: Jonathan Bedard <jbed...@apple.com>
+AuthorDate: Sat Oct 03 03:46:40 2020 +0000
+Commit: Jonathan Bedard <jbed...@apple.com>
+CommitDate: Sat Oct 03 03:46:40 2020 +0000
+ Patch Series
+ git-svn-id: https://svn.example.org/repository/repository/trunk@9 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+commit bae5d1e90999d4f916a8a15810ccfa43f37a2fd6
+Author: Jonathan Bedard <jbed...@apple.com>
+AuthorDate: Sat Oct 03 03:46:40 2020 +0000
+Commit: Jonathan Bedard <jbed...@apple.com>
+CommitDate: Sat Oct 03 03:46:40 2020 +0000
+
+ 8th commit
+ git-svn-id: https://svn.example.org/repository/repository/trunk@8 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+commit 1abe25b443e985f93b90d830e4a7e3731336af4d
+Author: Jonathan Bedard <jbed...@apple.com>
+AuthorDate: Sat Oct 03 02:23:20 2020 +0000
+Commit: Jonathan Bedard <jbed...@apple.com>
+CommitDate: Sat Oct 03 02:23:20 2020 +0000
+
+ 4th commit
+ git-svn-id: https://svn.example.org/repository/repository/trunk@4 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+'''
+ )
+
+ def test_branch_log(self):
+ with mocks.local.Git(self.path, git_svn=True):
+ self.assertEqual(
+ run([
+ local.Git.executable(), 'log', '--format=fuller', 'branch-b...main',
+ ], cwd=self.path, capture_output=True, encoding='utf-8').stdout,
+ '''commit 790725a6d79e28db2ecdde29548d2262c0bd059d
+Author: Jonathan Bedard <jbed...@apple.com>
+AuthorDate: Sat Oct 03 03:30:00 2020 +0000
+Commit: Jonathan Bedard <jbed...@apple.com>
+CommitDate: Sat Oct 03 03:30:00 2020 +0000
+
+ 7th commit
+ git-svn-id: https://svn.example.org/repository/repository/trunk@7 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+commit 3cd32e352410565bb543821fbf856a6d3caad1c4
+Author: Jonathan Bedard <jbed...@apple.com>
+AuthorDate: Sat Oct 03 02:40:00 2020 +0000
+Commit: Jonathan Bedard <jbed...@apple.com>
+CommitDate: Sat Oct 03 02:40:00 2020 +0000
+
+ 5th commit
+ Cherry pick
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@6 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+ git-svn-id: https://svn.example.org/repository/repository/trunk@5 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+commit a30ce8494bf1ac2807a69844f726be4a9843ca55
+Author: Jonathan Bedard <jbed...@apple.com>
+AuthorDate: Sat Oct 03 02:06:40 2020 +0000
+Commit: Jonathan Bedard <jbed...@apple.com>
+CommitDate: Sat Oct 03 02:06:40 2020 +0000
+
+ 3rd commit
+ git-svn-id: https://svn.example.org/repository/repository/trunk@3 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+'''
+ )
+
+
class TestGitHub(unittest.TestCase):
remote = 'https://github.example.com/WebKit/WebKit'