Changeset 213562 in webkit
- Timestamp:
- Mar 7, 2017 7:46:19 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r213555 r213562 1 2017-03-07 Kocsen Chung <kocsen_chung@apple.com> 2 3 Perf and layout test results should report using correct scm revision. 4 https://bugs.webkit.org/show_bug.cgi?id=169171 5 6 Reviewed by Ryosuke Niwa. 7 8 For accurate record keeping, perf test and layout test results should 9 report using the native scm revision as an identifier. 10 To do so we introduce a new scm functions: 11 `native_revision()` and `timestamp_of_native_revision()`. 12 The former is responsible for returning a git hash if scm.git or an 13 svn revision if scm.svn. The latter is responsible for retrieving the correct timestamp. 14 We also add the corresponding tests and a helper function `_most_recent_log_for_revision`. 15 16 * Scripts/webkitpy/common/checkout/scm/scm.py: 17 (SCM.run): 18 Drive-by indentation fix to adhere to WebKit style conventions. 19 (SCM.svn_revision): 20 Remove superfluous comment. 21 (SCM.native_revision): 22 Add new abstract function `native_revision` and make it a `_subclass_must_implement()` 23 as we want to closely mimic `svn_revision()` function due to their similar behavior. 24 (SCM.timestamp_of_native_revision): 25 Add new abstract function `timestamp_of_native_revision` to closely mimic `timestamp_of_revision`. 26 27 * Scripts/webkitpy/common/checkout/scm/git.py: 28 (Git._most_recent_log_for_revision): 29 New helper function similar to `_most_recent_log_matching` that is git hash friendly. 30 (Git.native_revision): 31 Implement new function `native_revision()`. Get the native_revision by running: 32 33 `git log -1 --pretty=format:%H` 34 35 and thus returning the latest git hash (in long format). 36 (Git.timestamp_of_native_revision): 37 Since perftestrunner and layout_test.controllers.manager use the new native_revision 38 function, we create a new native_revision timestamp retriever. 39 You will notice this uses a far more simplified way to retrieve UTC strict-ISO timestamp 40 than its non-native counterpart: `timestamp_of_revision()`. 41 * Scripts/webkitpy/common/checkout/scm/svn.py: 42 (SVN.native_revision): 43 Implement native_revision for SVN: simply return self.svn_revision() 44 (SVN.timestamp_of_native_revision): 45 Implement timestamp_of_native_revision for SVN: simply return self.timestamp_of_revision() 46 47 * Scripts/webkitpy/common/checkout/scm/scm_unittest.py: 48 (test_native_revision): 49 [SVN] Confirm that svn_revision == native_revision. And that native_revision returns 5. 50 Use '.' as the path parameter instead of svn_checkout_path to avoid violating pylint/E1101 51 and since we are guaranteed by test setUp to be in the correct SVN dir. 52 (GitTest.test_native_revision): 53 [Git] Confirm that `git rev-parse HEAD` is equal to newly implemented native_revision(). 54 (GitSVNTest.test_native_revision): 55 [Git] Confirm that `git rev-parse HEAD` is equal to newly implemented native_revision(). 56 (test_timestamp_of_native_revision): 57 Test new function `timestamp_of_native_revision`. Very similar fashion to 58 `test_timestamp_of_revision`. 59 60 * Scripts/webkitpy/common/checkout/scm/scm_mock.py: 61 (MockSCM.native_revision): 62 Add MockSCM.native_revision to behave like svn.py (default). 63 (MockSCM.test_native_revision): 64 Add MockSCM.test_native_revision to behave like its non-native counterpart. 65 66 * Scripts/webkitpy/layout_tests/controllers/manager.py: 67 (Manager.upload_results): 68 When iterating through a list of projects, make sure we use the project's new native revision. 69 * Scripts/webkitpy/performance_tests/perftestsrunner.py: 70 (_generate_results_dict): 71 As per the FIXME in manager.py, we have duplicate code in perftestsrunner.py. 72 So make the same exact change here. 73 1 74 2017-03-07 Tim Horton <timothy_horton@apple.com> 2 75 -
trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py
r203832 r213562 271 271 return self._run_git(['log', '-1', '--grep=' + grep_str, '--date=iso', self.find_checkout_root(path)]) 272 272 273 def _most_recent_log_for_revision(self, revision, path): 274 return self._run_git(['log', '-1', revision, '--date=iso', self.find_checkout_root(path)]) 275 273 276 def svn_revision(self, path): 274 277 git_log = self._most_recent_log_matching('git-svn-id:', path) … … 277 280 return "" 278 281 return str(match.group('svn_revision')) 282 283 def native_revision(self, path): 284 return self._run_git(['log', '-1', '--pretty=format:%H', self.find_checkout_root(path)]) 279 285 280 286 def svn_url(self): … … 300 306 time_without_timezone = time_with_timezone - datetime.timedelta(hours=sign * int(match.group(8)), minutes=int(match.group(9))) 301 307 return time_without_timezone.strftime('%Y-%m-%dT%H:%M:%SZ') 308 309 def timestamp_of_native_revision(self, path, sha): 310 unix_timestamp = self._run_git(['log', '-1', sha, '--pretty="format:%ct"', self.find_checkout_root(path)]).rstrip() 311 commit_timestamp = datetime.datetime.utcfromtimestamp(float(unix_timestamp)) 312 return commit_timestamp.strftime('%Y-%m-%dT%H:%M:%SZ') 302 313 303 314 def prepend_svn_revision(self, diff): -
trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py
r202362 r213562 70 70 # FIXME: We should set cwd appropriately. 71 71 return self._executive.run_command(args, 72 73 74 75 76 77 72 cwd=cwd, 73 input=input, 74 error_handler=error_handler, 75 return_exit_code=return_exit_code, 76 return_stderr=return_stderr, 77 decode_output=decode_output) 78 78 79 79 # SCM always returns repository relative path, but sometimes we need … … 159 159 160 160 def svn_revision(self, path): 161 """Returns the latest svn revision found in the checkout.""" 161 self._subclass_must_implement() 162 163 def native_revision(self, path): 162 164 self._subclass_must_implement() 163 165 164 166 def timestamp_of_revision(self, path, revision): 167 self._subclass_must_implement() 168 169 def timestamp_of_native_revision(self, path, revision): 165 170 self._subclass_must_implement() 166 171 -
trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py
r212579 r213562 85 85 return '5678' 86 86 87 def native_revision(self, path): 88 return self.svn_revision(path) 89 87 90 def timestamp_of_revision(self, path, revision): 91 return '2013-02-01 08:48:05 +0000' 92 93 def timestamp_of_native_revision(self, path, revision): 88 94 return '2013-02-01 08:48:05 +0000' 89 95 -
trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py
r208498 r213562 903 903 self._shared_test_head_svn_revision() 904 904 905 def test_native_revision(self): 906 self.assertEqual(self.scm.head_svn_revision(), self.scm.native_revision('.')) 907 self.assertEqual(self.scm.native_revision('.'), '5') 908 905 909 def test_propset_propget(self): 906 910 filepath = os.path.join(self.svn_checkout_path, "test_file") … … 1081 1085 self.assertEqual(scm.head_svn_revision(), '') 1082 1086 1087 def test_native_revision(self): 1088 scm = self.tracking_scm 1089 command = ['git', '-C', scm.checkout_root, 'rev-parse', 'HEAD'] 1090 self.assertEqual(scm.native_revision(scm.checkout_root), run_command(command).strip()) 1091 1083 1092 def test_rename_files(self): 1084 1093 scm = self.tracking_scm … … 1592 1601 self._shared_test_head_svn_revision() 1593 1602 1603 def test_native_revision(self): 1604 command = ['git', '-C', self.git_checkout_path, 'rev-parse', 'HEAD'] 1605 self.assertEqual(self.scm.native_revision(self.git_checkout_path), run_command(command).strip()) 1606 1594 1607 def test_to_object_name(self): 1595 1608 relpath = 'test_file_commit1' … … 1673 1686 scm._run_git = lambda args: 'Date: 2013-02-08 01:55:21 -0800' 1674 1687 self.assertEqual(scm.timestamp_of_revision('some-path', '12345'), '2013-02-08T09:55:21Z') 1688 1689 def test_timestamp_of_native_revision(self): 1690 scm = self.make_scm() 1691 scm.find_checkout_root = lambda path: '' 1692 scm._run_git = lambda args: '1360310749' 1693 self.assertEqual(scm.timestamp_of_native_revision('some-path', '1a1c3b08814bc2a8c15b0f6db63cdce68f2aaa7a'), '2013-02-08T08:05:49Z') 1694 1695 scm._run_git = lambda args: '1360279923' 1696 self.assertEqual(scm.timestamp_of_native_revision('some-path', '1a1c3b08814bc2a8c15b0f6db63cdce68f2aaa7a'), '2013-02-07T23:32:03Z') 1697 1698 scm._run_git = lambda args: '1360317321' 1699 self.assertEqual(scm.timestamp_of_native_revision('some-path', '1a1c3b08814bc2a8c15b0f6db63cdce68f2aaa7a'), '2013-02-08T09:55:21Z') -
trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py
r203832 r213562 269 269 return self.value_from_svn_info(path, 'Revision') 270 270 271 def native_revision(self, path): 272 return self.svn_revision(path) 273 271 274 def timestamp_of_revision(self, path, revision): 272 275 # We use --xml to get timestamps like 2013-02-08T08:18:04.964409Z … … 275 278 match = re.search(r"^<date>(?P<value>.+)</date>\r?$", info_output, re.MULTILINE) 276 279 return match.group('value') 280 281 def timestamp_of_native_revision(self, path, revision): 282 return self.timestamp_of_revision(path, revision) 277 283 278 284 # FIXME: This method should be on Checkout. -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py
r209798 r213562 472 472 for (name, path) in self._port.repository_paths(): 473 473 scm = SCMDetector(self._port.host.filesystem, self._port.host.executive).detect_scm_system(path) or self._port.host.scm() 474 revision = scm. svn_revision(path)475 revisions[name] = {'revision': revision, 'timestamp': scm.timestamp_of_ revision(path, revision)}474 revision = scm.native_revision(path) 475 revisions[name] = {'revision': revision, 'timestamp': scm.timestamp_of_native_revision(path, revision)} 476 476 477 477 _log.info("Uploading JSON files for master: %s builder: %s build: %s slave: %s to %s", master_name, builder_name, build_number, build_slave, hostname) -
trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py
r212182 r213562 271 271 for (name, path) in self._port.repository_paths(): 272 272 scm = SCMDetector(self._host.filesystem, self._host.executive).detect_scm_system(path) or self._host.scm() 273 revision = scm. svn_revision(path)274 revisions[name] = {'revision': revision, 'timestamp': scm.timestamp_of_ revision(path, revision)}273 revision = scm.native_revision(path) 274 revisions[name] = {'revision': revision, 'timestamp': scm.timestamp_of_native_revision(path, revision)} 275 275 276 276 meta_info = {
Note: See TracChangeset
for help on using the changeset viewer.