OLD | NEW |
1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # Redistribution and use in source and binary forms, with or without | 3 # found in the LICENSE file. |
4 # modification, are permitted provided that the following conditions are | |
5 # met: | |
6 # | |
7 # * Redistributions of source code must retain the above copyright | |
8 # notice, this list of conditions and the following disclaimer. | |
9 # * Redistributions in binary form must reproduce the above | |
10 # copyright notice, this list of conditions and the following disclaimer | |
11 # in the documentation and/or other materials provided with the | |
12 # distribution. | |
13 # * Neither the name of Google Inc. nor the names of its | |
14 # contributors may be used to endorse or promote products derived from | |
15 # this software without specific prior written permission. | |
16 # | |
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | 4 |
29 from webkitpy.common.system.filesystem_mock import MockFileSystem | 5 from webkitpy.common.system.filesystem_mock import MockFileSystem |
30 from webkitpy.common.system.executive_mock import MockExecutive | 6 from webkitpy.common.system.executive_mock import MockExecutive |
31 | 7 |
32 | 8 |
33 class MockSCM(object): | 9 class MockGit(object): |
34 | 10 |
35 # Arguments are generally unused in methods that return canned values below. | 11 # Arguments are listed below, even if they're unused, in order to match |
36 # pylint: disable=unused-argument | 12 # the Git class. pylint: disable=unused-argument |
37 | 13 |
38 executable_name = "MockSCM" | 14 executable_name = 'mock-git' |
39 | 15 |
40 def __init__(self, filesystem=None, executive=None): | 16 def __init__(self, filesystem=None, executive=None): |
41 self.checkout_root = "/mock-checkout" | 17 self.checkout_root = '/mock-checkout' |
42 self.added_paths = set() | 18 self.added_paths = set() |
43 self._filesystem = filesystem or MockFileSystem() | 19 self._filesystem = filesystem or MockFileSystem() |
44 self._executive = executive or MockExecutive() | 20 self._executive = executive or MockExecutive() |
45 self._local_commits = [] | 21 self._local_commits = [] |
46 | 22 |
47 def add_all(self, pathspec=None): | 23 def add_all(self, pathspec=None): |
48 if not pathspec: | 24 if not pathspec: |
49 pathspec = self.checkout_root | 25 pathspec = self.checkout_root |
50 for path in self._filesystem.glob(pathspec): | 26 for path in self._filesystem.glob(pathspec): |
51 self.add_list(self._filesystem.files_under(path)) | 27 self.add_list(self._filesystem.files_under(path)) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 return 10000 | 78 return 10000 |
103 return None | 79 return None |
104 | 80 |
105 def timestamp_of_revision(self, path, revision): | 81 def timestamp_of_revision(self, path, revision): |
106 return '2013-02-01 08:48:05 +0000' | 82 return '2013-02-01 08:48:05 +0000' |
107 | 83 |
108 def commit_locally_with_message(self, message): | 84 def commit_locally_with_message(self, message): |
109 self._local_commits.append([message]) | 85 self._local_commits.append([message]) |
110 | 86 |
111 def local_commits(self): | 87 def local_commits(self): |
112 """For testing purposes, returns the internal recording of commits made
via commit_locally_with_message. | 88 """Returns the internal recording of commits made via |commit_locally_wi
th_message|. |
113 Format as [ message, commit_all_working_directory_changes, author ]. | 89 |
| 90 This is a testing convenience method; commits are formatted as: |
| 91 [ message, commit_all_working_directory_changes, author ]. |
114 """ | 92 """ |
115 return self._local_commits | 93 return self._local_commits |
116 | 94 |
117 def delete(self, path): | 95 def delete(self, path): |
118 return self.delete_list([path]) | 96 return self.delete_list([path]) |
119 | 97 |
120 def delete_list(self, paths): | 98 def delete_list(self, paths): |
121 if not self._filesystem: | 99 if not self._filesystem: |
122 return | 100 return |
123 for path in paths: | 101 for path in paths: |
124 if self._filesystem.exists(path): | 102 if self._filesystem.exists(path): |
125 self._filesystem.remove(path) | 103 self._filesystem.remove(path) |
126 | 104 |
127 def move(self, origin, destination): | 105 def move(self, origin, destination): |
128 if self._filesystem: | 106 if self._filesystem: |
129 self._filesystem.move(self.absolute_path(origin), self.absolute_path
(destination)) | 107 self._filesystem.move(self.absolute_path(origin), self.absolute_path
(destination)) |
130 | 108 |
131 def changed_files(self): | 109 def changed_files(self): |
132 return [] | 110 return [] |
133 | 111 |
134 def unstaged_changes(self): | 112 def unstaged_changes(self): |
135 return {} | 113 return {} |
OLD | NEW |