| OLD | NEW |
| 1 # Copyright (c) 2009, Google Inc. All rights reserved. | 1 # Copyright (c) 2009, 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 25 matching lines...) Expand all Loading... |
| 36 from webkitpy.common.system.executive import Executive | 36 from webkitpy.common.system.executive import Executive |
| 37 from webkitpy.common.system.executive import ScriptError | 37 from webkitpy.common.system.executive import ScriptError |
| 38 from webkitpy.common.system.filesystem import FileSystem | 38 from webkitpy.common.system.filesystem import FileSystem |
| 39 | 39 |
| 40 _log = logging.getLogger(__name__) | 40 _log = logging.getLogger(__name__) |
| 41 | 41 |
| 42 | 42 |
| 43 # SCM methods are expected to return paths relative to self.checkout_root. | 43 # SCM methods are expected to return paths relative to self.checkout_root. |
| 44 class SCM: | 44 class SCM: |
| 45 | 45 |
| 46 # Arguments are generally unused in abstract base methods below. |
| 47 # pylint: disable=unused-argument |
| 48 |
| 46 def __init__(self, cwd, executive=None, filesystem=None): | 49 def __init__(self, cwd, executive=None, filesystem=None): |
| 47 self.cwd = cwd | 50 self.cwd = cwd |
| 48 self._executive = executive or Executive() | 51 self._executive = executive or Executive() |
| 49 self._filesystem = filesystem or FileSystem() | 52 self._filesystem = filesystem or FileSystem() |
| 50 self.checkout_root = self.find_checkout_root(self.cwd) | 53 self.checkout_root = self.find_checkout_root(self.cwd) |
| 51 | 54 |
| 52 # A wrapper used by subclasses to create processes. | 55 # A wrapper used by subclasses to create processes. |
| 53 def _run(self, | 56 def _run(self, |
| 54 args, | 57 args, |
| 55 cwd=None, | 58 cwd=None, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 def _subclass_must_implement(): | 95 def _subclass_must_implement(): |
| 93 raise NotImplementedError("subclasses must implement") | 96 raise NotImplementedError("subclasses must implement") |
| 94 | 97 |
| 95 @classmethod | 98 @classmethod |
| 96 def in_working_directory(cls, path, executive=None): | 99 def in_working_directory(cls, path, executive=None): |
| 97 SCM._subclass_must_implement() | 100 SCM._subclass_must_implement() |
| 98 | 101 |
| 99 def find_checkout_root(self, path): | 102 def find_checkout_root(self, path): |
| 100 SCM._subclass_must_implement() | 103 SCM._subclass_must_implement() |
| 101 | 104 |
| 105 def add_all(self, pathspec=None): |
| 106 self._subclass_must_implement() |
| 107 |
| 102 def add(self, path, return_exit_code=False, recurse=True): | 108 def add(self, path, return_exit_code=False, recurse=True): |
| 103 self.add_list([path], return_exit_code, recurse) | 109 self.add_list([path], return_exit_code, recurse) |
| 104 | 110 |
| 105 def add_list(self, paths, return_exit_code=False, recurse=True): | 111 def add_list(self, paths, return_exit_code=False, recurse=True): |
| 106 self._subclass_must_implement() | 112 self._subclass_must_implement() |
| 107 | 113 |
| 108 def delete(self, path): | 114 def delete(self, path): |
| 109 self.delete_list([path]) | 115 self.delete_list([path]) |
| 110 | 116 |
| 111 def delete_list(self, paths): | 117 def delete_list(self, paths): |
| (...skipping 20 matching lines...) Expand all Loading... |
| 132 def commit_position(self, path): | 138 def commit_position(self, path): |
| 133 """Returns the latest chromium commit position found in the checkout.""" | 139 """Returns the latest chromium commit position found in the checkout.""" |
| 134 self._subclass_must_implement() | 140 self._subclass_must_implement() |
| 135 | 141 |
| 136 def timestamp_of_revision(self, path, revision): | 142 def timestamp_of_revision(self, path, revision): |
| 137 self._subclass_must_implement() | 143 self._subclass_must_implement() |
| 138 | 144 |
| 139 def blame(self, path): | 145 def blame(self, path): |
| 140 self._subclass_must_implement() | 146 self._subclass_must_implement() |
| 141 | 147 |
| 142 def has_working_directory_changes(self): | 148 def has_working_directory_changes(self, pathspec=None): |
| 143 self._subclass_must_implement() | 149 self._subclass_must_implement() |
| 144 | 150 |
| 145 #-------------------------------------------------------------------------- | 151 #-------------------------------------------------------------------------- |
| 146 # Subclasses must indicate if they support local commits, | 152 # Subclasses must indicate if they support local commits, |
| 147 # but the SCM baseclass will only call local_commits methods when this is tr
ue. | 153 # but the SCM baseclass will only call local_commits methods when this is tr
ue. |
| 148 @staticmethod | 154 @staticmethod |
| 149 def supports_local_commits(): | 155 def supports_local_commits(): |
| 150 SCM._subclass_must_implement() | 156 SCM._subclass_must_implement() |
| 151 | 157 |
| 152 def commit_locally_with_message(self, message): | 158 def commit_locally_with_message(self, message): |
| 153 _log.error("Your source control manager does not support local commits."
) | 159 _log.error("Your source control manager does not support local commits."
) |
| 154 sys.exit(1) | 160 sys.exit(1) |
| OLD | NEW |