Changeset 267810 in webkit
- Timestamp:
- Sep 30, 2020 4:51:10 PM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r267805 r267810 1 2020-09-30 Jonathan Bedard <jbedard@apple.com> 2 3 [webkitscmpy] Check if a git checkout is linked to an SVN checkout 4 https://bugs.webkit.org/show_bug.cgi?id=216888 5 <rdar://problem/69446322> 6 7 Reviewed by Dewei Zhu. 8 9 * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Increment library version. 10 * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py: 11 (Git.info): Run `git svn info` if in a Git-SVN checkout. 12 (Git.is_svn): Check if in a Git-SVN checkout. 13 (Git.is_git): Return True. 14 * Scripts/libraries/webkitscmpy/webkitscmpy/local/scm.py: 15 (Scm.is_svn): Return False. 16 (Scm.is_git): Ditto. 17 * Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py: 18 (Svn.is_svn): Return True. 19 * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py: 20 (Git.__init__): Add `git svn` commands. 21 * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py: 22 (TestGit.test_scm_type): 23 (TestGit.test_info): 24 * Scripts/libraries/webkitscmpy/webkitscmpy/test/svn_unittest.py: 25 (TestSvn.test_scm_type): 26 1 27 2020-09-30 Jonathan Bedard <jbedard@apple.com> 2 28 -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py
r267096 r267810 47 47 ) 48 48 49 version = Version(0, 0, 4)49 version = Version(0, 0, 5) 50 50 51 51 from webkitscmpy.contributor import Contributor -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py
r267093 r267810 22 22 23 23 24 from webkitcorepy import run, decorators 24 from webkitcorepy import run, decorators, TimeoutExpired 25 25 from webkitscmpy.local import Scm 26 26 … … 37 37 if not self.root_path: 38 38 raise OSError('Provided path {} is not a git repository'.format(path)) 39 40 @decorators.Memoize(cached=False) 41 def info(self): 42 if not self.is_svn: 43 raise self.Exception('Cannot run SVN info on a git checkout which is not git-svn') 44 45 info_result = run([self.executable, 'svn', 'info'], cwd=self.path, capture_output=True, encoding='utf-8') 46 if info_result.returncode: 47 return {} 48 49 result = {} 50 for line in info_result.stdout.splitlines(): 51 split = line.split(': ') 52 result[split[0]] = ': '.join(split[1:]) 53 return result 54 55 @property 56 @decorators.Memoize() 57 def is_svn(self): 58 try: 59 return run( 60 [self.executable, 'svn', 'find-rev', 'r1'], 61 cwd=self.root_path, 62 capture_output=True, 63 encoding='utf-8', 64 timeout=1, 65 ).returncode == 0 66 except TimeoutExpired: 67 return False 68 69 @property 70 def is_git(self): 71 return True 39 72 40 73 @property -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/scm.py
r267093 r267810 44 44 45 45 @property 46 def is_svn(self): 47 return False 48 49 @property 50 def is_git(self): 51 return False 52 53 @property 46 54 def root_path(self): 47 55 raise NotImplementedError() -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py
r267093 r267810 51 51 52 52 @property 53 def is_svn(self): 54 return True 55 56 @property 53 57 def root_path(self): 54 58 return self.info(cached=True).get('Working Copy Root Path') -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py
r267093 r267810 33 33 branch=None, remote=None, branches=None, tags=None, 34 34 detached=None, default_branch='main', 35 git_svn=False, 35 36 ): 36 37 self.path = path … … 41 42 self.branches = branches or [] 42 43 self.tags = tags or [] 44 45 if git_svn: 46 git_svn_routes = [ 47 mocks.Subprocess.Route( 48 local.Git.executable, 'svn', 'find-rev', 'r1', 49 cwd=self.path, 50 completion=mocks.ProcessCompletion( 51 returncode=0, 52 stdout='d423ea82efaaed0dcbafb09aaa4a70fafdea0729\n', 53 ), 54 ), mocks.Subprocess.Route( 55 local.Git.executable, 'svn', 'info', 56 cwd=self.path, 57 completion=mocks.ProcessCompletion( 58 returncode=0, 59 stdout= 60 'Path: .\n' 61 'URL: {remote}/{branch}\n' 62 'Repository Root: {remote}\n'.format( 63 path=self.path, 64 remote=self.remote, 65 branch=self.branch, 66 ), 67 ), 68 ), 69 ] 70 71 else: 72 git_svn_routes = [mocks.Subprocess.Route( 73 local.Git.executable, 'svn', 74 cwd=self.path, 75 completion=mocks.ProcessCompletion(returncode=1, elapsed=2), 76 )] 43 77 44 78 super(Git, self).__init__( … … 117 151 stderr='fatal: not a git repository (or any parent up to mount point)\nStopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n', 118 152 ), 119 ), 153 ), *git_svn_routes 120 154 ) -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py
r267093 r267810 24 24 import unittest 25 25 26 from webkitcorepy import LoggerCapture 27 from webkitcorepy.mocks import Time as MockTime 26 28 from webkitscmpy import local, mocks 27 29 … … 70 72 with mocks.local.Git(self.path): 71 73 self.assertEqual(local.Git(self.path).default_branch, 'main') 74 75 def test_scm_type(self): 76 with mocks.local.Git(self.path), MockTime, LoggerCapture(): 77 self.assertTrue(local.Git(self.path).is_git) 78 self.assertFalse(local.Git(self.path).is_svn) 79 80 with mocks.local.Git(self.path, git_svn=True), MockTime, LoggerCapture(): 81 self.assertTrue(local.Git(self.path).is_git) 82 self.assertTrue(local.Git(self.path).is_svn) 83 84 def test_info(self): 85 with mocks.local.Git(self.path), MockTime, LoggerCapture(): 86 with self.assertRaises(local.Git.Exception): 87 self.assertEqual(dict(), local.Git(self.path).info()) 88 89 with mocks.local.Git(self.path, git_svn=True), MockTime, LoggerCapture(): 90 self.assertEqual( 91 { 92 'Path': '.', 93 'Repository Root': 'git@webkit.org:/mock/repository', 94 'URL': 'git@webkit.org:/mock/repository/main', 95 }, local.Git(self.path).info(), 96 ) -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/svn_unittest.py
r267093 r267810 67 67 with mocks.local.Svn(self.path): 68 68 self.assertEqual(local.Svn(self.path).default_branch, 'trunk') 69 70 def test_scm_type(self): 71 with mocks.local.Svn(self.path): 72 self.assertTrue(local.Svn(self.path).is_svn) 73 self.assertFalse(local.Svn(self.path).is_git)
Note: See TracChangeset
for help on using the changeset viewer.