| OLD | NEW |
| 1 # Copyright (c) 2009, 2010, 2011 Google Inc. All rights reserved. | 1 # Copyright (c) 2009, 2010, 2011 Google Inc. All rights reserved. |
| 2 # Copyright (c) 2009 Apple Inc. All rights reserved. | 2 # Copyright (c) 2009 Apple Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | 29 |
| 30 import logging | 30 import logging |
| 31 | 31 |
| 32 from webkitpy.common.system.filesystem import FileSystem | 32 from webkitpy.common.system.filesystem import FileSystem |
| 33 from webkitpy.common.system.executive import Executive | 33 from webkitpy.common.system.executive import Executive |
| 34 | 34 |
| 35 from .svn import SVN | |
| 36 from .git import Git | 35 from .git import Git |
| 37 | 36 |
| 38 _log = logging.getLogger(__name__) | 37 _log = logging.getLogger(__name__) |
| 39 | 38 |
| 40 | 39 |
| 41 class SCMDetector(object): | 40 class SCMDetector(object): |
| 42 def __init__(self, filesystem, executive): | 41 def __init__(self, filesystem, executive): |
| 43 self._filesystem = filesystem | 42 self._filesystem = filesystem |
| 44 self._executive = executive | 43 self._executive = executive |
| 45 | 44 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 61 else: | 60 else: |
| 62 raise Exception("FATAL: Failed to determine the SCM system for e
ither %s or %s" % (cwd, script_directory)) | 61 raise Exception("FATAL: Failed to determine the SCM system for e
ither %s or %s" % (cwd, script_directory)) |
| 63 return scm_system | 62 return scm_system |
| 64 | 63 |
| 65 def detect_scm_system(self, path, patch_directories=None): | 64 def detect_scm_system(self, path, patch_directories=None): |
| 66 absolute_path = self._filesystem.abspath(path) | 65 absolute_path = self._filesystem.abspath(path) |
| 67 | 66 |
| 68 if patch_directories == []: | 67 if patch_directories == []: |
| 69 patch_directories = None | 68 patch_directories = None |
| 70 | 69 |
| 71 if SVN.in_working_directory(absolute_path, executive=self._executive): | |
| 72 return SVN(cwd=absolute_path, patch_directories=patch_directories, f
ilesystem=self._filesystem, executive=self._executive) | |
| 73 | |
| 74 if Git.in_working_directory(absolute_path, executive=self._executive): | 70 if Git.in_working_directory(absolute_path, executive=self._executive): |
| 75 return Git(cwd=absolute_path, filesystem=self._filesystem, executive
=self._executive) | 71 return Git(cwd=absolute_path, filesystem=self._filesystem, executive
=self._executive) |
| 76 | 72 |
| 77 return None | 73 return None |
| 78 | 74 |
| 79 | 75 |
| 80 # FIXME: These free functions are all deprecated: | 76 # FIXME: These free functions are all deprecated: |
| 81 | 77 |
| 82 def detect_scm_system(path, patch_directories=None): | 78 def detect_scm_system(path, patch_directories=None): |
| 83 return SCMDetector(FileSystem(), Executive()).detect_scm_system(path, patch_
directories) | 79 return SCMDetector(FileSystem(), Executive()).detect_scm_system(path, patch_
directories) |
| OLD | NEW |