Show More
@@ -1,748 +1,748 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2010-2016 RhodeCode GmbH |
|
3 | # Copyright (C) 2010-2016 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | import textwrap |
|
21 | import textwrap | |
22 |
|
22 | |||
23 | import pytest |
|
23 | import pytest | |
24 |
|
24 | |||
25 | from rhodecode.lib.diffs import ( |
|
25 | from rhodecode.lib.diffs import ( | |
26 | DiffProcessor, wrapped_diff, |
|
26 | DiffProcessor, wrapped_diff, | |
27 | NEW_FILENODE, DEL_FILENODE, MOD_FILENODE, RENAMED_FILENODE, |
|
27 | NEW_FILENODE, DEL_FILENODE, MOD_FILENODE, RENAMED_FILENODE, | |
28 | CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE) |
|
28 | CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE) | |
29 | from rhodecode.tests.fixture import Fixture |
|
29 | from rhodecode.tests.fixture import Fixture | |
30 | from rhodecode.lib.vcs.backends.git.repository import GitDiff |
|
30 | from rhodecode.lib.vcs.backends.git.repository import GitDiff | |
31 | from rhodecode.lib.vcs.backends.hg.repository import MercurialDiff |
|
31 | from rhodecode.lib.vcs.backends.hg.repository import MercurialDiff | |
32 | from rhodecode.lib.vcs.backends.svn.repository import SubversionDiff |
|
32 | from rhodecode.lib.vcs.backends.svn.repository import SubversionDiff | |
33 |
|
33 | |||
34 | fixture = Fixture() |
|
34 | fixture = Fixture() | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | def test_wrapped_diff_limited_file_diff(vcsbackend_random): |
|
37 | def test_wrapped_diff_limited_file_diff(vcsbackend_random): | |
38 | vcsbackend = vcsbackend_random |
|
38 | vcsbackend = vcsbackend_random | |
39 | repo = vcsbackend.create_repo() |
|
39 | repo = vcsbackend.create_repo() | |
40 | vcsbackend.add_file(repo, 'a_file', content="line 1\nline 2\nline3\n") |
|
40 | vcsbackend.add_file(repo, 'a_file', content="line 1\nline 2\nline3\n") | |
41 | commit = repo.get_commit() |
|
41 | commit = repo.get_commit() | |
42 | file_node = commit.get_node('a_file') |
|
42 | file_node = commit.get_node('a_file') | |
43 |
|
43 | |||
44 | # Only limit the file diff to trigger the code path |
|
44 | # Only limit the file diff to trigger the code path | |
45 | result = wrapped_diff( |
|
45 | result = wrapped_diff( | |
46 | None, file_node, diff_limit=10000, file_limit=1) |
|
46 | None, file_node, diff_limit=10000, file_limit=1) | |
47 | data = result[5] |
|
47 | data = result[5] | |
48 |
|
48 | |||
49 | # Verify that the limits were applied |
|
49 | # Verify that the limits were applied | |
50 | assert data['exceeds_limit'] is True |
|
50 | assert data['exceeds_limit'] is True | |
51 | assert data['is_limited_diff'] is True |
|
51 | assert data['is_limited_diff'] is True | |
52 |
|
52 | |||
53 |
|
53 | |||
54 | def test_diffprocessor_as_html_with_comments(): |
|
54 | def test_diffprocessor_as_html_with_comments(): | |
55 | raw_diff = textwrap.dedent(''' |
|
55 | raw_diff = textwrap.dedent(''' | |
56 | diff --git a/setup.py b/setup.py |
|
56 | diff --git a/setup.py b/setup.py | |
57 | index 5b36422..cfd698e 100755 |
|
57 | index 5b36422..cfd698e 100755 | |
58 | --- a/setup.py |
|
58 | --- a/setup.py | |
59 | +++ b/setup.py |
|
59 | +++ b/setup.py | |
60 | @@ -2,7 +2,7 @@ |
|
60 | @@ -2,7 +2,7 @@ | |
61 | #!/usr/bin/python |
|
61 | #!/usr/bin/python | |
62 | # Setup file for X |
|
62 | # Setup file for X | |
63 | # Copyright (C) No one |
|
63 | # Copyright (C) No one | |
64 | - |
|
64 | - | |
65 | +x |
|
65 | +x | |
66 | try: |
|
66 | try: | |
67 | from setuptools import setup, Extension |
|
67 | from setuptools import setup, Extension | |
68 | except ImportError: |
|
68 | except ImportError: | |
69 | ''') |
|
69 | ''') | |
70 | diff = GitDiff(raw_diff) |
|
70 | diff = GitDiff(raw_diff) | |
71 | processor = DiffProcessor(diff) |
|
71 | processor = DiffProcessor(diff) | |
72 | processor.prepare() |
|
72 | processor.prepare() | |
73 |
|
73 | |||
74 | # Note that the cell with the context in line 5 (in the html) has the |
|
74 | # Note that the cell with the context in line 5 (in the html) has the | |
75 | # no-comment class, which will prevent the add comment icon to be displayed. |
|
75 | # no-comment class, which will prevent the add comment icon to be displayed. | |
76 | expected_html = textwrap.dedent(''' |
|
76 | expected_html = textwrap.dedent(''' | |
77 | <table class="code-difftable"> |
|
77 | <table class="code-difftable"> | |
78 | <tr class="line context"> |
|
78 | <tr class="line context"> | |
79 | <td class="add-comment-line"><span class="add-comment-content"></span></td> |
|
79 | <td class="add-comment-line"><span class="add-comment-content"></span></td><td class="comment-toggle tooltip" title="Toggle Comments"><i class="icon-comment"></i></td> | |
80 | <td class="lineno old">...</td> |
|
80 | <td class="lineno old">...</td> | |
81 | <td class="lineno new">...</td> |
|
81 | <td class="lineno new">...</td> | |
82 | <td class="code no-comment"> |
|
82 | <td class="code no-comment"> | |
83 | <pre>@@ -2,7 +2,7 @@ |
|
83 | <pre>@@ -2,7 +2,7 @@ | |
84 | </pre> |
|
84 | </pre> | |
85 | </td> |
|
85 | </td> | |
86 | </tr> |
|
86 | </tr> | |
87 | <tr class="line unmod"> |
|
87 | <tr class="line unmod"> | |
88 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td> |
|
88 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td><td class="comment-toggle tooltip" title="Toggle Comments"><i class="icon-comment"></i></td> | |
89 | <td id="setuppy_o2" class="lineno old"><a href="#setuppy_o2" class="tooltip" |
|
89 | <td id="setuppy_o2" class="lineno old"><a href="#setuppy_o2" class="tooltip" | |
90 | title="Click to select line">2</a></td> |
|
90 | title="Click to select line">2</a></td> | |
91 | <td id="setuppy_n2" class="lineno new"><a href="#setuppy_n2" class="tooltip" |
|
91 | <td id="setuppy_n2" class="lineno new"><a href="#setuppy_n2" class="tooltip" | |
92 | title="Click to select line">2</a></td> |
|
92 | title="Click to select line">2</a></td> | |
93 | <td class="code"> |
|
93 | <td class="code"> | |
94 | <pre>#!/usr/bin/python |
|
94 | <pre>#!/usr/bin/python | |
95 | </pre> |
|
95 | </pre> | |
96 | </td> |
|
96 | </td> | |
97 | </tr> |
|
97 | </tr> | |
98 | <tr class="line unmod"> |
|
98 | <tr class="line unmod"> | |
99 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td> |
|
99 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td><td class="comment-toggle tooltip" title="Toggle Comments"><i class="icon-comment"></i></td> | |
100 | <td id="setuppy_o3" class="lineno old"><a href="#setuppy_o3" class="tooltip" |
|
100 | <td id="setuppy_o3" class="lineno old"><a href="#setuppy_o3" class="tooltip" | |
101 | title="Click to select line">3</a></td> |
|
101 | title="Click to select line">3</a></td> | |
102 | <td id="setuppy_n3" class="lineno new"><a href="#setuppy_n3" class="tooltip" |
|
102 | <td id="setuppy_n3" class="lineno new"><a href="#setuppy_n3" class="tooltip" | |
103 | title="Click to select line">3</a></td> |
|
103 | title="Click to select line">3</a></td> | |
104 | <td class="code"> |
|
104 | <td class="code"> | |
105 | <pre># Setup file for X |
|
105 | <pre># Setup file for X | |
106 | </pre> |
|
106 | </pre> | |
107 | </td> |
|
107 | </td> | |
108 | </tr> |
|
108 | </tr> | |
109 | <tr class="line unmod"> |
|
109 | <tr class="line unmod"> | |
110 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td> |
|
110 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td><td class="comment-toggle tooltip" title="Toggle Comments"><i class="icon-comment"></i></td> | |
111 | <td id="setuppy_o4" class="lineno old"><a href="#setuppy_o4" class="tooltip" |
|
111 | <td id="setuppy_o4" class="lineno old"><a href="#setuppy_o4" class="tooltip" | |
112 | title="Click to select line">4</a></td> |
|
112 | title="Click to select line">4</a></td> | |
113 | <td id="setuppy_n4" class="lineno new"><a href="#setuppy_n4" class="tooltip" |
|
113 | <td id="setuppy_n4" class="lineno new"><a href="#setuppy_n4" class="tooltip" | |
114 | title="Click to select line">4</a></td> |
|
114 | title="Click to select line">4</a></td> | |
115 | <td class="code"> |
|
115 | <td class="code"> | |
116 | <pre># Copyright (C) No one |
|
116 | <pre># Copyright (C) No one | |
117 | </pre> |
|
117 | </pre> | |
118 | </td> |
|
118 | </td> | |
119 | </tr> |
|
119 | </tr> | |
120 | <tr class="line del"> |
|
120 | <tr class="line del"> | |
121 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td> |
|
121 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td><td class="comment-toggle tooltip" title="Toggle Comments"><i class="icon-comment"></i></td> | |
122 | <td id="setuppy_o5" class="lineno old"><a href="#setuppy_o5" class="tooltip" |
|
122 | <td id="setuppy_o5" class="lineno old"><a href="#setuppy_o5" class="tooltip" | |
123 | title="Click to select line">5</a></td> |
|
123 | title="Click to select line">5</a></td> | |
124 | <td class="lineno new"><a href="#setuppy_n" class="tooltip" |
|
124 | <td class="lineno new"><a href="#setuppy_n" class="tooltip" | |
125 | title="Click to select line"></a></td> |
|
125 | title="Click to select line"></a></td> | |
126 | <td class="code"> |
|
126 | <td class="code"> | |
127 | <pre> |
|
127 | <pre> | |
128 | </pre> |
|
128 | </pre> | |
129 | </td> |
|
129 | </td> | |
130 | </tr> |
|
130 | </tr> | |
131 | <tr class="line add"> |
|
131 | <tr class="line add"> | |
132 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td> |
|
132 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td><td class="comment-toggle tooltip" title="Toggle Comments"><i class="icon-comment"></i></td> | |
133 | <td class="lineno old"><a href="#setuppy_o" class="tooltip" |
|
133 | <td class="lineno old"><a href="#setuppy_o" class="tooltip" | |
134 | title="Click to select line"></a></td> |
|
134 | title="Click to select line"></a></td> | |
135 | <td id="setuppy_n5" class="lineno new"><a href="#setuppy_n5" class="tooltip" |
|
135 | <td id="setuppy_n5" class="lineno new"><a href="#setuppy_n5" class="tooltip" | |
136 | title="Click to select line">5</a></td> |
|
136 | title="Click to select line">5</a></td> | |
137 | <td class="code"> |
|
137 | <td class="code"> | |
138 | <pre><ins>x</ins> |
|
138 | <pre><ins>x</ins> | |
139 | </pre> |
|
139 | </pre> | |
140 | </td> |
|
140 | </td> | |
141 | </tr> |
|
141 | </tr> | |
142 | <tr class="line unmod"> |
|
142 | <tr class="line unmod"> | |
143 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td> |
|
143 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td><td class="comment-toggle tooltip" title="Toggle Comments"><i class="icon-comment"></i></td> | |
144 | <td id="setuppy_o6" class="lineno old"><a href="#setuppy_o6" class="tooltip" |
|
144 | <td id="setuppy_o6" class="lineno old"><a href="#setuppy_o6" class="tooltip" | |
145 | title="Click to select line">6</a></td> |
|
145 | title="Click to select line">6</a></td> | |
146 | <td id="setuppy_n6" class="lineno new"><a href="#setuppy_n6" class="tooltip" |
|
146 | <td id="setuppy_n6" class="lineno new"><a href="#setuppy_n6" class="tooltip" | |
147 | title="Click to select line">6</a></td> |
|
147 | title="Click to select line">6</a></td> | |
148 | <td class="code"> |
|
148 | <td class="code"> | |
149 | <pre>try: |
|
149 | <pre>try: | |
150 | </pre> |
|
150 | </pre> | |
151 | </td> |
|
151 | </td> | |
152 | </tr> |
|
152 | </tr> | |
153 | <tr class="line unmod"> |
|
153 | <tr class="line unmod"> | |
154 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td> |
|
154 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td><td class="comment-toggle tooltip" title="Toggle Comments"><i class="icon-comment"></i></td> | |
155 | <td id="setuppy_o7" class="lineno old"><a href="#setuppy_o7" class="tooltip" |
|
155 | <td id="setuppy_o7" class="lineno old"><a href="#setuppy_o7" class="tooltip" | |
156 | title="Click to select line">7</a></td> |
|
156 | title="Click to select line">7</a></td> | |
157 | <td id="setuppy_n7" class="lineno new"><a href="#setuppy_n7" class="tooltip" |
|
157 | <td id="setuppy_n7" class="lineno new"><a href="#setuppy_n7" class="tooltip" | |
158 | title="Click to select line">7</a></td> |
|
158 | title="Click to select line">7</a></td> | |
159 | <td class="code"> |
|
159 | <td class="code"> | |
160 | <pre> from setuptools import setup, Extension |
|
160 | <pre> from setuptools import setup, Extension | |
161 | </pre> |
|
161 | </pre> | |
162 | </td> |
|
162 | </td> | |
163 | </tr> |
|
163 | </tr> | |
164 | <tr class="line unmod"> |
|
164 | <tr class="line unmod"> | |
165 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td> |
|
165 | <td class="add-comment-line"><span class="add-comment-content"><a href="#"><span class="icon-comment-add"></span></a></span></td><td class="comment-toggle tooltip" title="Toggle Comments"><i class="icon-comment"></i></td> | |
166 | <td id="setuppy_o8" class="lineno old"><a href="#setuppy_o8" class="tooltip" |
|
166 | <td id="setuppy_o8" class="lineno old"><a href="#setuppy_o8" class="tooltip" | |
167 | title="Click to select line">8</a></td> |
|
167 | title="Click to select line">8</a></td> | |
168 | <td id="setuppy_n8" class="lineno new"><a href="#setuppy_n8" class="tooltip" |
|
168 | <td id="setuppy_n8" class="lineno new"><a href="#setuppy_n8" class="tooltip" | |
169 | title="Click to select line">8</a></td> |
|
169 | title="Click to select line">8</a></td> | |
170 | <td class="code"> |
|
170 | <td class="code"> | |
171 | <pre>except ImportError: |
|
171 | <pre>except ImportError: | |
172 | </pre> |
|
172 | </pre> | |
173 | </td> |
|
173 | </td> | |
174 | </tr> |
|
174 | </tr> | |
175 | </table> |
|
175 | </table> | |
176 | ''').strip() |
|
176 | ''').strip() | |
177 | html = processor.as_html(enable_comments=True).replace('\t', ' ') |
|
177 | html = processor.as_html(enable_comments=True).replace('\t', ' ') | |
178 |
|
178 | |||
179 | assert html == expected_html |
|
179 | assert html == expected_html | |
180 |
|
180 | |||
181 |
|
181 | |||
182 | class TestMixedFilenameEncodings: |
|
182 | class TestMixedFilenameEncodings: | |
183 |
|
183 | |||
184 | @pytest.fixture(scope="class") |
|
184 | @pytest.fixture(scope="class") | |
185 | def raw_diff(self): |
|
185 | def raw_diff(self): | |
186 | return fixture.load_resource( |
|
186 | return fixture.load_resource( | |
187 | 'hg_diff_mixed_filename_encodings.diff') |
|
187 | 'hg_diff_mixed_filename_encodings.diff') | |
188 |
|
188 | |||
189 | @pytest.fixture |
|
189 | @pytest.fixture | |
190 | def processor(self, raw_diff): |
|
190 | def processor(self, raw_diff): | |
191 | diff = MercurialDiff(raw_diff) |
|
191 | diff = MercurialDiff(raw_diff) | |
192 | processor = DiffProcessor(diff) |
|
192 | processor = DiffProcessor(diff) | |
193 | return processor |
|
193 | return processor | |
194 |
|
194 | |||
195 | def test_filenames_are_decoded_to_unicode(self, processor): |
|
195 | def test_filenames_are_decoded_to_unicode(self, processor): | |
196 | diff_data = processor.prepare() |
|
196 | diff_data = processor.prepare() | |
197 | filenames = [item['filename'] for item in diff_data] |
|
197 | filenames = [item['filename'] for item in diff_data] | |
198 | assert filenames == [ |
|
198 | assert filenames == [ | |
199 | u'spΓ€cial-utf8.txt', u'spοΏ½cial-cp1252.txt', u'spοΏ½cial-latin1.txt'] |
|
199 | u'spΓ€cial-utf8.txt', u'spοΏ½cial-cp1252.txt', u'spοΏ½cial-latin1.txt'] | |
200 |
|
200 | |||
201 | def test_raw_diff_is_decoded_to_unicode(self, processor): |
|
201 | def test_raw_diff_is_decoded_to_unicode(self, processor): | |
202 | diff_data = processor.prepare() |
|
202 | diff_data = processor.prepare() | |
203 | raw_diffs = [item['raw_diff'] for item in diff_data] |
|
203 | raw_diffs = [item['raw_diff'] for item in diff_data] | |
204 | new_file_message = u'\nnew file mode 100644\n' |
|
204 | new_file_message = u'\nnew file mode 100644\n' | |
205 | expected_raw_diffs = [ |
|
205 | expected_raw_diffs = [ | |
206 | u' a/spΓ€cial-utf8.txt b/spΓ€cial-utf8.txt' + new_file_message, |
|
206 | u' a/spΓ€cial-utf8.txt b/spΓ€cial-utf8.txt' + new_file_message, | |
207 | u' a/spοΏ½cial-cp1252.txt b/spοΏ½cial-cp1252.txt' + new_file_message, |
|
207 | u' a/spοΏ½cial-cp1252.txt b/spοΏ½cial-cp1252.txt' + new_file_message, | |
208 | u' a/spοΏ½cial-latin1.txt b/spοΏ½cial-latin1.txt' + new_file_message] |
|
208 | u' a/spοΏ½cial-latin1.txt b/spοΏ½cial-latin1.txt' + new_file_message] | |
209 | assert raw_diffs == expected_raw_diffs |
|
209 | assert raw_diffs == expected_raw_diffs | |
210 |
|
210 | |||
211 | def test_as_raw_preserves_the_encoding(self, processor, raw_diff): |
|
211 | def test_as_raw_preserves_the_encoding(self, processor, raw_diff): | |
212 | assert processor.as_raw() == raw_diff |
|
212 | assert processor.as_raw() == raw_diff | |
213 |
|
213 | |||
214 |
|
214 | |||
215 | # TODO: mikhail: format the following data structure properly |
|
215 | # TODO: mikhail: format the following data structure properly | |
216 | DIFF_FIXTURES = [ |
|
216 | DIFF_FIXTURES = [ | |
217 | ('hg', |
|
217 | ('hg', | |
218 | 'hg_diff_add_single_binary_file.diff', |
|
218 | 'hg_diff_add_single_binary_file.diff', | |
219 | [('US Warszawa.jpg', 'A', |
|
219 | [('US Warszawa.jpg', 'A', | |
220 | {'added': 0, |
|
220 | {'added': 0, | |
221 | 'deleted': 0, |
|
221 | 'deleted': 0, | |
222 | 'binary': True, |
|
222 | 'binary': True, | |
223 | 'ops': {NEW_FILENODE: 'new file 100755', |
|
223 | 'ops': {NEW_FILENODE: 'new file 100755', | |
224 | BIN_FILENODE: 'binary diff hidden'}}), |
|
224 | BIN_FILENODE: 'binary diff hidden'}}), | |
225 | ]), |
|
225 | ]), | |
226 | ('hg', |
|
226 | ('hg', | |
227 | 'hg_diff_mod_single_binary_file.diff', |
|
227 | 'hg_diff_mod_single_binary_file.diff', | |
228 | [('US Warszawa.jpg', 'M', |
|
228 | [('US Warszawa.jpg', 'M', | |
229 | {'added': 0, |
|
229 | {'added': 0, | |
230 | 'deleted': 0, |
|
230 | 'deleted': 0, | |
231 | 'binary': True, |
|
231 | 'binary': True, | |
232 | 'ops': {MOD_FILENODE: 'modified file', |
|
232 | 'ops': {MOD_FILENODE: 'modified file', | |
233 | BIN_FILENODE: 'binary diff hidden'}}), |
|
233 | BIN_FILENODE: 'binary diff hidden'}}), | |
234 | ]), |
|
234 | ]), | |
235 | ('hg', |
|
235 | ('hg', | |
236 | 'hg_diff_mod_single_file_and_rename_and_chmod.diff', |
|
236 | 'hg_diff_mod_single_file_and_rename_and_chmod.diff', | |
237 | [('README', 'M', |
|
237 | [('README', 'M', | |
238 | {'added': 3, |
|
238 | {'added': 3, | |
239 | 'deleted': 0, |
|
239 | 'deleted': 0, | |
240 | 'binary': False, |
|
240 | 'binary': False, | |
241 | 'ops': {MOD_FILENODE: 'modified file', |
|
241 | 'ops': {MOD_FILENODE: 'modified file', | |
242 | RENAMED_FILENODE: 'file renamed from README.rst to README', |
|
242 | RENAMED_FILENODE: 'file renamed from README.rst to README', | |
243 | CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}), |
|
243 | CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}), | |
244 | ]), |
|
244 | ]), | |
245 | ('hg', |
|
245 | ('hg', | |
246 | 'hg_diff_mod_file_and_rename.diff', |
|
246 | 'hg_diff_mod_file_and_rename.diff', | |
247 | [('README.rst', 'M', |
|
247 | [('README.rst', 'M', | |
248 | {'added': 3, |
|
248 | {'added': 3, | |
249 | 'deleted': 0, |
|
249 | 'deleted': 0, | |
250 | 'binary': False, |
|
250 | 'binary': False, | |
251 | 'ops': {MOD_FILENODE: 'modified file', |
|
251 | 'ops': {MOD_FILENODE: 'modified file', | |
252 | RENAMED_FILENODE: 'file renamed from README to README.rst'}}), |
|
252 | RENAMED_FILENODE: 'file renamed from README to README.rst'}}), | |
253 | ]), |
|
253 | ]), | |
254 | ('hg', |
|
254 | ('hg', | |
255 | 'hg_diff_del_single_binary_file.diff', |
|
255 | 'hg_diff_del_single_binary_file.diff', | |
256 | [('US Warszawa.jpg', 'D', |
|
256 | [('US Warszawa.jpg', 'D', | |
257 | {'added': 0, |
|
257 | {'added': 0, | |
258 | 'deleted': 0, |
|
258 | 'deleted': 0, | |
259 | 'binary': True, |
|
259 | 'binary': True, | |
260 | 'ops': {DEL_FILENODE: 'deleted file', |
|
260 | 'ops': {DEL_FILENODE: 'deleted file', | |
261 | BIN_FILENODE: 'binary diff hidden'}}), |
|
261 | BIN_FILENODE: 'binary diff hidden'}}), | |
262 | ]), |
|
262 | ]), | |
263 | ('hg', |
|
263 | ('hg', | |
264 | 'hg_diff_chmod_and_mod_single_binary_file.diff', |
|
264 | 'hg_diff_chmod_and_mod_single_binary_file.diff', | |
265 | [('gravatar.png', 'M', |
|
265 | [('gravatar.png', 'M', | |
266 | {'added': 0, |
|
266 | {'added': 0, | |
267 | 'deleted': 0, |
|
267 | 'deleted': 0, | |
268 | 'binary': True, |
|
268 | 'binary': True, | |
269 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755', |
|
269 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755', | |
270 | BIN_FILENODE: 'binary diff hidden'}}), |
|
270 | BIN_FILENODE: 'binary diff hidden'}}), | |
271 | ]), |
|
271 | ]), | |
272 | ('hg', |
|
272 | ('hg', | |
273 | 'hg_diff_chmod.diff', |
|
273 | 'hg_diff_chmod.diff', | |
274 | [('file', 'M', |
|
274 | [('file', 'M', | |
275 | {'added': 0, |
|
275 | {'added': 0, | |
276 | 'deleted': 0, |
|
276 | 'deleted': 0, | |
277 | 'binary': True, |
|
277 | 'binary': True, | |
278 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}), |
|
278 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}), | |
279 | ]), |
|
279 | ]), | |
280 | ('hg', |
|
280 | ('hg', | |
281 | 'hg_diff_rename_file.diff', |
|
281 | 'hg_diff_rename_file.diff', | |
282 | [('file_renamed', 'M', |
|
282 | [('file_renamed', 'M', | |
283 | {'added': 0, |
|
283 | {'added': 0, | |
284 | 'deleted': 0, |
|
284 | 'deleted': 0, | |
285 | 'binary': True, |
|
285 | 'binary': True, | |
286 | 'ops': {RENAMED_FILENODE: 'file renamed from file to file_renamed'}}), |
|
286 | 'ops': {RENAMED_FILENODE: 'file renamed from file to file_renamed'}}), | |
287 | ]), |
|
287 | ]), | |
288 | ('hg', |
|
288 | ('hg', | |
289 | 'hg_diff_rename_and_chmod_file.diff', |
|
289 | 'hg_diff_rename_and_chmod_file.diff', | |
290 | [('README', 'M', |
|
290 | [('README', 'M', | |
291 | {'added': 0, |
|
291 | {'added': 0, | |
292 | 'deleted': 0, |
|
292 | 'deleted': 0, | |
293 | 'binary': True, |
|
293 | 'binary': True, | |
294 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755', |
|
294 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755', | |
295 | RENAMED_FILENODE: 'file renamed from README.rst to README'}}), |
|
295 | RENAMED_FILENODE: 'file renamed from README.rst to README'}}), | |
296 | ]), |
|
296 | ]), | |
297 | ('hg', |
|
297 | ('hg', | |
298 | 'hg_diff_binary_and_normal.diff', |
|
298 | 'hg_diff_binary_and_normal.diff', | |
299 | [('img/baseline-10px.png', 'A', |
|
299 | [('img/baseline-10px.png', 'A', | |
300 | {'added': 0, |
|
300 | {'added': 0, | |
301 | 'deleted': 0, |
|
301 | 'deleted': 0, | |
302 | 'binary': True, |
|
302 | 'binary': True, | |
303 | 'ops': {NEW_FILENODE: 'new file 100644', |
|
303 | 'ops': {NEW_FILENODE: 'new file 100644', | |
304 | BIN_FILENODE: 'binary diff hidden'}}), |
|
304 | BIN_FILENODE: 'binary diff hidden'}}), | |
305 | ('js/jquery/hashgrid.js', 'A', |
|
305 | ('js/jquery/hashgrid.js', 'A', | |
306 | {'added': 340, |
|
306 | {'added': 340, | |
307 | 'deleted': 0, |
|
307 | 'deleted': 0, | |
308 | 'binary': False, |
|
308 | 'binary': False, | |
309 | 'ops': {NEW_FILENODE: 'new file 100755'}}), |
|
309 | 'ops': {NEW_FILENODE: 'new file 100755'}}), | |
310 | ('index.html', 'M', |
|
310 | ('index.html', 'M', | |
311 | {'added': 3, |
|
311 | {'added': 3, | |
312 | 'deleted': 2, |
|
312 | 'deleted': 2, | |
313 | 'binary': False, |
|
313 | 'binary': False, | |
314 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
314 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
315 | ('less/docs.less', 'M', |
|
315 | ('less/docs.less', 'M', | |
316 | {'added': 34, |
|
316 | {'added': 34, | |
317 | 'deleted': 0, |
|
317 | 'deleted': 0, | |
318 | 'binary': False, |
|
318 | 'binary': False, | |
319 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
319 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
320 | ('less/scaffolding.less', 'M', |
|
320 | ('less/scaffolding.less', 'M', | |
321 | {'added': 1, |
|
321 | {'added': 1, | |
322 | 'deleted': 3, |
|
322 | 'deleted': 3, | |
323 | 'binary': False, |
|
323 | 'binary': False, | |
324 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
324 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
325 | ('readme.markdown', 'M', |
|
325 | ('readme.markdown', 'M', | |
326 | {'added': 1, |
|
326 | {'added': 1, | |
327 | 'deleted': 10, |
|
327 | 'deleted': 10, | |
328 | 'binary': False, |
|
328 | 'binary': False, | |
329 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
329 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
330 | ('img/baseline-20px.png', 'D', |
|
330 | ('img/baseline-20px.png', 'D', | |
331 | {'added': 0, |
|
331 | {'added': 0, | |
332 | 'deleted': 0, |
|
332 | 'deleted': 0, | |
333 | 'binary': True, |
|
333 | 'binary': True, | |
334 | 'ops': {DEL_FILENODE: 'deleted file', |
|
334 | 'ops': {DEL_FILENODE: 'deleted file', | |
335 | BIN_FILENODE: 'binary diff hidden'}}), |
|
335 | BIN_FILENODE: 'binary diff hidden'}}), | |
336 | ('js/global.js', 'D', |
|
336 | ('js/global.js', 'D', | |
337 | {'added': 0, |
|
337 | {'added': 0, | |
338 | 'deleted': 75, |
|
338 | 'deleted': 75, | |
339 | 'binary': False, |
|
339 | 'binary': False, | |
340 | 'ops': {DEL_FILENODE: 'deleted file'}}) |
|
340 | 'ops': {DEL_FILENODE: 'deleted file'}}) | |
341 | ]), |
|
341 | ]), | |
342 | ('git', |
|
342 | ('git', | |
343 | 'git_diff_chmod.diff', |
|
343 | 'git_diff_chmod.diff', | |
344 | [('work-horus.xls', 'M', |
|
344 | [('work-horus.xls', 'M', | |
345 | {'added': 0, |
|
345 | {'added': 0, | |
346 | 'deleted': 0, |
|
346 | 'deleted': 0, | |
347 | 'binary': True, |
|
347 | 'binary': True, | |
348 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}}) |
|
348 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}}) | |
349 | ]), |
|
349 | ]), | |
350 | ('git', |
|
350 | ('git', | |
351 | 'git_diff_rename_file.diff', |
|
351 | 'git_diff_rename_file.diff', | |
352 | [('file.xls', 'M', |
|
352 | [('file.xls', 'M', | |
353 | {'added': 0, |
|
353 | {'added': 0, | |
354 | 'deleted': 0, |
|
354 | 'deleted': 0, | |
355 | 'binary': True, |
|
355 | 'binary': True, | |
356 | 'ops': { |
|
356 | 'ops': { | |
357 | RENAMED_FILENODE: 'file renamed from work-horus.xls to file.xls'}}) |
|
357 | RENAMED_FILENODE: 'file renamed from work-horus.xls to file.xls'}}) | |
358 | ]), |
|
358 | ]), | |
359 | ('git', |
|
359 | ('git', | |
360 | 'git_diff_mod_single_binary_file.diff', |
|
360 | 'git_diff_mod_single_binary_file.diff', | |
361 | [('US Warszawa.jpg', 'M', |
|
361 | [('US Warszawa.jpg', 'M', | |
362 | {'added': 0, |
|
362 | {'added': 0, | |
363 | 'deleted': 0, |
|
363 | 'deleted': 0, | |
364 | 'binary': True, |
|
364 | 'binary': True, | |
365 | 'ops': {MOD_FILENODE: 'modified file', |
|
365 | 'ops': {MOD_FILENODE: 'modified file', | |
366 | BIN_FILENODE: 'binary diff hidden'}}) |
|
366 | BIN_FILENODE: 'binary diff hidden'}}) | |
367 | ]), |
|
367 | ]), | |
368 | ('git', |
|
368 | ('git', | |
369 | 'git_diff_binary_and_normal.diff', |
|
369 | 'git_diff_binary_and_normal.diff', | |
370 | [('img/baseline-10px.png', 'A', |
|
370 | [('img/baseline-10px.png', 'A', | |
371 | {'added': 0, |
|
371 | {'added': 0, | |
372 | 'deleted': 0, |
|
372 | 'deleted': 0, | |
373 | 'binary': True, |
|
373 | 'binary': True, | |
374 | 'ops': {NEW_FILENODE: 'new file 100644', |
|
374 | 'ops': {NEW_FILENODE: 'new file 100644', | |
375 | BIN_FILENODE: 'binary diff hidden'}}), |
|
375 | BIN_FILENODE: 'binary diff hidden'}}), | |
376 | ('js/jquery/hashgrid.js', 'A', |
|
376 | ('js/jquery/hashgrid.js', 'A', | |
377 | {'added': 340, |
|
377 | {'added': 340, | |
378 | 'deleted': 0, |
|
378 | 'deleted': 0, | |
379 | 'binary': False, |
|
379 | 'binary': False, | |
380 | 'ops': {NEW_FILENODE: 'new file 100755'}}), |
|
380 | 'ops': {NEW_FILENODE: 'new file 100755'}}), | |
381 | ('index.html', 'M', |
|
381 | ('index.html', 'M', | |
382 | {'added': 3, |
|
382 | {'added': 3, | |
383 | 'deleted': 2, |
|
383 | 'deleted': 2, | |
384 | 'binary': False, |
|
384 | 'binary': False, | |
385 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
385 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
386 | ('less/docs.less', 'M', |
|
386 | ('less/docs.less', 'M', | |
387 | {'added': 34, |
|
387 | {'added': 34, | |
388 | 'deleted': 0, |
|
388 | 'deleted': 0, | |
389 | 'binary': False, |
|
389 | 'binary': False, | |
390 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
390 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
391 | ('less/scaffolding.less', 'M', |
|
391 | ('less/scaffolding.less', 'M', | |
392 | {'added': 1, |
|
392 | {'added': 1, | |
393 | 'deleted': 3, |
|
393 | 'deleted': 3, | |
394 | 'binary': False, |
|
394 | 'binary': False, | |
395 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
395 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
396 | ('readme.markdown', 'M', |
|
396 | ('readme.markdown', 'M', | |
397 | {'added': 1, |
|
397 | {'added': 1, | |
398 | 'deleted': 10, |
|
398 | 'deleted': 10, | |
399 | 'binary': False, |
|
399 | 'binary': False, | |
400 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
400 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
401 | ('img/baseline-20px.png', 'D', |
|
401 | ('img/baseline-20px.png', 'D', | |
402 | {'added': 0, |
|
402 | {'added': 0, | |
403 | 'deleted': 0, |
|
403 | 'deleted': 0, | |
404 | 'binary': True, |
|
404 | 'binary': True, | |
405 | 'ops': {DEL_FILENODE: 'deleted file', |
|
405 | 'ops': {DEL_FILENODE: 'deleted file', | |
406 | BIN_FILENODE: 'binary diff hidden'}}), |
|
406 | BIN_FILENODE: 'binary diff hidden'}}), | |
407 | ('js/global.js', 'D', |
|
407 | ('js/global.js', 'D', | |
408 | {'added': 0, |
|
408 | {'added': 0, | |
409 | 'deleted': 75, |
|
409 | 'deleted': 75, | |
410 | 'binary': False, |
|
410 | 'binary': False, | |
411 | 'ops': {DEL_FILENODE: 'deleted file'}}), |
|
411 | 'ops': {DEL_FILENODE: 'deleted file'}}), | |
412 | ]), |
|
412 | ]), | |
413 | ('hg', |
|
413 | ('hg', | |
414 | 'diff_with_diff_data.diff', |
|
414 | 'diff_with_diff_data.diff', | |
415 | [('vcs/backends/base.py', 'M', |
|
415 | [('vcs/backends/base.py', 'M', | |
416 | {'added': 18, |
|
416 | {'added': 18, | |
417 | 'deleted': 2, |
|
417 | 'deleted': 2, | |
418 | 'binary': False, |
|
418 | 'binary': False, | |
419 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
419 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
420 | ('vcs/backends/git/repository.py', 'M', |
|
420 | ('vcs/backends/git/repository.py', 'M', | |
421 | {'added': 46, |
|
421 | {'added': 46, | |
422 | 'deleted': 15, |
|
422 | 'deleted': 15, | |
423 | 'binary': False, |
|
423 | 'binary': False, | |
424 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
424 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
425 | ('vcs/backends/hg.py', 'M', |
|
425 | ('vcs/backends/hg.py', 'M', | |
426 | {'added': 22, |
|
426 | {'added': 22, | |
427 | 'deleted': 3, |
|
427 | 'deleted': 3, | |
428 | 'binary': False, |
|
428 | 'binary': False, | |
429 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
429 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
430 | ('vcs/tests/test_git.py', 'M', |
|
430 | ('vcs/tests/test_git.py', 'M', | |
431 | {'added': 5, |
|
431 | {'added': 5, | |
432 | 'deleted': 5, |
|
432 | 'deleted': 5, | |
433 | 'binary': False, |
|
433 | 'binary': False, | |
434 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
434 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
435 | ('vcs/tests/test_repository.py', 'M', |
|
435 | ('vcs/tests/test_repository.py', 'M', | |
436 | {'added': 174, |
|
436 | {'added': 174, | |
437 | 'deleted': 2, |
|
437 | 'deleted': 2, | |
438 | 'binary': False, |
|
438 | 'binary': False, | |
439 | 'ops': {MOD_FILENODE: 'modified file'}}), |
|
439 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
440 | ]), |
|
440 | ]), | |
441 | ('hg', |
|
441 | ('hg', | |
442 | 'hg_diff_copy_file.diff', |
|
442 | 'hg_diff_copy_file.diff', | |
443 | [('file2', 'M', |
|
443 | [('file2', 'M', | |
444 | {'added': 0, |
|
444 | {'added': 0, | |
445 | 'deleted': 0, |
|
445 | 'deleted': 0, | |
446 | 'binary': True, |
|
446 | 'binary': True, | |
447 | 'ops': {COPIED_FILENODE: 'file copied from file1 to file2'}}), |
|
447 | 'ops': {COPIED_FILENODE: 'file copied from file1 to file2'}}), | |
448 | ]), |
|
448 | ]), | |
449 | ('hg', |
|
449 | ('hg', | |
450 | 'hg_diff_copy_and_modify_file.diff', |
|
450 | 'hg_diff_copy_and_modify_file.diff', | |
451 | [('file3', 'M', |
|
451 | [('file3', 'M', | |
452 | {'added': 1, |
|
452 | {'added': 1, | |
453 | 'deleted': 0, |
|
453 | 'deleted': 0, | |
454 | 'binary': False, |
|
454 | 'binary': False, | |
455 | 'ops': {COPIED_FILENODE: 'file copied from file2 to file3', |
|
455 | 'ops': {COPIED_FILENODE: 'file copied from file2 to file3', | |
456 | MOD_FILENODE: 'modified file'}}), |
|
456 | MOD_FILENODE: 'modified file'}}), | |
457 | ]), |
|
457 | ]), | |
458 | ('hg', |
|
458 | ('hg', | |
459 | 'hg_diff_copy_and_chmod_file.diff', |
|
459 | 'hg_diff_copy_and_chmod_file.diff', | |
460 | [('file4', 'M', |
|
460 | [('file4', 'M', | |
461 | {'added': 0, |
|
461 | {'added': 0, | |
462 | 'deleted': 0, |
|
462 | 'deleted': 0, | |
463 | 'binary': True, |
|
463 | 'binary': True, | |
464 | 'ops': {COPIED_FILENODE: 'file copied from file3 to file4', |
|
464 | 'ops': {COPIED_FILENODE: 'file copied from file3 to file4', | |
465 | CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}}), |
|
465 | CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}}), | |
466 | ]), |
|
466 | ]), | |
467 | ('hg', |
|
467 | ('hg', | |
468 | 'hg_diff_copy_chmod_and_edit_file.diff', |
|
468 | 'hg_diff_copy_chmod_and_edit_file.diff', | |
469 | [('file5', 'M', |
|
469 | [('file5', 'M', | |
470 | {'added': 2, |
|
470 | {'added': 2, | |
471 | 'deleted': 1, |
|
471 | 'deleted': 1, | |
472 | 'binary': False, |
|
472 | 'binary': False, | |
473 | 'ops': {COPIED_FILENODE: 'file copied from file4 to file5', |
|
473 | 'ops': {COPIED_FILENODE: 'file copied from file4 to file5', | |
474 | CHMOD_FILENODE: 'modified file chmod 100755 => 100644', |
|
474 | CHMOD_FILENODE: 'modified file chmod 100755 => 100644', | |
475 | MOD_FILENODE: 'modified file'}})]), |
|
475 | MOD_FILENODE: 'modified file'}})]), | |
476 |
|
476 | |||
477 | # Diffs to validate rename and copy file with space in its name |
|
477 | # Diffs to validate rename and copy file with space in its name | |
478 | ('git', |
|
478 | ('git', | |
479 | 'git_diff_rename_file_with_spaces.diff', |
|
479 | 'git_diff_rename_file_with_spaces.diff', | |
480 | [('file_with_ two spaces.txt', 'M', |
|
480 | [('file_with_ two spaces.txt', 'M', | |
481 | {'added': 0, |
|
481 | {'added': 0, | |
482 | 'deleted': 0, |
|
482 | 'deleted': 0, | |
483 | 'binary': True, |
|
483 | 'binary': True, | |
484 | 'ops': { |
|
484 | 'ops': { | |
485 | RENAMED_FILENODE: ( |
|
485 | RENAMED_FILENODE: ( | |
486 | 'file renamed from file_with_ spaces.txt to file_with_ ' |
|
486 | 'file renamed from file_with_ spaces.txt to file_with_ ' | |
487 | ' two spaces.txt')} |
|
487 | ' two spaces.txt')} | |
488 | }), ]), |
|
488 | }), ]), | |
489 | ('hg', |
|
489 | ('hg', | |
490 | 'hg_diff_rename_file_with_spaces.diff', |
|
490 | 'hg_diff_rename_file_with_spaces.diff', | |
491 | [('file_changed _.txt', 'M', |
|
491 | [('file_changed _.txt', 'M', | |
492 | {'added': 0, |
|
492 | {'added': 0, | |
493 | 'deleted': 0, |
|
493 | 'deleted': 0, | |
494 | 'binary': True, |
|
494 | 'binary': True, | |
495 | 'ops': { |
|
495 | 'ops': { | |
496 | RENAMED_FILENODE: ( |
|
496 | RENAMED_FILENODE: ( | |
497 | 'file renamed from file_ with update.txt to file_changed' |
|
497 | 'file renamed from file_ with update.txt to file_changed' | |
498 | ' _.txt')} |
|
498 | ' _.txt')} | |
499 | }), ]), |
|
499 | }), ]), | |
500 | ('hg', |
|
500 | ('hg', | |
501 | 'hg_diff_copy_file_with_spaces.diff', |
|
501 | 'hg_diff_copy_file_with_spaces.diff', | |
502 | [('file_copied_ with spaces.txt', 'M', |
|
502 | [('file_copied_ with spaces.txt', 'M', | |
503 | {'added': 0, |
|
503 | {'added': 0, | |
504 | 'deleted': 0, |
|
504 | 'deleted': 0, | |
505 | 'binary': True, |
|
505 | 'binary': True, | |
506 | 'ops': { |
|
506 | 'ops': { | |
507 | COPIED_FILENODE: ( |
|
507 | COPIED_FILENODE: ( | |
508 | 'file copied from file_changed_without_spaces.txt to' |
|
508 | 'file copied from file_changed_without_spaces.txt to' | |
509 | ' file_copied_ with spaces.txt')} |
|
509 | ' file_copied_ with spaces.txt')} | |
510 | }), |
|
510 | }), | |
511 | ]), |
|
511 | ]), | |
512 |
|
512 | |||
513 | # special signs from git |
|
513 | # special signs from git | |
514 | ('git', |
|
514 | ('git', | |
515 | 'git_diff_binary_special_files.diff', |
|
515 | 'git_diff_binary_special_files.diff', | |
516 | [('css/_Icon\\r', 'A', |
|
516 | [('css/_Icon\\r', 'A', | |
517 | {'added': 0, |
|
517 | {'added': 0, | |
518 | 'deleted': 0, |
|
518 | 'deleted': 0, | |
519 | 'binary': True, |
|
519 | 'binary': True, | |
520 | 'ops': {NEW_FILENODE: 'new file 100644', |
|
520 | 'ops': {NEW_FILENODE: 'new file 100644', | |
521 | BIN_FILENODE: 'binary diff hidden'} |
|
521 | BIN_FILENODE: 'binary diff hidden'} | |
522 | }), |
|
522 | }), | |
523 | ]), |
|
523 | ]), | |
524 | ('git', |
|
524 | ('git', | |
525 | 'git_diff_binary_special_files_2.diff', |
|
525 | 'git_diff_binary_special_files_2.diff', | |
526 | [('css/Icon\\r', 'A', |
|
526 | [('css/Icon\\r', 'A', | |
527 | {'added': 0, |
|
527 | {'added': 0, | |
528 | 'deleted': 0, |
|
528 | 'deleted': 0, | |
529 | 'binary': True, |
|
529 | 'binary': True, | |
530 | 'ops': {NEW_FILENODE: 'new file 100644', } |
|
530 | 'ops': {NEW_FILENODE: 'new file 100644', } | |
531 | }), |
|
531 | }), | |
532 | ]), |
|
532 | ]), | |
533 |
|
533 | |||
534 | # TODO: mikhail: do we still need this? |
|
534 | # TODO: mikhail: do we still need this? | |
535 | # ( |
|
535 | # ( | |
536 | # 'hg', |
|
536 | # 'hg', | |
537 | # 'large_diff.diff', |
|
537 | # 'large_diff.diff', | |
538 | # [ |
|
538 | # [ | |
539 | # ('.hgignore', 'A', { |
|
539 | # ('.hgignore', 'A', { | |
540 | # 'deleted': 0, 'binary': False, 'added': 3, 'ops': { |
|
540 | # 'deleted': 0, 'binary': False, 'added': 3, 'ops': { | |
541 | # 1: 'new file 100644'}}), |
|
541 | # 1: 'new file 100644'}}), | |
542 | # ( |
|
542 | # ( | |
543 | # 'MANIFEST.in', 'A', |
|
543 | # 'MANIFEST.in', 'A', | |
544 | # {'deleted': 0, 'binary': False, 'added': 3, 'ops': { |
|
544 | # {'deleted': 0, 'binary': False, 'added': 3, 'ops': { | |
545 | # 1: 'new file 100644'}}), |
|
545 | # 1: 'new file 100644'}}), | |
546 | # ( |
|
546 | # ( | |
547 | # 'README.txt', 'A', |
|
547 | # 'README.txt', 'A', | |
548 | # {'deleted': 0, 'binary': False, 'added': 19, 'ops': { |
|
548 | # {'deleted': 0, 'binary': False, 'added': 19, 'ops': { | |
549 | # 1: 'new file 100644'}}), |
|
549 | # 1: 'new file 100644'}}), | |
550 | # ( |
|
550 | # ( | |
551 | # 'development.ini', 'A', { |
|
551 | # 'development.ini', 'A', { | |
552 | # 'deleted': 0, 'binary': False, 'added': 116, 'ops': { |
|
552 | # 'deleted': 0, 'binary': False, 'added': 116, 'ops': { | |
553 | # 1: 'new file 100644'}}), |
|
553 | # 1: 'new file 100644'}}), | |
554 | # ( |
|
554 | # ( | |
555 | # 'docs/index.txt', 'A', { |
|
555 | # 'docs/index.txt', 'A', { | |
556 | # 'deleted': 0, 'binary': False, 'added': 19, 'ops': { |
|
556 | # 'deleted': 0, 'binary': False, 'added': 19, 'ops': { | |
557 | # 1: 'new file 100644'}}), |
|
557 | # 1: 'new file 100644'}}), | |
558 | # ( |
|
558 | # ( | |
559 | # 'ez_setup.py', 'A', { |
|
559 | # 'ez_setup.py', 'A', { | |
560 | # 'deleted': 0, 'binary': False, 'added': 276, 'ops': { |
|
560 | # 'deleted': 0, 'binary': False, 'added': 276, 'ops': { | |
561 | # 1: 'new file 100644'}}), |
|
561 | # 1: 'new file 100644'}}), | |
562 | # ( |
|
562 | # ( | |
563 | # 'hgapp.py', 'A', { |
|
563 | # 'hgapp.py', 'A', { | |
564 | # 'deleted': 0, 'binary': False, 'added': 26, 'ops': { |
|
564 | # 'deleted': 0, 'binary': False, 'added': 26, 'ops': { | |
565 | # 1: 'new file 100644'}}), |
|
565 | # 1: 'new file 100644'}}), | |
566 | # ( |
|
566 | # ( | |
567 | # 'hgwebdir.config', 'A', { |
|
567 | # 'hgwebdir.config', 'A', { | |
568 | # 'deleted': 0, 'binary': False, 'added': 21, 'ops': { |
|
568 | # 'deleted': 0, 'binary': False, 'added': 21, 'ops': { | |
569 | # 1: 'new file 100644'}}), |
|
569 | # 1: 'new file 100644'}}), | |
570 | # ( |
|
570 | # ( | |
571 | # 'pylons_app.egg-info/PKG-INFO', 'A', { |
|
571 | # 'pylons_app.egg-info/PKG-INFO', 'A', { | |
572 | # 'deleted': 0, 'binary': False, 'added': 10, 'ops': { |
|
572 | # 'deleted': 0, 'binary': False, 'added': 10, 'ops': { | |
573 | # 1: 'new file 100644'}}), |
|
573 | # 1: 'new file 100644'}}), | |
574 | # ( |
|
574 | # ( | |
575 | # 'pylons_app.egg-info/SOURCES.txt', 'A', { |
|
575 | # 'pylons_app.egg-info/SOURCES.txt', 'A', { | |
576 | # 'deleted': 0, 'binary': False, 'added': 33, 'ops': { |
|
576 | # 'deleted': 0, 'binary': False, 'added': 33, 'ops': { | |
577 | # 1: 'new file 100644'}}), |
|
577 | # 1: 'new file 100644'}}), | |
578 | # ( |
|
578 | # ( | |
579 | # 'pylons_app.egg-info/dependency_links.txt', 'A', { |
|
579 | # 'pylons_app.egg-info/dependency_links.txt', 'A', { | |
580 | # 'deleted': 0, 'binary': False, 'added': 1, 'ops': { |
|
580 | # 'deleted': 0, 'binary': False, 'added': 1, 'ops': { | |
581 | # 1: 'new file 100644'}}), |
|
581 | # 1: 'new file 100644'}}), | |
582 | # #TODO: |
|
582 | # #TODO: | |
583 | # ] |
|
583 | # ] | |
584 | # ), |
|
584 | # ), | |
585 | ] |
|
585 | ] | |
586 |
|
586 | |||
587 | DIFF_FIXTURES_WITH_CONTENT = [ |
|
587 | DIFF_FIXTURES_WITH_CONTENT = [ | |
588 | ( |
|
588 | ( | |
589 | 'hg', 'hg_diff_single_file_change_newline.diff', |
|
589 | 'hg', 'hg_diff_single_file_change_newline.diff', | |
590 | [ |
|
590 | [ | |
591 | ( |
|
591 | ( | |
592 | 'file_b', # filename |
|
592 | 'file_b', # filename | |
593 | 'A', # change |
|
593 | 'A', # change | |
594 | { # stats |
|
594 | { # stats | |
595 | 'added': 1, |
|
595 | 'added': 1, | |
596 | 'deleted': 0, |
|
596 | 'deleted': 0, | |
597 | 'binary': False, |
|
597 | 'binary': False, | |
598 | 'ops': {NEW_FILENODE: 'new file 100644', } |
|
598 | 'ops': {NEW_FILENODE: 'new file 100644', } | |
599 | }, |
|
599 | }, | |
600 | '@@ -0,0 +1 @@\n+test_content b\n' # diff |
|
600 | '@@ -0,0 +1 @@\n+test_content b\n' # diff | |
601 | ), |
|
601 | ), | |
602 | ], |
|
602 | ], | |
603 | ), |
|
603 | ), | |
604 | ( |
|
604 | ( | |
605 | 'hg', 'hg_diff_double_file_change_newline.diff', |
|
605 | 'hg', 'hg_diff_double_file_change_newline.diff', | |
606 | [ |
|
606 | [ | |
607 | ( |
|
607 | ( | |
608 | 'file_b', # filename |
|
608 | 'file_b', # filename | |
609 | 'A', # change |
|
609 | 'A', # change | |
610 | { # stats |
|
610 | { # stats | |
611 | 'added': 1, |
|
611 | 'added': 1, | |
612 | 'deleted': 0, |
|
612 | 'deleted': 0, | |
613 | 'binary': False, |
|
613 | 'binary': False, | |
614 | 'ops': {NEW_FILENODE: 'new file 100644', } |
|
614 | 'ops': {NEW_FILENODE: 'new file 100644', } | |
615 | }, |
|
615 | }, | |
616 | '@@ -0,0 +1 @@\n+test_content b\n' # diff |
|
616 | '@@ -0,0 +1 @@\n+test_content b\n' # diff | |
617 | ), |
|
617 | ), | |
618 | ( |
|
618 | ( | |
619 | 'file_c', # filename |
|
619 | 'file_c', # filename | |
620 | 'A', # change |
|
620 | 'A', # change | |
621 | { # stats |
|
621 | { # stats | |
622 | 'added': 1, |
|
622 | 'added': 1, | |
623 | 'deleted': 0, |
|
623 | 'deleted': 0, | |
624 | 'binary': False, |
|
624 | 'binary': False, | |
625 | 'ops': {NEW_FILENODE: 'new file 100644', } |
|
625 | 'ops': {NEW_FILENODE: 'new file 100644', } | |
626 | }, |
|
626 | }, | |
627 | '@@ -0,0 +1 @@\n+test_content c\n' # diff |
|
627 | '@@ -0,0 +1 @@\n+test_content c\n' # diff | |
628 | ), |
|
628 | ), | |
629 | ], |
|
629 | ], | |
630 | ), |
|
630 | ), | |
631 | ( |
|
631 | ( | |
632 | 'hg', 'hg_diff_double_file_change_double_newline.diff', |
|
632 | 'hg', 'hg_diff_double_file_change_double_newline.diff', | |
633 | [ |
|
633 | [ | |
634 | ( |
|
634 | ( | |
635 | 'file_b', # filename |
|
635 | 'file_b', # filename | |
636 | 'A', # change |
|
636 | 'A', # change | |
637 | { # stats |
|
637 | { # stats | |
638 | 'added': 1, |
|
638 | 'added': 1, | |
639 | 'deleted': 0, |
|
639 | 'deleted': 0, | |
640 | 'binary': False, |
|
640 | 'binary': False, | |
641 | 'ops': {NEW_FILENODE: 'new file 100644', } |
|
641 | 'ops': {NEW_FILENODE: 'new file 100644', } | |
642 | }, |
|
642 | }, | |
643 | '@@ -0,0 +1 @@\n+test_content b\n\n' # diff |
|
643 | '@@ -0,0 +1 @@\n+test_content b\n\n' # diff | |
644 | ), |
|
644 | ), | |
645 | ( |
|
645 | ( | |
646 | 'file_c', # filename |
|
646 | 'file_c', # filename | |
647 | 'A', # change |
|
647 | 'A', # change | |
648 | { # stats |
|
648 | { # stats | |
649 | 'added': 1, |
|
649 | 'added': 1, | |
650 | 'deleted': 0, |
|
650 | 'deleted': 0, | |
651 | 'binary': False, |
|
651 | 'binary': False, | |
652 | 'ops': {NEW_FILENODE: 'new file 100644', } |
|
652 | 'ops': {NEW_FILENODE: 'new file 100644', } | |
653 | }, |
|
653 | }, | |
654 | '@@ -0,0 +1 @@\n+test_content c\n' # diff |
|
654 | '@@ -0,0 +1 @@\n+test_content c\n' # diff | |
655 | ), |
|
655 | ), | |
656 | ], |
|
656 | ], | |
657 | ), |
|
657 | ), | |
658 | ( |
|
658 | ( | |
659 | 'hg', 'hg_diff_four_file_change_newline.diff', |
|
659 | 'hg', 'hg_diff_four_file_change_newline.diff', | |
660 | [ |
|
660 | [ | |
661 | ( |
|
661 | ( | |
662 | 'file', # filename |
|
662 | 'file', # filename | |
663 | 'A', # change |
|
663 | 'A', # change | |
664 | { # stats |
|
664 | { # stats | |
665 | 'added': 1, |
|
665 | 'added': 1, | |
666 | 'deleted': 0, |
|
666 | 'deleted': 0, | |
667 | 'binary': False, |
|
667 | 'binary': False, | |
668 | 'ops': {NEW_FILENODE: 'new file 100644', } |
|
668 | 'ops': {NEW_FILENODE: 'new file 100644', } | |
669 | }, |
|
669 | }, | |
670 | '@@ -0,0 +1,1 @@\n+file\n' # diff |
|
670 | '@@ -0,0 +1,1 @@\n+file\n' # diff | |
671 | ), |
|
671 | ), | |
672 | ( |
|
672 | ( | |
673 | 'file2', # filename |
|
673 | 'file2', # filename | |
674 | 'A', # change |
|
674 | 'A', # change | |
675 | { # stats |
|
675 | { # stats | |
676 | 'added': 1, |
|
676 | 'added': 1, | |
677 | 'deleted': 0, |
|
677 | 'deleted': 0, | |
678 | 'binary': False, |
|
678 | 'binary': False, | |
679 | 'ops': {NEW_FILENODE: 'new file 100644', } |
|
679 | 'ops': {NEW_FILENODE: 'new file 100644', } | |
680 | }, |
|
680 | }, | |
681 | '@@ -0,0 +1,1 @@\n+another line\n' # diff |
|
681 | '@@ -0,0 +1,1 @@\n+another line\n' # diff | |
682 | ), |
|
682 | ), | |
683 | ( |
|
683 | ( | |
684 | 'file3', # filename |
|
684 | 'file3', # filename | |
685 | 'A', # change |
|
685 | 'A', # change | |
686 | { # stats |
|
686 | { # stats | |
687 | 'added': 1, |
|
687 | 'added': 1, | |
688 | 'deleted': 0, |
|
688 | 'deleted': 0, | |
689 | 'binary': False, |
|
689 | 'binary': False, | |
690 | 'ops': {NEW_FILENODE: 'new file 100644', } |
|
690 | 'ops': {NEW_FILENODE: 'new file 100644', } | |
691 | }, |
|
691 | }, | |
692 | '@@ -0,0 +1,1 @@\n+newline\n' # diff |
|
692 | '@@ -0,0 +1,1 @@\n+newline\n' # diff | |
693 | ), |
|
693 | ), | |
694 | ( |
|
694 | ( | |
695 | 'file4', # filename |
|
695 | 'file4', # filename | |
696 | 'A', # change |
|
696 | 'A', # change | |
697 | { # stats |
|
697 | { # stats | |
698 | 'added': 1, |
|
698 | 'added': 1, | |
699 | 'deleted': 0, |
|
699 | 'deleted': 0, | |
700 | 'binary': False, |
|
700 | 'binary': False, | |
701 | 'ops': {NEW_FILENODE: 'new file 100644', } |
|
701 | 'ops': {NEW_FILENODE: 'new file 100644', } | |
702 | }, |
|
702 | }, | |
703 | '@@ -0,0 +1,1 @@\n+fil4\n\\ No newline at end of file' # diff |
|
703 | '@@ -0,0 +1,1 @@\n+fil4\n\\ No newline at end of file' # diff | |
704 | ), |
|
704 | ), | |
705 | ], |
|
705 | ], | |
706 | ), |
|
706 | ), | |
707 |
|
707 | |||
708 | ] |
|
708 | ] | |
709 |
|
709 | |||
710 |
|
710 | |||
711 | diff_class = { |
|
711 | diff_class = { | |
712 | 'git': GitDiff, |
|
712 | 'git': GitDiff, | |
713 | 'hg': MercurialDiff, |
|
713 | 'hg': MercurialDiff, | |
714 | 'svn': SubversionDiff, |
|
714 | 'svn': SubversionDiff, | |
715 | } |
|
715 | } | |
716 |
|
716 | |||
717 |
|
717 | |||
718 | @pytest.fixture(params=DIFF_FIXTURES) |
|
718 | @pytest.fixture(params=DIFF_FIXTURES) | |
719 | def diff_fixture(request): |
|
719 | def diff_fixture(request): | |
720 | vcs, diff_fixture, expected = request.param |
|
720 | vcs, diff_fixture, expected = request.param | |
721 | diff_txt = fixture.load_resource(diff_fixture) |
|
721 | diff_txt = fixture.load_resource(diff_fixture) | |
722 | diff = diff_class[vcs](diff_txt) |
|
722 | diff = diff_class[vcs](diff_txt) | |
723 | return diff, expected |
|
723 | return diff, expected | |
724 |
|
724 | |||
725 |
|
725 | |||
726 | def test_diff_lib(diff_fixture): |
|
726 | def test_diff_lib(diff_fixture): | |
727 | diff, expected_data = diff_fixture |
|
727 | diff, expected_data = diff_fixture | |
728 | diff_proc = DiffProcessor(diff) |
|
728 | diff_proc = DiffProcessor(diff) | |
729 | diff_proc_d = diff_proc.prepare() |
|
729 | diff_proc_d = diff_proc.prepare() | |
730 | data = [(x['filename'], x['operation'], x['stats']) for x in diff_proc_d] |
|
730 | data = [(x['filename'], x['operation'], x['stats']) for x in diff_proc_d] | |
731 | assert expected_data == data |
|
731 | assert expected_data == data | |
732 |
|
732 | |||
733 |
|
733 | |||
734 | @pytest.fixture(params=DIFF_FIXTURES_WITH_CONTENT) |
|
734 | @pytest.fixture(params=DIFF_FIXTURES_WITH_CONTENT) | |
735 | def diff_fixture_w_content(request): |
|
735 | def diff_fixture_w_content(request): | |
736 | vcs, diff_fixture, expected = request.param |
|
736 | vcs, diff_fixture, expected = request.param | |
737 | diff_txt = fixture.load_resource(diff_fixture) |
|
737 | diff_txt = fixture.load_resource(diff_fixture) | |
738 | diff = diff_class[vcs](diff_txt) |
|
738 | diff = diff_class[vcs](diff_txt) | |
739 | return diff, expected |
|
739 | return diff, expected | |
740 |
|
740 | |||
741 |
|
741 | |||
742 | def test_diff_lib_newlines(diff_fixture_w_content): |
|
742 | def test_diff_lib_newlines(diff_fixture_w_content): | |
743 | diff, expected_data = diff_fixture_w_content |
|
743 | diff, expected_data = diff_fixture_w_content | |
744 | diff_proc = DiffProcessor(diff) |
|
744 | diff_proc = DiffProcessor(diff) | |
745 | diff_proc_d = diff_proc.prepare() |
|
745 | diff_proc_d = diff_proc.prepare() | |
746 | data = [(x['filename'], x['operation'], x['stats'], x['raw_diff']) |
|
746 | data = [(x['filename'], x['operation'], x['stats'], x['raw_diff']) | |
747 | for x in diff_proc_d] |
|
747 | for x in diff_proc_d] | |
748 | assert expected_data == data |
|
748 | assert expected_data == data |
General Comments 0
You need to be logged in to leave comments.
Login now