Changeset 266628 in webkit
- Timestamp:
- Sep 4, 2020 12:12:16 PM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 14 added
- 4 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r266626 r266628 1 2020-09-04 Jonathan Bedard <jbedard@apple.com> 2 3 [webkitscmpy] Add root, branch and remote for local SCM repositories 4 https://bugs.webkit.org/show_bug.cgi?id=215960 5 <rdar://problem/67968919> 6 7 Reviewed by Dewei Zhu. 8 9 * Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py: Bump version. 10 * Scripts/libraries/webkitcorepy/webkitcorepy/decorators.py: Added. 11 (Memoize): Add a memoize call that can cache a response for a set amount of time 12 Or be explicitly cleared. 13 * Scripts/libraries/webkitcorepy/webkitcorepy/tests/decorators_unittest.py: Added. 14 (TestMemoize): 15 * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Bump version. 16 * Scripts/libraries/webkitscmpy/webkitscmpy/local: Added. 17 * Scripts/libraries/webkitscmpy/webkitscmpy/local/__init__.py: Added. 18 * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py: Added. 19 (Git): Object representing a local git checkout. 20 (Git.is_checkout): Check if a given path is a git checkout. 21 (Git.__init__): Initialize a Git checkout. 22 (Git.root_path): Return the path for the root of the local repository. 23 (Git.branch): Return the current branch. 24 (Git.remote): Return the url of the remote. 25 * Scripts/libraries/webkitscmpy/webkitscmpy/local/scm.py: Added. 26 (Scm): Base class for all local SCM checkouts. 27 (Scm.Exception): 28 (Scm.from_path): Given a path, return an instantiated SVN object from that 29 path, if possible. 30 (Scm.__init__): 31 (Scm.root_path): Virtual function implemented by children. 32 (Scm.branch): Ditto. 33 (Scm.remote): Ditto. 34 * Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py: Added. 35 (Svn): Object representing a local Svn checkout. 36 (Svn.is_checkout): Check if a given path is a svn checkout. 37 (Svn.__init__): Initialize a Svn checkout. 38 (Svn.info): Return the contents of svn info as a dictionary. 39 (Svn.root_path): Return the path for the root of the local repository. 40 (Svn.branch): Return the current branch. 41 (Svn.remote): Return the url of the remote. 42 * Scripts/libraries/webkitscmpy/webkitscmpy/mocks: Added. 43 * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/__init__.py: Added. 44 * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local: Added. 45 * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/__init__.py: Added. 46 * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py: Added. 47 (Git): Mock a local Git repository. 48 (Git.__init__): 49 * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/svn.py: Added. 50 (Svn): Mock a local SVN repository. 51 * Scripts/libraries/webkitscmpy/webkitscmpy/test: Added. 52 * Scripts/libraries/webkitscmpy/webkitscmpy/test/__init__.py: Added. 53 * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py: Added. 54 (TestGit): 55 * Scripts/libraries/webkitscmpy/webkitscmpy/test/scm_unittest.py: Added. 56 (TestScm): 57 * Scripts/libraries/webkitscmpy/webkitscmpy/test/svn_unittest.py: Added. 58 (TestSvn): 59 1 60 2020-09-04 Aakash Jain <aakash_jain@apple.com> 2 61 -
trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py
r266478 r266628 36 36 from webkitcorepy.output_capture import LoggerCapture, OutputCapture, OutputDuplicate 37 37 38 version = Version(0, 4, 4)38 version = Version(0, 4, 5) 39 39 40 40 from webkitcorepy.autoinstall import Package, AutoInstall -
trunk/Tools/Scripts/libraries/webkitscmpy/setup.py
r266255 r266628 49 49 author_email='jbedard@apple.com', 50 50 license='Modified BSD', 51 packages=['webkitscmpy'], 51 packages=[ 52 'webkitscmpy', 53 'webkitscmpy.local', 54 'webkitscmpy.mocks', 55 'webkitscmpy.mocks.local', 56 'webkitscmpy.test', 57 ], 52 58 install_requires=['webkitcorepy'], 53 59 include_package_data=True, -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py
r266255 r266628 1 # Copyright (C) 20 19Apple Inc. All rights reserved.1 # Copyright (C) 2020 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 47 47 ) 48 48 49 version = Version(0, 0, 1) 49 version = Version(0, 0, 2) 50 51 from webkitscmpy import local 52 from webkitscmpy import mocks 53 50 54 name = 'webkitscmpy' -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/scm.py
r266627 r266628 1 # Copyright (C) 20 19Apple Inc. All rights reserved.1 # Copyright (C) 2020 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 21 21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 22 23 import logging24 import os25 import sys26 23 27 log = logging.getLogger('webkitscmpy') 24 class Scm(object): 25 class Exception(RuntimeError): 26 pass 28 27 28 executable = None 29 29 30 def _maybe_add_webkitcorepy_path(): 31 # Hopefully we're beside webkitcorepy, otherwise webkitcorepy will need to be installed. 32 libraries_path = os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) 33 webkitcorepy_path = os.path.join(libraries_path, 'webkitcorepy') 34 if os.path.isdir(webkitcorepy_path) and os.path.isdir(os.path.join(webkitcorepy_path, 'webkitcorepy')) and webkitcorepy_path not in sys.path: 35 sys.path.insert(0, webkitcorepy_path) 30 @classmethod 31 def from_path(cls, path): 32 from webkitscmpy import local 36 33 34 if local.Git.is_checkout(path): 35 return local.Git(path) 36 if local.Svn.is_checkout(path): 37 return local.Svn(path) 38 raise OSError('{} is not a known SCM type') 37 39 38 _maybe_add_webkitcorepy_path() 40 def __init__(self, path): 41 if not isinstance(path, str): 42 raise ValueError('') 43 self.path = path 39 44 40 try: 41 from webkitcorepy.version import Version 42 except ImportError: 43 raise ImportError( 44 "'webkitcorepy' could not be found on your Python path.\n" + 45 "You are not running from a WebKit checkout.\n" + 46 "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`" 47 ) 45 @property 46 def root_path(self): 47 raise NotImplementedError() 48 48 49 version = Version(0, 0, 1) 50 name = 'webkitscmpy' 49 @property 50 def branch(self): 51 raise NotImplementedError() 52 53 def remote(self, name=None): 54 raise NotImplementedError() -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py
r266627 r266628 1 # Copyright (C) 20 19Apple Inc. All rights reserved.1 # Copyright (C) 2020 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 21 21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 22 23 import logging24 23 import os 25 import sys24 import unittest 26 25 27 log = logging.getLogger('webkitscmpy') 26 from webkitscmpy import local, mocks 28 27 29 28 30 def _maybe_add_webkitcorepy_path(): 31 # Hopefully we're beside webkitcorepy, otherwise webkitcorepy will need to be installed. 32 libraries_path = os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) 33 webkitcorepy_path = os.path.join(libraries_path, 'webkitcorepy') 34 if os.path.isdir(webkitcorepy_path) and os.path.isdir(os.path.join(webkitcorepy_path, 'webkitcorepy')) and webkitcorepy_path not in sys.path: 35 sys.path.insert(0, webkitcorepy_path) 29 class TestGit(unittest.TestCase): 30 path = '/mock/repository' 36 31 32 def test_detection(self): 33 with mocks.local.Git(self.path), mocks.local.Svn(): 34 detect = local.Scm.from_path(self.path) 35 self.assertEqual(detect.executable, local.Git.executable) 37 36 38 _maybe_add_webkitcorepy_path() 37 def test_root(self): 38 with mocks.local.Git(self.path): 39 self.assertEqual(local.Git(self.path).root_path, self.path) 39 40 40 try: 41 from webkitcorepy.version import Version 42 except ImportError: 43 raise ImportError( 44 "'webkitcorepy' could not be found on your Python path.\n" + 45 "You are not running from a WebKit checkout.\n" + 46 "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`" 47 ) 41 with self.assertRaises(OSError): 42 local.Git(os.path.dirname(self.path)).root_path 48 43 49 version = Version(0, 0, 1) 50 name = 'webkitscmpy' 44 def test_branch(self): 45 with mocks.local.Git(self.path): 46 self.assertEqual(local.Git(self.path).branch, 'master') 47 48 with mocks.local.Git(self.path, detached=True): 49 self.assertEqual(local.Git(self.path).branch, None) 50 51 def test_remote(self): 52 with mocks.local.Git(self.path) as repo: 53 self.assertEqual(local.Git(self.path).remote(), repo.remote) -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/scm_unittest.py
r266627 r266628 1 # Copyright (C) 20 19Apple Inc. All rights reserved.1 # Copyright (C) 2020 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 21 21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 22 23 import logging24 import os25 import sys26 23 27 log = logging.getLogger('webkitscmpy') 24 import unittest 25 from webkitscmpy import local, mocks 28 26 29 27 30 def _maybe_add_webkitcorepy_path(): 31 # Hopefully we're beside webkitcorepy, otherwise webkitcorepy will need to be installed. 32 libraries_path = os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) 33 webkitcorepy_path = os.path.join(libraries_path, 'webkitcorepy') 34 if os.path.isdir(webkitcorepy_path) and os.path.isdir(os.path.join(webkitcorepy_path, 'webkitcorepy')) and webkitcorepy_path not in sys.path: 35 sys.path.insert(0, webkitcorepy_path) 28 class TestScm(unittest.TestCase): 29 path = '/mock/directory' 36 30 31 def test_detection(self): 32 with mocks.local.Git(), mocks.local.Svn(): 33 with self.assertRaises(OSError): 34 local.Scm.from_path(self.path) 37 35 38 _maybe_add_webkitcorepy_path() 36 def test_root(self): 37 with self.assertRaises(NotImplementedError): 38 local.Scm(self.path).root_path 39 39 40 try: 41 from webkitcorepy.version import Version 42 except ImportError: 43 raise ImportError( 44 "'webkitcorepy' could not be found on your Python path.\n" + 45 "You are not running from a WebKit checkout.\n" + 46 "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`" 47 ) 40 def test_branch(self): 41 with self.assertRaises(NotImplementedError): 42 local.Scm(self.path).branch 48 43 49 version = Version(0, 0, 1) 50 name = 'webkitscmpy' 44 def test_remote(self): 45 with self.assertRaises(NotImplementedError): 46 local.Scm(self.path).remote() -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/svn_unittest.py
r266627 r266628 1 # Copyright (C) 20 19Apple Inc. All rights reserved.1 # Copyright (C) 2020 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 21 21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 22 23 import logging24 23 import os 25 import sys24 import unittest 26 25 27 log = logging.getLogger('webkitscmpy') 26 from webkitscmpy import local, mocks 28 27 29 28 30 def _maybe_add_webkitcorepy_path(): 31 # Hopefully we're beside webkitcorepy, otherwise webkitcorepy will need to be installed. 32 libraries_path = os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) 33 webkitcorepy_path = os.path.join(libraries_path, 'webkitcorepy') 34 if os.path.isdir(webkitcorepy_path) and os.path.isdir(os.path.join(webkitcorepy_path, 'webkitcorepy')) and webkitcorepy_path not in sys.path: 35 sys.path.insert(0, webkitcorepy_path) 29 class TestSvn(unittest.TestCase): 30 path = '/mock/repository' 36 31 32 def test_detection(self): 33 with mocks.local.Svn(self.path), mocks.local.Git(): 34 detect = local.Scm.from_path(self.path) 35 self.assertEqual(detect.executable, local.Svn.executable) 37 36 38 _maybe_add_webkitcorepy_path() 37 def test_root(self): 38 with mocks.local.Svn(self.path): 39 self.assertEqual(local.Svn(self.path).root_path, self.path) 39 40 40 try: 41 from webkitcorepy.version import Version 42 except ImportError: 43 raise ImportError( 44 "'webkitcorepy' could not be found on your Python path.\n" + 45 "You are not running from a WebKit checkout.\n" + 46 "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`" 47 ) 41 with self.assertRaises(OSError): 42 local.Svn(os.path.dirname(self.path)).root_path 48 43 49 version = Version(0, 0, 1) 50 name = 'webkitscmpy' 44 def test_branch(self): 45 with mocks.local.Svn(self.path): 46 self.assertEqual(local.Svn(self.path).branch, 'trunk') 47 48 def test_remote(self): 49 with mocks.local.Svn(self.path) as repo: 50 self.assertEqual(local.Svn(self.path).remote(), repo.remote)
Note: See TracChangeset
for help on using the changeset viewer.