Title: [108693] trunk/Tools
Revision
108693
Author
[email protected]
Date
2012-02-23 16:05:33 -0800 (Thu, 23 Feb 2012)

Log Message

Use self._filesystem in more places in the SCM classes
https://bugs.webkit.org/show_bug.cgi?id=79415

Reviewed by Adam Barth.

* Scripts/webkitpy/common/checkout/scm/detection_unittest.py:
(SCMDetectorTest.test_detect_scm_system):
* Scripts/webkitpy/common/checkout/scm/git.py:
(Git.find_checkout_root):
(Git.to_object_name):
* Scripts/webkitpy/common/checkout/scm/scm.py:
(SCM.__init__):
(SCM.in_working_directory):
* Scripts/webkitpy/common/checkout/scm/svn.py:
(SVN.find_uuid):
(SVN.find_checkout_root):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (108692 => 108693)


--- trunk/Tools/ChangeLog	2012-02-24 00:03:29 UTC (rev 108692)
+++ trunk/Tools/ChangeLog	2012-02-24 00:05:33 UTC (rev 108693)
@@ -1,3 +1,22 @@
+2012-02-23  Eric Seidel  <[email protected]>
+
+        Use self._filesystem in more places in the SCM classes
+        https://bugs.webkit.org/show_bug.cgi?id=79415
+
+        Reviewed by Adam Barth.
+
+        * Scripts/webkitpy/common/checkout/scm/detection_unittest.py:
+        (SCMDetectorTest.test_detect_scm_system):
+        * Scripts/webkitpy/common/checkout/scm/git.py:
+        (Git.find_checkout_root):
+        (Git.to_object_name):
+        * Scripts/webkitpy/common/checkout/scm/scm.py:
+        (SCM.__init__):
+        (SCM.in_working_directory):
+        * Scripts/webkitpy/common/checkout/scm/svn.py:
+        (SVN.find_uuid):
+        (SVN.find_checkout_root):
+
 2012-02-23  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r108685.

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/detection_unittest.py (108692 => 108693)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/detection_unittest.py	2012-02-24 00:03:29 UTC (rev 108692)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/detection_unittest.py	2012-02-24 00:05:33 UTC (rev 108693)
@@ -36,7 +36,7 @@
 
 
 class SCMDetectorTest(unittest.TestCase):
-    def test_find_checkout_root(self):
+    def test_detect_scm_system(self):
         filesystem = MockFileSystem()
         executive = MockExecutive(should_log=True)
         detector = SCMDetector(filesystem, executive)

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


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py	2012-02-24 00:03:29 UTC (rev 108692)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py	2012-02-24 00:05:33 UTC (rev 108693)
@@ -105,19 +105,18 @@
             # The Windows bots seem to through a WindowsError when git isn't installed.
             return False
 
-    @classmethod
-    def find_checkout_root(cls, path):
-        # FIXME: This should use a FileSystem object instead of os.path.
+    def find_checkout_root(self, path):
         # "git rev-parse --show-cdup" would be another way to get to the root
-        (checkout_root, dot_git) = os.path.split(run_command(['git', 'rev-parse', '--git-dir'], cwd=(path or "./")))
-        if not os.path.isabs(checkout_root):  # Sometimes git returns relative paths
-            checkout_root = os.path.join(path, checkout_root)
+        git_output = self._executive.run_command(['git', 'rev-parse', '--git-dir'], cwd=(path or "./"))
+        (checkout_root, dot_git) = self._filesystem.split(git_output)
+        if not self._filesystem.isabs(checkout_root):  # Sometimes git returns relative paths
+            checkout_root = self._filesystem.join(path, checkout_root)
         return checkout_root
 
-    @classmethod
-    def to_object_name(cls, filepath):
-        # FIXME: This should use a FileSystem object instead of os.path.
-        root_end_with_slash = os.path.join(cls.find_checkout_root(os.path.dirname(filepath)), '')
+    def to_object_name(self, filepath):
+        # FIXME: This can't be the right way to append a slash.
+        root_end_with_slash = self._filesystem.join(self.find_checkout_root(self._filesystem.dirname(filepath)), '')
+        # FIXME: This seems to want some sort of rel_path instead?
         return filepath.replace(root_end_with_slash, '')
 
     @classmethod

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


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py	2012-02-24 00:03:29 UTC (rev 108692)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py	2012-02-24 00:05:33 UTC (rev 108693)
@@ -60,9 +60,9 @@
 class SCM:
     def __init__(self, cwd, executive=None, filesystem=None):
         self.cwd = cwd
-        self.checkout_root = self.find_checkout_root(self.cwd)
         self._executive = executive or Executive()
         self._filesystem = filesystem or FileSystem()
+        self.checkout_root = self.find_checkout_root(self.cwd)
 
     # A wrapper used by subclasses to create processes.
     def run(self, args, cwd=None, input=None, error_handler=None, return_exit_code=False, return_stderr=True, decode_output=True):
@@ -137,7 +137,6 @@
     def in_working_directory(path):
         SCM._subclass_must_implement()
 
-    @staticmethod
     def find_checkout_root(path):
         SCM._subclass_must_implement()
 

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


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py	2012-02-24 00:03:29 UTC (rev 108692)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py	2012-02-24 00:05:33 UTC (rev 108693)
@@ -86,11 +86,10 @@
     def in_working_directory(path):
         return os.path.isdir(os.path.join(path, '.svn'))
 
-    @classmethod
-    def find_uuid(cls, path):
-        if not cls.in_working_directory(path):
+    def find_uuid(self, path):
+        if not self.in_working_directory(path):
             return None
-        return cls.value_from_svn_info(path, 'Repository UUID')
+        return self.value_from_svn_info(path, 'Repository UUID')
 
     @classmethod
     def value_from_svn_info(cls, path, field_name):
@@ -102,19 +101,18 @@
             raise ScriptError(script_args=svn_info_args, message='svn info did not contain a %s.' % field_name)
         return match.group('value')
 
-    @staticmethod
-    def find_checkout_root(path):
-        uuid = SVN.find_uuid(path)
+    def find_checkout_root(self, path):
+        uuid = self.find_uuid(path)
         # If |path| is not in a working directory, we're supposed to return |path|.
         if not uuid:
             return path
         # Search up the directory hierarchy until we find a different UUID.
         last_path = None
         while True:
-            if uuid != SVN.find_uuid(path):
+            if uuid != self.find_uuid(path):
                 return last_path
             last_path = path
-            (path, last_component) = os.path.split(path)
+            (path, last_component) = self._filesystem.split(path)
             if last_path == path:
                 return None
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to