OLD | NEW |
1 # Copyright (c) 2010 Google Inc. All rights reserved. | 1 # Copyright (c) 2010 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 |
(...skipping 11 matching lines...) Expand all Loading... |
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 import StringIO | 29 import StringIO |
30 | 30 |
31 from webkitpy.common.config import urls | 31 from webkitpy.common.config import urls |
32 from webkitpy.common.checkout.commitinfo import CommitInfo | |
33 from webkitpy.common.checkout.scm import CommitMessage | 32 from webkitpy.common.checkout.scm import CommitMessage |
34 from webkitpy.common.checkout.deps import DEPS | 33 from webkitpy.common.checkout.deps import DEPS |
35 from webkitpy.common.memoized import memoized | 34 from webkitpy.common.memoized import memoized |
36 from webkitpy.common.system.executive import ScriptError | 35 from webkitpy.common.system.executive import ScriptError |
37 | 36 |
38 | 37 |
39 # This class represents the WebKit-specific parts of the checkout. | 38 # This class represents the WebKit-specific parts of the checkout. |
40 # FIXME: Move a bunch of ChangeLog-specific processing from SCM to this object. | |
41 # NOTE: All paths returned from this class should be absolute. | 39 # NOTE: All paths returned from this class should be absolute. |
42 class Checkout(object): | 40 class Checkout(object): |
43 def __init__(self, scm, executive=None, filesystem=None): | 41 def __init__(self, scm, executive=None, filesystem=None): |
44 self._scm = scm | 42 self._scm = scm |
45 # FIXME: We shouldn't be grabbing at private members on scm. | 43 # FIXME: We shouldn't be grabbing at private members on scm. |
46 self._executive = executive or self._scm._executive | 44 self._executive = executive or self._scm._executive |
47 self._filesystem = filesystem or self._scm._filesystem | 45 self._filesystem = filesystem or self._scm._filesystem |
48 | 46 |
49 def is_path_to_changelog(self, path): | |
50 return False | |
51 | |
52 @memoized | |
53 def commit_info_for_revision(self, revision): | |
54 return None | |
55 | |
56 def _modified_files_matching_predicate(self, git_commit, predicate, changed_
files=None): | 47 def _modified_files_matching_predicate(self, git_commit, predicate, changed_
files=None): |
57 # SCM returns paths relative to scm.checkout_root | 48 # SCM returns paths relative to scm.checkout_root |
58 # Callers may expect absolute paths, so this method returns absolute | 49 # Callers (especially those using the ChangeLog class) may |
59 # paths. | 50 # expect absolute paths, so this method returns absolute paths. |
60 if not changed_files: | 51 if not changed_files: |
61 changed_files = self._scm.changed_files(git_commit) | 52 changed_files = self._scm.changed_files(git_commit) |
62 return filter(predicate, map(self._scm.absolute_path, changed_files)) | 53 return filter(predicate, map(self._scm.absolute_path, changed_files)) |
63 | 54 |
64 def modified_changelogs(self, git_commit, changed_files=None): | |
65 return [] | |
66 | |
67 def modified_non_changelogs(self, git_commit, changed_files=None): | |
68 return self._modified_files_matching_predicate(git_commit, lambda path:
not self.is_path_to_changelog(path), changed_files=changed_files) | |
69 | |
70 def commit_message_for_this_commit(self, git_commit, changed_files=None, ret
urn_stderr=False): | |
71 # FIXME: Delete this and callers. | |
72 raise ScriptError(message="Found no modified ChangeLogs, cannot create a
commit message.\n" | |
73 "All changes require a ChangeLog. See:\n %s" % urls.c
ontribution_guidelines) | |
74 | |
75 def recent_commit_infos_for_files(self, paths): | 55 def recent_commit_infos_for_files(self, paths): |
76 revisions = set(sum(map(self._scm.revisions_changing_file, paths), [])) | 56 revisions = set(sum(map(self._scm.revisions_changing_file, paths), [])) |
77 return set(map(self.commit_info_for_revision, revisions)) | 57 return set(map(self.commit_info_for_revision, revisions)) |
78 | 58 |
79 def apply_patch(self, patch): | 59 def apply_patch(self, patch): |
80 # It's possible that the patch was not made from the root directory. | 60 # It's possible that the patch was not made from the root directory. |
81 # We should detect and handle that case. | 61 # We should detect and handle that case. |
82 # FIXME: Move _scm.script_path here once we get rid of all the dependenc
ies. | 62 # FIXME: Move _scm.script_path here once we get rid of all the dependenc
ies. |
83 # --force (continue after errors) is the common case, so we always use i
t. | 63 # --force (continue after errors) is the common case, so we always use i
t. |
84 args = [self._scm.script_path('svn-apply'), "--force"] | 64 args = [self._scm.script_path('svn-apply'), "--force"] |
85 if patch.reviewer(): | 65 if patch.reviewer(): |
86 args += ['--reviewer', patch.reviewer().full_name] | 66 args += ['--reviewer', patch.reviewer().full_name] |
87 self._executive.run_command(args, input=patch.contents(), cwd=self._scm.
checkout_root) | 67 self._executive.run_command(args, input=patch.contents(), cwd=self._scm.
checkout_root) |
88 | 68 |
89 def apply_reverse_diff(self, revision): | 69 def apply_reverse_diff(self, revision): |
90 self._scm.apply_reverse_diff(revision) | 70 self._scm.apply_reverse_diff(revision) |
91 | 71 |
92 conflicts = self._scm.conflicted_files() | 72 conflicts = self._scm.conflicted_files() |
93 if len(conflicts): | 73 if len(conflicts): |
94 raise ScriptError(message="Failed to apply reverse diff for revision
%s because of the following conflicts:\n%s" % (revision, "\n".join(conflicts))) | 74 raise ScriptError(message="Failed to apply reverse diff for revision
%s because of the following conflicts:\n%s" % (revision, "\n".join(conflicts))) |
95 | 75 |
96 def apply_reverse_diffs(self, revision_list): | 76 def apply_reverse_diffs(self, revision_list): |
97 for revision in sorted(revision_list, reverse=True): | 77 for revision in sorted(revision_list, reverse=True): |
98 self.apply_reverse_diff(revision) | 78 self.apply_reverse_diff(revision) |
OLD | NEW |