Title: [145141] trunk/Tools
Revision
145141
Author
dpra...@chromium.org
Date
2013-03-07 14:40:05 -0800 (Thu, 07 Mar 2013)

Log Message

run-perf-tests fails due to svn_revision not working on a pure git clone
https://bugs.webkit.org/show_bug.cgi?id=110839

Reviewed by Ryosuke Niwa.

Previously we would call git svn find-rev to look up the commit for
a given revision, and that'll hang in a pure git checkout.

This patch changes the way we look up svn revisions in a git
repository to use git log --grep 'git-svn-id', which is much faster
than grepping ourselves. It also renames timestamp_of_latest_commit()
to timestamp_of_revision() in order to accurately reflect what
the method is doing. Note that this patch only changes the logic
inside latest_revision() and svn_revision(). I'll file a separate
bug to change git_commit_from_svn_revision().

This patch also contains some fixes to unit tests that had bit-rotted
or were otherwise fragile, so that test-webkitpy --all would pass
cleanly, and a fix to outputcapture so that
test-webkitpy -p would work correctly again.

* Scripts/webkitpy/common/checkout/scm/git.py:
(Git.svn_revision):
(Git.timestamp_of_revision):
* Scripts/webkitpy/common/checkout/scm/scm.py:
(SCM.svn_revision):
(SCM.timestamp_of_revision):
* Scripts/webkitpy/common/checkout/scm/scm_mock.py:
(MockSCM.timestamp_of_revision):
* Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
(_shared_test_commit_with_message):
(test_commit_without_authorization):
(test_timestamp_of_revision):
* Scripts/webkitpy/common/checkout/scm/svn.py:
(SVN.timestamp_of_revision):
* Scripts/webkitpy/common/system/outputcapture.py:
  Importing unittest2 directly may not be safe if this module is
  imported before the autoinstaller gets a chance to set things up
  properly. We don't actually need unittest2 here.
* Scripts/webkitpy/performance_tests/perftestsrunner.py:
(PerfTestsRunner._generate_results_dict):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (145140 => 145141)


--- trunk/Tools/ChangeLog	2013-03-07 22:37:02 UTC (rev 145140)
+++ trunk/Tools/ChangeLog	2013-03-07 22:40:05 UTC (rev 145141)
@@ -1,3 +1,47 @@
+2013-03-07  Dirk Pranke  <dpra...@chromium.org>
+
+        run-perf-tests fails due to svn_revision not working on a pure git clone
+        https://bugs.webkit.org/show_bug.cgi?id=110839
+
+        Reviewed by Ryosuke Niwa.
+
+        Previously we would call git svn find-rev to look up the commit for
+        a given revision, and that'll hang in a pure git checkout.
+
+        This patch changes the way we look up svn revisions in a git
+        repository to use git log --grep 'git-svn-id', which is much faster
+        than grepping ourselves. It also renames timestamp_of_latest_commit()
+        to timestamp_of_revision() in order to accurately reflect what
+        the method is doing. Note that this patch only changes the logic
+        inside latest_revision() and svn_revision(). I'll file a separate
+        bug to change git_commit_from_svn_revision().
+
+        This patch also contains some fixes to unit tests that had bit-rotted
+        or were otherwise fragile, so that test-webkitpy --all would pass
+        cleanly, and a fix to outputcapture so that
+        test-webkitpy -p would work correctly again.
+
+        * Scripts/webkitpy/common/checkout/scm/git.py:
+        (Git.svn_revision):
+        (Git.timestamp_of_revision):
+        * Scripts/webkitpy/common/checkout/scm/scm.py:
+        (SCM.svn_revision):
+        (SCM.timestamp_of_revision):
+        * Scripts/webkitpy/common/checkout/scm/scm_mock.py:
+        (MockSCM.timestamp_of_revision):
+        * Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
+        (_shared_test_commit_with_message):
+        (test_commit_without_authorization):
+        (test_timestamp_of_revision):
+        * Scripts/webkitpy/common/checkout/scm/svn.py:
+        (SVN.timestamp_of_revision):
+        * Scripts/webkitpy/common/system/outputcapture.py:
+          Importing unittest2 directly may not be safe if this module is
+          imported before the autoinstaller gets a chance to set things up
+          properly. We don't actually need unittest2 here.
+        * Scripts/webkitpy/performance_tests/perftestsrunner.py:
+        (PerfTestsRunner._generate_results_dict):
+
 2013-03-07  Christophe Dumez  <ch.du...@sisa.samsung.com>
 
         [EFL] Bump libsoup dependency to 2.40.3 to fix regressions

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py (145140 => 145141)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py	2013-03-07 22:37:02 UTC (rev 145140)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py	2013-03-07 22:40:05 UTC (rev 145141)
@@ -246,17 +246,20 @@
     def display_name(self):
         return "git"
 
+    def _most_recent_log_matching(self, grep_str, path):
+        # We use '--grep=' + foo rather than '--grep', foo because
+        # git 1.7.0.4 (and earlier) didn't support the separate arg.
+        return self._run_git(['log', '-1', '--grep=' + grep_str, '--date=iso', self.find_checkout_root(path)])
+
     def svn_revision(self, path):
-        _log.debug('Running git.head_svn_revision... (Temporary logging message)')
-        git_log = self._run_git(['log', '-25', self.find_checkout_root(path)])
+        git_log = self._most_recent_log_matching('git-svn-id:', path)
         match = re.search("^\s*git-svn-id:.*@(?P<svn_revision>\d+)\ ", git_log, re.MULTILINE)
         if not match:
             return ""
         return str(match.group('svn_revision'))
 
-    def timestamp_of_latest_commit(self, path, revision):
-        git_commit = self.git_commit_from_svn_revision(revision)
-        git_log = self._run_git(['log', '-1', '-r', git_commit, '--date=iso', self.find_checkout_root(path)])
+    def timestamp_of_revision(self, path, revision):
+        git_log = self._most_recent_log_matching('git-svn-id:.*@%s' % revision, path)
         match = re.search("^Date:\s*(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}) ([+-])(\d{2})(\d{2})$", git_log, re.MULTILINE)
         if not match:
             return ""
@@ -307,6 +310,9 @@
 
     @memoized
     def git_commit_from_svn_revision(self, svn_revision):
+        # FIXME: https://bugs.webkit.org/show_bug.cgi?id=111668
+        # We should change this to run git log --grep 'git-svn-id' instead
+        # so that we don't require git+svn to be set up.
         git_commit = self._run_git_svn_find_rev('r%s' % svn_revision)
         if not git_commit:
             # FIXME: Alternatively we could offer to update the checkout? Or return None?

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py (145140 => 145141)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py	2013-03-07 22:37:02 UTC (rev 145140)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py	2013-03-07 22:40:05 UTC (rev 145141)
@@ -167,9 +167,10 @@
         return self.svn_revision(self.checkout_root)
 
     def svn_revision(self, path):
+        """Returns the latest svn revision found in the checkout."""
         self._subclass_must_implement()
 
-    def timestamp_of_latest_commit(self, path, revision):
+    def timestamp_of_revision(self, path, revision):
         self._subclass_must_implement()
 
     def create_patch(self, git_commit=None, changed_files=None):

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py (145140 => 145141)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py	2013-03-07 22:37:02 UTC (rev 145140)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py	2013-03-07 22:40:05 UTC (rev 145141)
@@ -84,7 +84,7 @@
     def svn_revision(self, path):
         return '5678'
 
-    def timestamp_of_latest_commit(self, path, revision):
+    def timestamp_of_revision(self, path, revision):
         return '2013-02-01 08:48:05 +0000'
 
     def create_patch(self, git_commit, changed_files=None):

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py (145140 => 145141)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py	2013-03-07 22:37:02 UTC (rev 145140)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py	2013-03-07 22:40:05 UTC (rev 145141)
@@ -716,7 +716,12 @@
         self._shared_test_commit_with_message("dba...@webkit.org")
 
     def test_commit_without_authorization(self):
-        self.scm.svn_server_realm = SVN.svn_server_realm
+        # FIXME: https://bugs.webkit.org/show_bug.cgi?id=111669
+        # This test ends up looking in the actal $HOME/.subversion for authorization,
+        # which makes it fragile. For now, set it to use a realm that won't be authorized,
+        # but we should really plumb through a fake_home_dir here like we do in
+        # test_has_authorization_for_realm.
+        self.scm.svn_server_realm = '<http://svn.example.com:80> Example'
         self.assertRaises(AuthenticationError, self._shared_test_commit_with_message)
 
     def test_has_authorization_for_realm_using_credentials_with_passtype(self):
@@ -1510,8 +1515,7 @@
 
     def test_to_object_name(self):
         relpath = 'test_file_commit1'
-        fullpath = os.path.join(self.git_checkout_path, relpath)
-        self._two_local_commits()
+        fullpath = os.path.realpath(os.path.join(self.git_checkout_path, relpath))
         self.assertEqual(relpath, self.scm.to_object_name(fullpath))
 
     def test_show_head(self):
@@ -1562,7 +1566,8 @@
         expected_stderr = """\
 MOCK run_command: ['git', 'merge-base', 'MOCKVALUE', 'HEAD'], cwd=%(checkout)s
 MOCK run_command: ['git', 'diff', '--binary', '--no-color', '--no-ext-diff', '--full-index', '--no-renames', '', 'MOCK output of child process', '--'], cwd=%(checkout)s
-MOCK run_command: ['git', 'log', '-25', './MOCK output of child process'], cwd=%(checkout)s
+MOCK run_command: ['git', 'rev-parse', '--show-toplevel'], cwd=%(checkout)s
+MOCK run_command: ['git', 'log', '-1', '--grep=git-svn-id:', '--date=iso', './MOCK output of child process/MOCK output of child process'], cwd=%(checkout)s
 """ % {'checkout': scm.checkout_root}
         OutputCapture().assert_outputs(self, scm.create_patch, expected_logs=expected_stderr)
 
@@ -1578,14 +1583,14 @@
     def test_push_local_commits_to_server_without_username_and_with_password(self):
         self.assertRaises(AuthenticationError, self.make_scm().push_local_commits_to_server, {'password': 'blah'})
 
-    def test_timestamp_of_latest_commit(self):
+    def test_timestamp_of_revision(self):
         scm = self.make_scm()
         scm.find_checkout_root = lambda path: ''
         scm._run_git = lambda args: 'Date: 2013-02-08 08:05:49 +0000'
-        self.assertEqual(scm.timestamp_of_latest_commit('some-path', '12345'), '2013-02-08T08:05:49Z')
+        self.assertEqual(scm.timestamp_of_revision('some-path', '12345'), '2013-02-08T08:05:49Z')
 
         scm._run_git = lambda args: 'Date: 2013-02-08 01:02:03 +0130'
-        self.assertEqual(scm.timestamp_of_latest_commit('some-path', '12345'), '2013-02-07T23:32:03Z')
+        self.assertEqual(scm.timestamp_of_revision('some-path', '12345'), '2013-02-07T23:32:03Z')
 
         scm._run_git = lambda args: 'Date: 2013-02-08 01:55:21 -0800'
-        self.assertEqual(scm.timestamp_of_latest_commit('some-path', '12345'), '2013-02-08T09:55:21Z')
+        self.assertEqual(scm.timestamp_of_revision('some-path', '12345'), '2013-02-08T09:55:21Z')

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py (145140 => 145141)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py	2013-03-07 22:37:02 UTC (rev 145140)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py	2013-03-07 22:40:05 UTC (rev 145141)
@@ -246,7 +246,7 @@
     def svn_revision(self, path):
         return self.value_from_svn_info(path, 'Revision')
 
-    def timestamp_of_latest_commit(self, path, revision):
+    def timestamp_of_revision(self, path, revision):
         # We use --xml to get timestamps like 2013-02-08T08:18:04.964409Z
         repository_root = self.value_from_svn_info(self.checkout_root, 'Repository Root')
         info_output = Executive().run_command([self.executable_name, 'log', '-r', revision, '--xml', repository_root], cwd=path).rstrip()

Modified: trunk/Tools/Scripts/webkitpy/common/system/outputcapture.py (145140 => 145141)


--- trunk/Tools/Scripts/webkitpy/common/system/outputcapture.py	2013-03-07 22:37:02 UTC (rev 145140)
+++ trunk/Tools/Scripts/webkitpy/common/system/outputcapture.py	2013-03-07 22:40:05 UTC (rev 145141)
@@ -29,7 +29,7 @@
 # Class for unittest support.  Used for capturing stderr/stdout.
 
 import logging
-import unittest2 as unittest
+import unittest  # Don't use unittest2 here as the autoinstaller may not have it yet.
 import sys
 from StringIO import StringIO
 

Modified: trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py (145140 => 145141)


--- trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py	2013-03-07 22:37:02 UTC (rev 145140)
+++ trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py	2013-03-07 22:40:05 UTC (rev 145141)
@@ -238,7 +238,7 @@
         for (name, path) in self._port.repository_paths():
             scm = SCMDetector(self._host.filesystem, self._host.executive).detect_scm_system(path) or self._host.scm()
             revision = scm.svn_revision(path)
-            revisions[name] = {'revision': str(revision), 'timestamp': scm.timestamp_of_latest_commit(path, revision)}
+            revisions[name] = {'revision': revision, 'timestamp': scm.timestamp_of_revision(path, revision)}
 
         meta_info = {
             'description': description,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to