OLD | NEW |
1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
11 # in the documentation and/or other materials provided with the | 11 # in the documentation and/or other materials provided with the |
12 # distribution. | 12 # distribution. |
13 # * Neither the name of Google Inc. nor the names of its | 13 # * Neither the name of Google Inc. nor the names of its |
14 # contributors may be used to endorse or promote products derived from | 14 # contributors may be used to endorse or promote products derived from |
15 # this software without specific prior written permission. | 15 # this software without specific prior written permission. |
16 # | 16 # |
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 from .commitinfo import CommitInfo | |
30 | |
31 # FIXME: These imports are wrong, we should use a shared MockCommittersList. | |
32 from webkitpy.common.config.committers import CommitterList | |
33 from webkitpy.common.net.bugzilla.bugzilla_mock import _mock_reviewers | |
34 from webkitpy.common.system.filesystem_mock import MockFileSystem | 29 from webkitpy.common.system.filesystem_mock import MockFileSystem |
35 | 30 |
36 | 31 |
37 class MockCommitMessage(object): | 32 class MockCommitMessage(object): |
38 def message(self): | 33 def message(self): |
39 return "This is a fake commit message that is at least 50 characters." | 34 return "This is a fake commit message that is at least 50 characters." |
40 | 35 |
41 | 36 |
42 committer_list = CommitterList() | |
43 | |
44 mock_revisions = { | |
45 1: CommitInfo(852, "eric@webkit.org", { | |
46 "bug_id": 50000, | |
47 "author_name": "Adam Barth", | |
48 "author_email": "abarth@webkit.org", | |
49 "author": committer_list.contributor_by_email("abarth@webkit.org"), | |
50 "reviewer_text": "Darin Adler", | |
51 "reviewer": committer_list.committer_by_name("Darin Adler"), | |
52 "changed_files": [ | |
53 "path/to/file", | |
54 "another/file", | |
55 ], | |
56 }), | |
57 3001: CommitInfo(3001, "tomz@codeaurora.org", { | |
58 "bug_id": 50004, | |
59 "author_name": "Tom Zakrajsek", | |
60 "author_email": "tomz@codeaurora.org", | |
61 "author": committer_list.contributor_by_email("tomz@codeaurora.org"), | |
62 "reviewer_text": "Darin Adler", | |
63 "reviewer": committer_list.committer_by_name("Darin Adler"), | |
64 "changed_files": [ | |
65 "path/to/file", | |
66 "another/file", | |
67 ], | |
68 }) | |
69 } | |
70 | |
71 class MockCheckout(object): | 37 class MockCheckout(object): |
72 def __init__(self): | 38 def __init__(self): |
73 # FIXME: It's unclear if a MockCheckout is very useful. A normal Checko
ut | 39 # FIXME: It's unclear if a MockCheckout is very useful. A normal Checko
ut |
74 # with a MockSCM/MockFileSystem/MockExecutive is probably better. | 40 # with a MockSCM/MockFileSystem/MockExecutive is probably better. |
75 self._filesystem = MockFileSystem() | 41 self._filesystem = MockFileSystem() |
76 | 42 |
77 def commit_info_for_revision(self, svn_revision): | |
78 # There are legacy tests that all expected these revision numbers to map | |
79 # to the same commit description (now mock_revisions[1]) | |
80 if svn_revision in [32, 123, 852, 853, 854, 1234, 21654, 21655, 21656]: | |
81 return mock_revisions[1] | |
82 | |
83 if svn_revision in mock_revisions: | |
84 return mock_revisions[svn_revision] | |
85 | |
86 # any "unrecognized" svn_revision will return None. | |
87 | |
88 def is_path_to_changelog(self, path): | 43 def is_path_to_changelog(self, path): |
89 return self._filesystem.basename(path) == "ChangeLog" | 44 return self._filesystem.basename(path) == "ChangeLog" |
90 | 45 |
91 def recent_commit_infos_for_files(self, paths): | 46 def recent_commit_infos_for_files(self, paths): |
92 return [self.commit_info_for_revision(32)] | 47 return [self.commit_info_for_revision(32)] |
93 | 48 |
94 def modified_changelogs(self, git_commit, changed_files=None): | 49 def modified_changelogs(self, git_commit, changed_files=None): |
95 # Ideally we'd return something more interesting here. The problem is | 50 # Ideally we'd return something more interesting here. The problem is |
96 # that LandDiff will try to actually read the patch from disk! | 51 # that LandDiff will try to actually read the patch from disk! |
97 return [] | 52 return [] |
98 | 53 |
99 def commit_message_for_this_commit(self, git_commit, changed_files=None): | 54 def commit_message_for_this_commit(self, git_commit, changed_files=None): |
100 return MockCommitMessage() | 55 return MockCommitMessage() |
101 | 56 |
102 def apply_patch(self, patch): | 57 def apply_patch(self, patch): |
103 pass | 58 pass |
104 | 59 |
105 def apply_reverse_diffs(self, revision): | 60 def apply_reverse_diffs(self, revision): |
106 pass | 61 pass |
OLD | NEW |