Diff
Modified: trunk/Tools/ChangeLog (271257 => 271258)
--- trunk/Tools/ChangeLog 2021-01-07 20:56:28 UTC (rev 271257)
+++ trunk/Tools/ChangeLog 2021-01-07 21:15:47 UTC (rev 271258)
@@ -1,3 +1,24 @@
+2021-01-07 Jonathan Bedard <[email protected]>
+
+ [webkitscmpy] Use .git/config to verify if repository is git-svn
+ https://bugs.webkit.org/show_bug.cgi?id=220427
+ <rdar://problem/72899735>
+
+ Reviewed by Dewei Zhu.
+
+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Bump version number.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
+ (Git.is_svn): Use .git/config to verify if a repository is git-svn.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py:
+ (Git): Populate .git/config if the provided path is writeable.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py:
+ (TestFind.test_revision_git_svn): Use a temporary directory so files
+ can be written.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
+ (TestGit.test_scm_type): Use a temporary directory so files can be written.
+ (TestGit.test_info): Ditto.
+ (TestGit.test_commit_revision): Ditto.
+
2021-01-07 Chris Dumez <[email protected]>
[GPUProcess] Implement GPUProcess crash recovery for MediaElementAudioSourceNode
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (271257 => 271258)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2021-01-07 20:56:28 UTC (rev 271257)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2021-01-07 21:15:47 UTC (rev 271258)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Apple Inc. All rights reserved.
+# Copyright (C) 2020, 2021 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(0, 7, 1)
+version = Version(0, 7, 2)
AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('monotonic', Version(1, 5)))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py (271257 => 271258)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py 2021-01-07 20:56:28 UTC (rev 271257)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py 2021-01-07 21:15:47 UTC (rev 271258)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Apple Inc. All rights reserved.
+# Copyright (C) 2020, 2021 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -21,6 +21,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import logging
+import os
import re
import six
@@ -64,17 +65,16 @@
@property
@decorators.Memoize()
def is_svn(self):
- try:
- return run(
- [self.executable(), 'svn', 'find-rev', 'r1'],
- cwd=self.root_path,
- capture_output=True,
- encoding='utf-8',
- timeout=1,
- ).returncode == 0
- except TimeoutExpired:
+ config = os.path.join(self.root_path, '.git/config')
+ if not os.path.isfile(config):
return False
+ with open(config, 'r') as config:
+ for line in config.readlines():
+ if line.startswith('[svn-remote "svn"]'):
+ return True
+ return False
+
@property
def is_git(self):
return True
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py (271257 => 271258)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2021-01-07 20:56:28 UTC (rev 271257)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2021-01-07 21:15:47 UTC (rev 271258)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Apple Inc. All rights reserved.
+# Copyright (C) 2020, 2021 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -63,6 +63,44 @@
self.remotes = {'origin/{}'.format(branch): commits[-1] for branch, commits in self.commits.items()}
self.tags = {}
+ # If the directory provided actually exists, populate it
+ if os.path.isdir(self.path):
+ if not os.path.isdir(os.path.join(self.path, '.git')):
+ os.mkdir(os.path.join(self.path, '.git'))
+ with open(os.path.join(self.path, '.git', 'config'), 'w') as config:
+ config.write(
+ '[core]\n'
+ ' repositoryformatversion = 0\n'
+ ' filemode = true\n'
+ ' bare = false\n'
+ ' logallrefupdates = true\n'
+ ' ignorecase = true\n'
+ ' precomposeunicode = true\n'
+ '[remote "origin"]\n'
+ ' url = ""
+ ' fetch = +refs/heads/*:refs/remotes/origin/*\n'
+ '[branch "{branch}"]\n'
+ ' remote = origin\n'
+ ' merge = refs/heads/{branch}\n'.format(
+ remote=self.remote,
+ branch=self.default_branch,
+ ))
+ if git_svn:
+ domain = 'webkit.org'
+ if self.remote.startswith('https://'):
+ domain = self.remote.split('/')[2]
+ elif '@' in self.remote:
+ domain = self.remote.split('@')[1].split(':')[0]
+
+ config.write(
+ '[svn-remote "svn"]\n'
+ ' url = ""
+ ' fetch = trunk:refs/remotes/origin/{branch}'.format(
+ domain=domain,
+ branch=self.default_branch,
+ )
+ )
+
if git_svn:
git_svn_routes = [
mocks.Subprocess.Route(
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py (271257 => 271258)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py 2021-01-07 20:56:28 UTC (rev 271257)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py 2021-01-07 21:15:47 UTC (rev 271258)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Apple Inc. All rights reserved.
+# Copyright (C) 2020, 2021 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -21,6 +21,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import json
+import shutil
+import tempfile
import unittest
from datetime import datetime
@@ -113,12 +115,16 @@
self.assertEqual(captured.stdout.getvalue(), '2.2@branch-b | r5 | 5th commit\n')
def test_revision_git_svn(self):
- with OutputCapture() as captured, mocks.local.Git(self.path, git_svn=True), mocks.local.Svn(), MockTime:
- self.assertEqual(0, program.main(
- args=('find', 'r5', '-q'),
- path=self.path,
- ))
- self.assertEqual(captured.stdout.getvalue(), '2.2@branch-b | 3cd32e352410, r5 | 5th commit\n')
+ try:
+ dirname = tempfile.mkdtemp()
+ with OutputCapture() as captured, mocks.local.Git(dirname, git_svn=True, remote='[email protected]:{}'.format(self.path)), mocks.local.Svn(), MockTime:
+ self.assertEqual(0, program.main(
+ args=('find', 'r5', '-q'),
+ path=dirname,
+ ))
+ self.assertEqual(captured.stdout.getvalue(), '2.2@branch-b | 3cd32e352410, r5 | 5th commit\n')
+ finally:
+ shutil.rmtree(dirname)
def test_standard(self):
with OutputCapture() as captured, mocks.local.Git(self.path, git_svn=True), mocks.local.Svn(), MockTime:
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py (271257 => 271258)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py 2021-01-07 20:56:28 UTC (rev 271257)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py 2021-01-07 21:15:47 UTC (rev 271258)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Apple Inc. All rights reserved.
+# Copyright (C) 2020, 2021 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -21,6 +21,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
+import shutil
+import tempfile
import unittest
from datetime import datetime
@@ -77,52 +79,65 @@
self.assertEqual(local.Git(self.path).default_branch, 'main')
def test_scm_type(self):
- with mocks.local.Git(self.path), MockTime, LoggerCapture():
- self.assertTrue(local.Git(self.path).is_git)
- self.assertFalse(local.Git(self.path).is_svn)
+ try:
+ dirname = tempfile.mkdtemp()
+ with mocks.local.Git(dirname, remote='[email protected]:{}'.format(self.path)), MockTime, LoggerCapture():
+ self.assertTrue(local.Git(dirname).is_git)
+ self.assertFalse(local.Git(dirname).is_svn)
- with mocks.local.Git(self.path, git_svn=True), MockTime, LoggerCapture():
- self.assertTrue(local.Git(self.path).is_git)
- self.assertTrue(local.Git(self.path).is_svn)
+ with mocks.local.Git(dirname, git_svn=True, remote='[email protected]:{}'.format(self.path)), MockTime, LoggerCapture():
+ self.assertTrue(local.Git(dirname).is_git)
+ self.assertTrue(local.Git(dirname).is_svn)
+ finally:
+ shutil.rmtree(dirname)
+
def test_info(self):
- with mocks.local.Git(self.path), MockTime, LoggerCapture():
- with self.assertRaises(local.Git.Exception):
- self.assertEqual(dict(), local.Git(self.path).info())
+ try:
+ dirname = tempfile.mkdtemp()
+ with mocks.local.Git(dirname, remote='[email protected]:{}'.format(self.path)), MockTime, LoggerCapture():
+ with self.assertRaises(local.Git.Exception):
+ self.assertEqual(dict(), local.Git(dirname).info())
- with mocks.local.Git(self.path, git_svn=True), MockTime:
- self.assertDictEqual(
- {
- 'Path': '.',
- 'Repository Root': '[email protected]:/mock/repository',
- 'URL': '[email protected]:/mock/repository/main',
- 'Revision': '6',
- 'Node Kind': 'directory',
- 'Schedule': 'normal',
- 'Last Changed Author': '[email protected]',
- 'Last Changed Rev': '6',
- 'Last Changed Date': datetime.fromtimestamp(1601665000).strftime('%Y-%m-%d %H:%M:%S'),
- }, local.Git(self.path).info(),
- )
+ with mocks.local.Git(dirname, git_svn=True, remote='[email protected]:{}'.format(self.path)), MockTime:
+ self.assertDictEqual(
+ {
+ 'Path': '.',
+ 'Repository Root': '[email protected]:/mock/repository',
+ 'URL': '[email protected]:/mock/repository/main',
+ 'Revision': '6',
+ 'Node Kind': 'directory',
+ 'Schedule': 'normal',
+ 'Last Changed Author': '[email protected]',
+ 'Last Changed Rev': '6',
+ 'Last Changed Date': datetime.fromtimestamp(1601665000).strftime('%Y-%m-%d %H:%M:%S'),
+ }, local.Git(dirname).info(),
+ )
+ finally:
+ shutil.rmtree(dirname)
def test_commit_revision(self):
- with mocks.local.Git(self.path), MockTime, LoggerCapture():
- with self.assertRaises(local.Git.Exception):
- self.assertEqual(None, local.Git(self.path).commit(revision=1))
+ try:
+ dirname = tempfile.mkdtemp()
+ with mocks.local.Git(dirname), MockTime, LoggerCapture():
+ with self.assertRaises(local.Git.Exception):
+ self.assertEqual(None, local.Git(dirname).commit(revision=1))
- with mocks.local.Git(self.path, git_svn=True), MockTime, LoggerCapture():
- self.assertEqual('1@main', str(local.Git(self.path).commit(revision=1)))
- self.assertEqual('2@main', str(local.Git(self.path).commit(revision=2)))
- self.assertEqual('2.1@branch-a', str(local.Git(self.path).commit(revision=3)))
- self.assertEqual('3@main', str(local.Git(self.path).commit(revision=4)))
- self.assertEqual('2.2@branch-b', str(local.Git(self.path).commit(revision=5)))
- self.assertEqual('4@main', str(local.Git(self.path).commit(revision=6)))
- self.assertEqual('2.2@branch-a', str(local.Git(self.path).commit(revision=7)))
- self.assertEqual('2.3@branch-b', str(local.Git(self.path).commit(revision=8)))
+ with mocks.local.Git(dirname, git_svn=True, remote='[email protected]:{}'.format(self.path)), MockTime, LoggerCapture():
+ self.assertEqual('1@main', str(local.Git(dirname).commit(revision=1)))
+ self.assertEqual('2@main', str(local.Git(dirname).commit(revision=2)))
+ self.assertEqual('2.1@branch-a', str(local.Git(dirname).commit(revision=3)))
+ self.assertEqual('3@main', str(local.Git(dirname).commit(revision=4)))
+ self.assertEqual('2.2@branch-b', str(local.Git(dirname).commit(revision=5)))
+ self.assertEqual('4@main', str(local.Git(dirname).commit(revision=6)))
+ self.assertEqual('2.2@branch-a', str(local.Git(dirname).commit(revision=7)))
+ self.assertEqual('2.3@branch-b', str(local.Git(dirname).commit(revision=8)))
- # Out-of-bounds commit
- with self.assertRaises(local.Git.Exception):
- self.assertEqual(None, local.Git(self.path).commit(revision=10))
+ # Out-of-bounds commit
+ with self.assertRaises(local.Git.Exception):
+ self.assertEqual(None, local.Git(dirname).commit(revision=10))
+ finally:
+ shutil.rmtree(dirname)
def test_commit_hash(self):
for mock in [mocks.local.Git(self.path), mocks.local.Git(self.path, git_svn=True)]: