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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108693
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-02-23 Eric Seidel <eric@webkit.org>
+
+ 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 <webkit.review.bot@gmail.com>
Unreviewed, rolling out r108685.
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)
# 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
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):
def in_working_directory(path):
SCM._subclass_must_implement()
- @staticmethod
def find_checkout_root(path):
SCM._subclass_must_implement()
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):
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