Show More
@@ -94,6 +94,7 b' class TestCompareView(object):' | |||
|
94 | 94 | origin_repo = origin.scm_instance(cache=False) |
|
95 | 95 | origin_repo.config.clear_section('hooks') |
|
96 | 96 | origin_repo.pull(fork.repo_full_path, commit_ids=[commit3.raw_id]) |
|
97 | origin_repo = origin.scm_instance(cache=False) # cache rebuild | |
|
97 | 98 | |
|
98 | 99 | # Verify test fixture setup |
|
99 | 100 | # This does not work for git |
@@ -162,8 +163,7 b' class TestCompareView(object):' | |||
|
162 | 163 | compare_page.target_source_are_disabled() |
|
163 | 164 | |
|
164 | 165 | @pytest.mark.xfail_backends("svn", reason="Depends on branch support") |
|
165 | def test_compare_forks_on_branch_extra_commits_origin_has_incomming( | |
|
166 | self, backend): | |
|
166 | def test_compare_forks_on_branch_extra_commits_origin_has_incomming(self, backend): | |
|
167 | 167 | repo1 = backend.create_repo() |
|
168 | 168 | |
|
169 | 169 | # commit something ! |
@@ -21,6 +21,7 b'' | |||
|
21 | 21 | import pytest |
|
22 | 22 | |
|
23 | 23 | from rhodecode.lib.vcs import nodes |
|
24 | from rhodecode.lib.vcs.backends.base import EmptyCommit | |
|
24 | 25 | from rhodecode.tests.fixture import Fixture |
|
25 | 26 | from rhodecode.tests.utils import commit_change |
|
26 | 27 | |
@@ -43,70 +44,7 b' def route_path(name, params=None, **kwar' | |||
|
43 | 44 | @pytest.mark.usefixtures("autologin_user", "app") |
|
44 | 45 | class TestSideBySideDiff(object): |
|
45 | 46 | |
|
46 |
def test_diff_side |
|
|
47 | f_path = 'test_sidebyside_file.py' | |
|
48 | commit1_content = 'content-25d7e49c18b159446c\n' | |
|
49 | commit2_content = 'content-603d6c72c46d953420\n' | |
|
50 | repo = backend.create_repo() | |
|
51 | ||
|
52 | commit1 = commit_change( | |
|
53 | repo.repo_name, filename=f_path, content=commit1_content, | |
|
54 | message='A', vcs_type=backend.alias, parent=None, newfile=True) | |
|
55 | ||
|
56 | commit2 = commit_change( | |
|
57 | repo.repo_name, filename=f_path, content=commit2_content, | |
|
58 | message='B, child of A', vcs_type=backend.alias, parent=commit1) | |
|
59 | ||
|
60 | response = self.app.get(route_path( | |
|
61 | 'repo_compare', | |
|
62 | repo_name=repo.repo_name, | |
|
63 | source_ref_type='rev', | |
|
64 | source_ref=commit1.raw_id, | |
|
65 | target_ref_type='rev', | |
|
66 | target_ref=commit2.raw_id, | |
|
67 | params=dict(f_path=f_path, target_repo=repo.repo_name, diffmode='sidebyside') | |
|
68 | )) | |
|
69 | ||
|
70 | response.mustcontain('Expand 1 commit') | |
|
71 | response.mustcontain('1 file changed') | |
|
72 | ||
|
73 | response.mustcontain( | |
|
74 | 'r%s:%s...r%s:%s' % ( | |
|
75 | commit1.idx, commit1.short_id, commit2.idx, commit2.short_id)) | |
|
76 | ||
|
77 | response.mustcontain('<strong>{}</strong>'.format(f_path)) | |
|
78 | ||
|
79 | def test_diff_side_by_side_with_empty_file(self, app, backend, backend_stub): | |
|
80 | commits = [ | |
|
81 | {'message': 'First commit'}, | |
|
82 | {'message': 'Commit with binary', | |
|
83 | 'added': [nodes.FileNode('file.empty', content='')]}, | |
|
84 | ] | |
|
85 | f_path = 'file.empty' | |
|
86 | repo = backend.create_repo(commits=commits) | |
|
87 | commit1 = repo.get_commit(commit_idx=0) | |
|
88 | commit2 = repo.get_commit(commit_idx=1) | |
|
89 | ||
|
90 | response = self.app.get(route_path( | |
|
91 | 'repo_compare', | |
|
92 | repo_name=repo.repo_name, | |
|
93 | source_ref_type='rev', | |
|
94 | source_ref=commit1.raw_id, | |
|
95 | target_ref_type='rev', | |
|
96 | target_ref=commit2.raw_id, | |
|
97 | params=dict(f_path=f_path, target_repo=repo.repo_name, diffmode='sidebyside') | |
|
98 | )) | |
|
99 | ||
|
100 | response.mustcontain('Expand 1 commit') | |
|
101 | response.mustcontain('1 file changed') | |
|
102 | ||
|
103 | response.mustcontain( | |
|
104 | 'r%s:%s...r%s:%s' % ( | |
|
105 | commit1.idx, commit1.short_id, commit2.idx, commit2.short_id)) | |
|
106 | ||
|
107 | response.mustcontain('<strong>{}</strong>'.format(f_path)) | |
|
108 | ||
|
109 | def test_diff_sidebyside_two_commits(self, app, backend): | |
|
47 | def test_diff_sidebyside_single_commit(self, app, backend): | |
|
110 | 48 | commit_id_range = { |
|
111 | 49 | 'hg': { |
|
112 | 50 | 'commits': ['25d7e49c18b159446cadfa506a5cf8ad1cb04067', |
@@ -141,26 +79,164 b' class TestSideBySideDiff(object):' | |||
|
141 | 79 | params=dict(target_repo=backend.repo_name, diffmode='sidebyside') |
|
142 | 80 | )) |
|
143 | 81 | |
|
82 | response.mustcontain(file_changes) | |
|
144 | 83 | response.mustcontain('Expand 1 commit') |
|
145 | response.mustcontain(file_changes) | |
|
146 | 84 | |
|
147 |
def test_diff_sidebyside_two_commits |
|
|
85 | def test_diff_sidebyside_two_commits(self, app, backend): | |
|
148 | 86 | commit_id_range = { |
|
149 | 87 | 'hg': { |
|
150 | 'commits': ['25d7e49c18b159446cadfa506a5cf8ad1cb04067', | |
|
88 | 'commits': ['4fdd71e9427417b2e904e0464c634fdee85ec5a7', | |
|
151 | 89 | '603d6c72c46d953420c89d36372f08d9f305f5dd'], |
|
152 |
'changes': ' |
|
|
90 | 'changes': '32 files changed: 1165 inserted, 308 deleted' | |
|
153 | 91 | }, |
|
154 | 92 | 'git': { |
|
155 | 'commits': ['6fc9270775aaf5544c1deb014f4ddd60c952fcbb', | |
|
93 | 'commits': ['f5fbf9cfd5f1f1be146f6d3b38bcd791a7480c13', | |
|
156 | 94 | '03fa803d7e9fb14daa9a3089e0d1494eda75d986'], |
|
157 |
'changes': ' |
|
|
95 | 'changes': '32 files changed: 1165 inserted, 308 deleted' | |
|
158 | 96 | }, |
|
159 | 97 | |
|
160 | 98 | 'svn': { |
|
161 |
'commits': ['33 |
|
|
99 | 'commits': ['335', | |
|
162 | 100 | '337'], |
|
163 |
'changes': ' |
|
|
101 | 'changes': '32 files changed: 1179 inserted, 310 deleted' | |
|
102 | }, | |
|
103 | } | |
|
104 | ||
|
105 | commit_info = commit_id_range[backend.alias] | |
|
106 | commit2, commit1 = commit_info['commits'] | |
|
107 | file_changes = commit_info['changes'] | |
|
108 | ||
|
109 | response = self.app.get(route_path( | |
|
110 | 'repo_compare', | |
|
111 | repo_name=backend.repo_name, | |
|
112 | source_ref_type='rev', | |
|
113 | source_ref=commit2, | |
|
114 | target_repo=backend.repo_name, | |
|
115 | target_ref_type='rev', | |
|
116 | target_ref=commit1, | |
|
117 | params=dict(target_repo=backend.repo_name, diffmode='sidebyside') | |
|
118 | )) | |
|
119 | ||
|
120 | response.mustcontain(file_changes) | |
|
121 | response.mustcontain('Expand 2 commits') | |
|
122 | ||
|
123 | @pytest.mark.xfail(reason='GIT does not handle empty commit compare correct (missing 1 commit)') | |
|
124 | def test_diff_side_by_side_from_0_commit(self, app, backend, backend_stub): | |
|
125 | f_path = 'test_sidebyside_file.py' | |
|
126 | commit1_content = 'content-25d7e49c18b159446c\n' | |
|
127 | commit2_content = 'content-603d6c72c46d953420\n' | |
|
128 | repo = backend.create_repo() | |
|
129 | ||
|
130 | commit1 = commit_change( | |
|
131 | repo.repo_name, filename=f_path, content=commit1_content, | |
|
132 | message='A', vcs_type=backend.alias, parent=None, newfile=True) | |
|
133 | ||
|
134 | commit2 = commit_change( | |
|
135 | repo.repo_name, filename=f_path, content=commit2_content, | |
|
136 | message='B, child of A', vcs_type=backend.alias, parent=commit1) | |
|
137 | ||
|
138 | response = self.app.get(route_path( | |
|
139 | 'repo_compare', | |
|
140 | repo_name=repo.repo_name, | |
|
141 | source_ref_type='rev', | |
|
142 | source_ref=EmptyCommit().raw_id, | |
|
143 | target_ref_type='rev', | |
|
144 | target_ref=commit2.raw_id, | |
|
145 | params=dict(diffmode='sidebyside') | |
|
146 | )) | |
|
147 | ||
|
148 | response.mustcontain('Expand 2 commits') | |
|
149 | response.mustcontain('123 file changed') | |
|
150 | ||
|
151 | response.mustcontain( | |
|
152 | 'r%s:%s...r%s:%s' % ( | |
|
153 | commit1.idx, commit1.short_id, commit2.idx, commit2.short_id)) | |
|
154 | ||
|
155 | response.mustcontain('<strong>{}</strong>'.format(f_path)) | |
|
156 | ||
|
157 | @pytest.mark.xfail(reason='GIT does not handle empty commit compare correct (missing 1 commit)') | |
|
158 | def test_diff_side_by_side_from_0_commit_with_file_filter(self, app, backend, backend_stub): | |
|
159 | f_path = 'test_sidebyside_file.py' | |
|
160 | commit1_content = 'content-25d7e49c18b159446c\n' | |
|
161 | commit2_content = 'content-603d6c72c46d953420\n' | |
|
162 | repo = backend.create_repo() | |
|
163 | ||
|
164 | commit1 = commit_change( | |
|
165 | repo.repo_name, filename=f_path, content=commit1_content, | |
|
166 | message='A', vcs_type=backend.alias, parent=None, newfile=True) | |
|
167 | ||
|
168 | commit2 = commit_change( | |
|
169 | repo.repo_name, filename=f_path, content=commit2_content, | |
|
170 | message='B, child of A', vcs_type=backend.alias, parent=commit1) | |
|
171 | ||
|
172 | response = self.app.get(route_path( | |
|
173 | 'repo_compare', | |
|
174 | repo_name=repo.repo_name, | |
|
175 | source_ref_type='rev', | |
|
176 | source_ref=EmptyCommit().raw_id, | |
|
177 | target_ref_type='rev', | |
|
178 | target_ref=commit2.raw_id, | |
|
179 | params=dict(f_path=f_path, target_repo=repo.repo_name, diffmode='sidebyside') | |
|
180 | )) | |
|
181 | ||
|
182 | response.mustcontain('Expand 2 commits') | |
|
183 | response.mustcontain('1 file changed') | |
|
184 | ||
|
185 | response.mustcontain( | |
|
186 | 'r%s:%s...r%s:%s' % ( | |
|
187 | commit1.idx, commit1.short_id, commit2.idx, commit2.short_id)) | |
|
188 | ||
|
189 | response.mustcontain('<strong>{}</strong>'.format(f_path)) | |
|
190 | ||
|
191 | def test_diff_side_by_side_with_empty_file(self, app, backend, backend_stub): | |
|
192 | commits = [ | |
|
193 | {'message': 'First commit'}, | |
|
194 | {'message': 'Second commit'}, | |
|
195 | {'message': 'Commit with binary', | |
|
196 | 'added': [nodes.FileNode('file.empty', content='')]}, | |
|
197 | ] | |
|
198 | f_path = 'file.empty' | |
|
199 | repo = backend.create_repo(commits=commits) | |
|
200 | commit1 = repo.get_commit(commit_idx=0) | |
|
201 | commit2 = repo.get_commit(commit_idx=1) | |
|
202 | commit3 = repo.get_commit(commit_idx=2) | |
|
203 | ||
|
204 | response = self.app.get(route_path( | |
|
205 | 'repo_compare', | |
|
206 | repo_name=repo.repo_name, | |
|
207 | source_ref_type='rev', | |
|
208 | source_ref=commit1.raw_id, | |
|
209 | target_ref_type='rev', | |
|
210 | target_ref=commit3.raw_id, | |
|
211 | params=dict(f_path=f_path, target_repo=repo.repo_name, diffmode='sidebyside') | |
|
212 | )) | |
|
213 | ||
|
214 | response.mustcontain('Expand 2 commits') | |
|
215 | response.mustcontain('1 file changed') | |
|
216 | ||
|
217 | response.mustcontain( | |
|
218 | 'r%s:%s...r%s:%s' % ( | |
|
219 | commit2.idx, commit2.short_id, commit3.idx, commit3.short_id)) | |
|
220 | ||
|
221 | response.mustcontain('<strong>{}</strong>'.format(f_path)) | |
|
222 | ||
|
223 | def test_diff_sidebyside_two_commits_with_file_filter(self, app, backend): | |
|
224 | commit_id_range = { | |
|
225 | 'hg': { | |
|
226 | 'commits': ['4fdd71e9427417b2e904e0464c634fdee85ec5a7', | |
|
227 | '603d6c72c46d953420c89d36372f08d9f305f5dd'], | |
|
228 | 'changes': '1 file changed: 3 inserted, 3 deleted' | |
|
229 | }, | |
|
230 | 'git': { | |
|
231 | 'commits': ['f5fbf9cfd5f1f1be146f6d3b38bcd791a7480c13', | |
|
232 | '03fa803d7e9fb14daa9a3089e0d1494eda75d986'], | |
|
233 | 'changes': '1 file changed: 3 inserted, 3 deleted' | |
|
234 | }, | |
|
235 | ||
|
236 | 'svn': { | |
|
237 | 'commits': ['335', | |
|
238 | '337'], | |
|
239 | 'changes': '1 file changed: 3 inserted, 3 deleted' | |
|
164 | 240 | }, |
|
165 | 241 | } |
|
166 | 242 | f_path = 'docs/conf.py' |
@@ -179,5 +255,5 b' class TestSideBySideDiff(object):' | |||
|
179 | 255 | params=dict(f_path=f_path, target_repo=backend.repo_name, diffmode='sidebyside') |
|
180 | 256 | )) |
|
181 | 257 | |
|
182 |
response.mustcontain('Expand |
|
|
258 | response.mustcontain('Expand 2 commits') | |
|
183 | 259 | response.mustcontain(file_changes) |
@@ -214,29 +214,23 b' class RepoCompareView(RepoAppView):' | |||
|
214 | 214 | pre_load = ["author", "branch", "date", "message"] |
|
215 | 215 | c.ancestor = None |
|
216 | 216 | |
|
217 | if c.file_path: | |
|
218 | if source_commit == target_commit: | |
|
219 | c.commit_ranges = [] | |
|
220 | else: | |
|
221 | c.commit_ranges = [source_commit, target_commit] | |
|
222 | else: | |
|
223 | try: | |
|
224 | c.commit_ranges = source_scm.compare( | |
|
225 | source_commit.raw_id, target_commit.raw_id, | |
|
226 | target_scm, merge, pre_load=pre_load) | |
|
227 | if merge: | |
|
228 | c.ancestor = source_scm.get_common_ancestor( | |
|
229 | source_commit.raw_id, target_commit.raw_id, target_scm) | |
|
230 | except RepositoryRequirementError: | |
|
231 | msg = _('Could not compare repos with different ' | |
|
232 | 'large file settings') | |
|
233 | log.error(msg) | |
|
234 | if partial: | |
|
235 | return Response(msg) | |
|
236 | h.flash(msg, category='error') | |
|
237 | raise HTTPFound( | |
|
238 | h.route_path('repo_compare_select', | |
|
239 | repo_name=self.db_repo_name)) | |
|
217 | try: | |
|
218 | c.commit_ranges = source_scm.compare( | |
|
219 | source_commit.raw_id, target_commit.raw_id, | |
|
220 | target_scm, merge, pre_load=pre_load) or [] | |
|
221 | if merge: | |
|
222 | c.ancestor = source_scm.get_common_ancestor( | |
|
223 | source_commit.raw_id, target_commit.raw_id, target_scm) | |
|
224 | except RepositoryRequirementError: | |
|
225 | msg = _('Could not compare repos with different ' | |
|
226 | 'large file settings') | |
|
227 | log.error(msg) | |
|
228 | if partial: | |
|
229 | return Response(msg) | |
|
230 | h.flash(msg, category='error') | |
|
231 | raise HTTPFound( | |
|
232 | h.route_path('repo_compare_select', | |
|
233 | repo_name=self.db_repo_name)) | |
|
240 | 234 | |
|
241 | 235 | c.statuses = self.db_repo.statuses( |
|
242 | 236 | [x.raw_id for x in c.commit_ranges]) |
@@ -55,6 +55,7 b' log = logging.getLogger(__name__)' | |||
|
55 | 55 | |
|
56 | 56 | FILEMODE_DEFAULT = 0o100644 |
|
57 | 57 | FILEMODE_EXECUTABLE = 0o100755 |
|
58 | EMPTY_COMMIT_ID = '0' * 40 | |
|
58 | 59 | |
|
59 | 60 | Reference = collections.namedtuple('Reference', ('type', 'name', 'commit_id')) |
|
60 | 61 | |
@@ -1569,7 +1570,7 b' class EmptyCommit(BaseCommit):' | |||
|
1569 | 1570 | """ |
|
1570 | 1571 | |
|
1571 | 1572 | def __init__( |
|
1572 |
self, commit_id= |
|
|
1573 | self, commit_id=EMPTY_COMMIT_ID, repo=None, alias=None, idx=-1, | |
|
1573 | 1574 | message='', author='', date=None): |
|
1574 | 1575 | self._empty_commit_id = commit_id |
|
1575 | 1576 | # TODO: johbo: Solve idx parameter, default value does not make |
@@ -1629,7 +1630,7 b' class EmptyChangeset(EmptyCommit):' | |||
|
1629 | 1630 | "Use EmptyCommit instead of EmptyChangeset", DeprecationWarning) |
|
1630 | 1631 | return super(EmptyCommit, cls).__new__(cls, *args, **kwargs) |
|
1631 | 1632 | |
|
1632 |
def __init__(self, cs= |
|
|
1633 | def __init__(self, cs=EMPTY_COMMIT_ID, repo=None, requested_revision=None, | |
|
1633 | 1634 | alias=None, revision=-1, message='', author='', date=None): |
|
1634 | 1635 | if requested_revision is not None: |
|
1635 | 1636 | warnings.warn( |
@@ -37,12 +37,12 b'' | |||
|
37 | 37 | <h4> |
|
38 | 38 | ${_('Compare Commits')} |
|
39 | 39 | % if c.file_path: |
|
40 | ${_('for file')} <a href="#${'a_' + h.FID('',c.file_path)}">${c.file_path}</a> | |
|
40 | ${_('for file')} <a href="#${('a_' + h.FID('',c.file_path))}">${c.file_path}</a> | |
|
41 | 41 | % endif |
|
42 | 42 | |
|
43 | 43 | % if c.commit_ranges: |
|
44 | 44 | <code> |
|
45 |
r${c. |
|
|
45 | r${c.commit_ranges[0].idx}:${h.short_id(c.commit_ranges[0].raw_id)}...r${c.commit_ranges[-1].idx}:${h.short_id(c.commit_ranges[-1].raw_id)} | |
|
46 | 46 | </code> |
|
47 | 47 | % endif |
|
48 | 48 | </h4> |
@@ -48,9 +48,9 b' log = logging.getLogger(__name__)' | |||
|
48 | 48 | |
|
49 | 49 | |
|
50 | 50 | class CustomTestResponse(TestResponse): |
|
51 | ||
|
51 | 52 | def _save_output(self, out): |
|
52 | f = tempfile.NamedTemporaryFile( | |
|
53 | delete=False, prefix='rc-test-', suffix='.html') | |
|
53 | f = tempfile.NamedTemporaryFile(delete=False, prefix='rc-test-', suffix='.html') | |
|
54 | 54 | f.write(out) |
|
55 | 55 | return f.name |
|
56 | 56 | |
@@ -63,6 +63,7 b' class CustomTestResponse(TestResponse):' | |||
|
63 | 63 | |
|
64 | 64 | assert string in res |
|
65 | 65 | """ |
|
66 | print_body = kw.pop('print_body', False) | |
|
66 | 67 | if 'no' in kw: |
|
67 | 68 | no = kw['no'] |
|
68 | 69 | del kw['no'] |
@@ -79,18 +80,20 b' class CustomTestResponse(TestResponse):' | |||
|
79 | 80 | for s in strings: |
|
80 | 81 | if not s in self: |
|
81 | 82 | print_stderr("Actual response (no %r):" % s) |
|
82 |
print_stderr( |
|
|
83 | print_stderr("body output saved as `%s`" % f) | |
|
84 | if print_body: | |
|
85 | print_stderr(str(self)) | |
|
83 | 86 | raise IndexError( |
|
84 | "Body does not contain string %r, output saved as %s" % ( | |
|
85 | s, f)) | |
|
87 | "Body does not contain string %r, body output saved as %s" % (s, f)) | |
|
86 | 88 | |
|
87 | 89 | for no_s in no: |
|
88 | 90 | if no_s in self: |
|
89 | 91 | print_stderr("Actual response (has %r)" % no_s) |
|
90 |
print_stderr( |
|
|
92 | print_stderr("body output saved as `%s`" % f) | |
|
93 | if print_body: | |
|
94 | print_stderr(str(self)) | |
|
91 | 95 | raise IndexError( |
|
92 | "Body contains bad string %r, output saved as %s" % ( | |
|
93 | no_s, f)) | |
|
96 | "Body contains bad string %r, body output saved as %s" % (no_s, f)) | |
|
94 | 97 | |
|
95 | 98 | def assert_response(self): |
|
96 | 99 | return AssertResponse(self) |
General Comments 0
You need to be logged in to leave comments.
Login now