Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py

Issue 2594513003: Merge scm.py and git.py in webkitpy. (Closed)
Patch Set: Rebased Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (C) 2011 Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
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
29 from webkitpy.common.system.filesystem_mock import MockFileSystem
30 from webkitpy.common.system.executive_mock import MockExecutive
31
32
33 class MockSCM(object):
34
35 # Arguments are generally unused in methods that return canned values below.
36 # pylint: disable=unused-argument
37
38 executable_name = "MockSCM"
39
40 def __init__(self, filesystem=None, executive=None):
41 self.checkout_root = "/mock-checkout"
42 self.added_paths = set()
43 self._filesystem = filesystem or MockFileSystem()
44 self._executive = executive or MockExecutive()
45 self._local_commits = []
46
47 def add_all(self, pathspec=None):
48 if not pathspec:
49 pathspec = self.checkout_root
50 for path in self._filesystem.glob(pathspec):
51 self.add_list(self._filesystem.files_under(path))
52
53 def add(self, destination_path, return_exit_code=False):
54 self.add_list([destination_path], return_exit_code)
55
56 def add_list(self, destination_paths, return_exit_code=False):
57 self.added_paths.update(set(destination_paths))
58 if return_exit_code:
59 return 0
60
61 def has_working_directory_changes(self, pathspec=None):
62 return False
63
64 def ensure_cleanly_tracking_remote_master(self):
65 pass
66
67 def current_branch(self):
68 return "mock-branch-name"
69
70 def current_branch_or_ref(self):
71 return "mock-branch-name"
72
73 def checkout_branch(self, name):
74 pass
75
76 def create_clean_branch(self, name):
77 pass
78
79 def delete_branch(self, name):
80 pass
81
82 def supports_local_commits(self):
83 return True
84
85 def exists(self, path):
86 # TestRealMain.test_real_main (and several other rebaseline tests) are s ensitive to this return value.
87 # We should make those tests more robust, but for now we just return Tru e always (since no test needs otherwise).
88 return True
89
90 def absolute_path(self, *comps):
91 return self._filesystem.join(self.checkout_root, *comps)
92
93 def commit_position(self, path):
94 return 5678
95
96 def commit_position_from_git_commit(self, git_commit):
97 if git_commit == '6469e754a1':
98 return 1234
99 if git_commit == '624c3081c0':
100 return 5678
101 if git_commit == '624caaaaaa':
102 return 10000
103 return None
104
105 def timestamp_of_revision(self, path, revision):
106 return '2013-02-01 08:48:05 +0000'
107
108 def commit_locally_with_message(self, message):
109 self._local_commits.append([message])
110
111 def local_commits(self):
112 """For testing purposes, returns the internal recording of commits made via commit_locally_with_message.
113 Format as [ message, commit_all_working_directory_changes, author ].
114 """
115 return self._local_commits
116
117 def delete(self, path):
118 return self.delete_list([path])
119
120 def delete_list(self, paths):
121 if not self._filesystem:
122 return
123 for path in paths:
124 if self._filesystem.exists(path):
125 self._filesystem.remove(path)
126
127 def move(self, origin, destination):
128 if self._filesystem:
129 self._filesystem.move(self.absolute_path(origin), self.absolute_path (destination))
130
131 def changed_files(self):
132 return []
133
134 def unstaged_changes(self):
135 return {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698