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 23 matching lines...) Expand all Loading... |
34 import sys | 34 import sys |
35 | 35 |
36 from webkitpy.common.system.executive import Executive, ScriptError | 36 from webkitpy.common.system.executive import Executive, ScriptError |
37 from webkitpy.common.system.filesystem import FileSystem | 37 from webkitpy.common.system.filesystem import FileSystem |
38 | 38 |
39 _log = logging.getLogger(__name__) | 39 _log = logging.getLogger(__name__) |
40 | 40 |
41 | 41 |
42 # SCM methods are expected to return paths relative to self.checkout_root. | 42 # SCM methods are expected to return paths relative to self.checkout_root. |
43 class SCM: | 43 class SCM: |
| 44 |
44 def __init__(self, cwd, executive=None, filesystem=None): | 45 def __init__(self, cwd, executive=None, filesystem=None): |
45 self.cwd = cwd | 46 self.cwd = cwd |
46 self._executive = executive or Executive() | 47 self._executive = executive or Executive() |
47 self._filesystem = filesystem or FileSystem() | 48 self._filesystem = filesystem or FileSystem() |
48 self.checkout_root = self.find_checkout_root(self.cwd) | 49 self.checkout_root = self.find_checkout_root(self.cwd) |
49 | 50 |
50 # A wrapper used by subclasses to create processes. | 51 # A wrapper used by subclasses to create processes. |
51 def _run(self, args, cwd=None, input=None, error_handler=None, return_exit_c
ode=False, return_stderr=True, decode_output=True): | 52 def _run(self, args, cwd=None, input=None, error_handler=None, return_exit_c
ode=False, return_stderr=True, decode_output=True): |
52 # FIXME: We should set cwd appropriately. | 53 # FIXME: We should set cwd appropriately. |
53 return self._executive.run_command(args, | 54 return self._executive.run_command(args, |
54 cwd=cwd, | 55 cwd=cwd, |
55 input=input, | 56 input=input, |
56 error_handler=error_handler, | 57 error_handler=error_handler, |
57 return_exit_code=return_exit_code, | 58 return_exit_code=return_exit_code, |
58 return_stderr=return_stderr, | 59 return_stderr=return_stderr, |
59 decode_output=decode_output) | 60 decode_output=decode_output) |
60 | 61 |
61 # SCM always returns repository relative path, but sometimes we need | 62 # SCM always returns repository relative path, but sometimes we need |
62 # absolute paths to pass to rm, etc. | 63 # absolute paths to pass to rm, etc. |
63 def absolute_path(self, repository_relative_path): | 64 def absolute_path(self, repository_relative_path): |
64 return self._filesystem.join(self.checkout_root, repository_relative_pat
h) | 65 return self._filesystem.join(self.checkout_root, repository_relative_pat
h) |
65 | 66 |
66 def _run_status_and_extract_filenames(self, status_command, status_regexp): | 67 def _run_status_and_extract_filenames(self, status_command, status_regexp): |
67 filenames = [] | 68 filenames = [] |
68 # We run with cwd=self.checkout_root so that returned-paths are root-rel
ative. | 69 # We run with cwd=self.checkout_root so that returned-paths are root-rel
ative. |
69 for line in self._run(status_command, cwd=self.checkout_root).splitlines
(): | 70 for line in self._run(status_command, cwd=self.checkout_root).splitlines
(): |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 #-------------------------------------------------------------------------- | 133 #-------------------------------------------------------------------------- |
133 # Subclasses must indicate if they support local commits, | 134 # Subclasses must indicate if they support local commits, |
134 # but the SCM baseclass will only call local_commits methods when this is tr
ue. | 135 # but the SCM baseclass will only call local_commits methods when this is tr
ue. |
135 @staticmethod | 136 @staticmethod |
136 def supports_local_commits(): | 137 def supports_local_commits(): |
137 SCM._subclass_must_implement() | 138 SCM._subclass_must_implement() |
138 | 139 |
139 def commit_locally_with_message(self, message): | 140 def commit_locally_with_message(self, message): |
140 _log.error("Your source control manager does not support local commits."
) | 141 _log.error("Your source control manager does not support local commits."
) |
141 sys.exit(1) | 142 sys.exit(1) |
OLD | NEW |