pull-requests: allow to show range diff in pr view
marcink -
r3124:ddd1ae7b default
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -303,7 +303,8
303
303
304 def render_patchset_filtered(self, diffset, patchset, source_ref=None, target_ref=None):
304 def render_patchset_filtered(self, diffset, patchset, source_ref=None, target_ref=None):
305 filtered_patchset, has_hidden_changes = self.filter_patchset(patchset)
305 filtered_patchset, has_hidden_changes = self.filter_patchset(patchset)
306 result = diffset.render_patchset(filtered_patchset, source_ref=source_ref, target_ref=target_ref)
306 result = diffset.render_patchset(
307 filtered_patchset, source_ref=source_ref, target_ref=target_ref)
307 result.has_hidden_changes = has_hidden_changes
308 result.has_hidden_changes = has_hidden_changes
308 return result
309 return result
309
310
@@ -135,12 +135,18
135 if backend.alias == 'svn':
135 if backend.alias == 'svn':
136 response.mustcontain(
136 response.mustcontain(
137 '''data-f-path="vcs/commands/summary.py" '''
137 '''data-f-path="vcs/commands/summary.py" '''
138 '''id="a_c--ad05457a43f8"'''
138 '''id="a_c-300-ad05457a43f8"'''
139 )
139 )
140 else:
140 if backend.alias == 'git':
141 response.mustcontain(
141 response.mustcontain(
142 '''data-f-path="vcs/backends/hg.py" '''
142 '''data-f-path="vcs/backends/hg.py" '''
143 '''id="a_c--9c390eb52cd6"'''
143 '''id="a_c-883e775e89ea-9c390eb52cd6"'''
144 )
145
146 if backend.alias == 'hg':
147 response.mustcontain(
148 '''data-f-path="vcs/backends/hg.py" '''
149 '''id="a_c-e58d85a3973b-9c390eb52cd6"'''
144 )
150 )
145
151
146 assert Notification.query().count() == 1
152 assert Notification.query().count() == 1
@@ -104,13 +104,11
104 # Comparing the revisions
104 # Comparing the revisions
105 response = self.app.get(
105 response = self.app.get(
106 route_path('repo_compare',
106 route_path('repo_compare',
107 repo_name=origin.repo_name,
107 repo_name=origin.repo_name,
108 source_ref_type="rev",
108 source_ref_type="rev", source_ref=commit3.raw_id,
109 source_ref=commit3.raw_id,
109 target_ref_type="rev", target_ref=commit4.raw_id,
110 target_ref_type="rev",
110 params=dict(merge='1', target_repo=fork.repo_name)
111 target_ref=commit4.raw_id,
111 ))
112 params=dict(merge='1', target_repo=fork.repo_name)
113 ))
114
112
115 compare_page = ComparePage(response)
113 compare_page = ComparePage(response)
116 compare_page.contains_commits([commit4])
114 compare_page.contains_commits([commit4])
@@ -142,13 +140,11
142
140
143 response = self.app.get(
141 response = self.app.get(
144 route_path('repo_compare',
142 route_path('repo_compare',
145 repo_name=repo1.repo_name,
143 repo_name=repo1.repo_name,
146 source_ref_type="branch",
144 source_ref_type="branch", source_ref=commit_id2,
147 source_ref=commit_id2,
145 target_ref_type="branch", target_ref=commit_id1,
148 target_ref_type="branch",
146 params=dict(merge='1', target_repo=repo2.repo_name)
149 target_ref=commit_id1,
147 ))
150 params=dict(merge='1', target_repo=repo2.repo_name)
151 ))
152
148
153 response.mustcontain('%s@%s' % (repo1.repo_name, commit_id2))
149 response.mustcontain('%s@%s' % (repo1.repo_name, commit_id2))
154 response.mustcontain('%s@%s' % (repo2.repo_name, commit_id1))
150 response.mustcontain('%s@%s' % (repo2.repo_name, commit_id1))
@@ -156,9 +152,9
156 compare_page = ComparePage(response)
152 compare_page = ComparePage(response)
157 compare_page.contains_change_summary(1, 2, 0)
153 compare_page.contains_change_summary(1, 2, 0)
158 compare_page.contains_commits([commit1, commit2])
154 compare_page.contains_commits([commit1, commit2])
159 compare_page.contains_file_links_and_anchors([
155
160 ('file1', 'a_c--826e8142e6ba'),
156 anchor = 'a_c-{}-826e8142e6ba'.format(commit0.short_id)
161 ])
157 compare_page.contains_file_links_and_anchors([('file1', anchor), ])
162
158
163 # Swap is removed when comparing branches since it's a PR feature and
159 # Swap is removed when comparing branches since it's a PR feature and
164 # it is then a preview mode
160 # it is then a preview mode
@@ -199,13 +195,11
199
195
200 response = self.app.get(
196 response = self.app.get(
201 route_path('repo_compare',
197 route_path('repo_compare',
202 repo_name=repo1.repo_name,
198 repo_name=repo1.repo_name,
203 source_ref_type="branch",
199 source_ref_type="branch", source_ref=commit_id2,
204 source_ref=commit_id2,
200 target_ref_type="branch", target_ref=commit_id1,
205 target_ref_type="branch",
201 params=dict(merge='1', target_repo=repo2.repo_name),
206 target_ref=commit_id1,
202 ))
207 params=dict(merge='1', target_repo=repo2.repo_name),
208 ))
209
203
210 response.mustcontain('%s@%s' % (repo1.repo_name, commit_id2))
204 response.mustcontain('%s@%s' % (repo1.repo_name, commit_id2))
211 response.mustcontain('%s@%s' % (repo2.repo_name, commit_id1))
205 response.mustcontain('%s@%s' % (repo2.repo_name, commit_id1))
@@ -213,9 +207,8
213 compare_page = ComparePage(response)
207 compare_page = ComparePage(response)
214 compare_page.contains_change_summary(1, 2, 0)
208 compare_page.contains_change_summary(1, 2, 0)
215 compare_page.contains_commits([commit1, commit2])
209 compare_page.contains_commits([commit1, commit2])
216 compare_page.contains_file_links_and_anchors([
210 anchor = 'a_c-{}-826e8142e6ba'.format(commit0.short_id)
217 ('file1', 'a_c--826e8142e6ba'),
211 compare_page.contains_file_links_and_anchors([('file1', anchor), ])
218 ])
219
212
220 # Swap is removed when comparing branches since it's a PR feature and
213 # Swap is removed when comparing branches since it's a PR feature and
221 # it is then a preview mode
214 # it is then a preview mode
@@ -230,13 +223,11
230
223
231 response = self.app.get(
224 response = self.app.get(
232 route_path('repo_compare',
225 route_path('repo_compare',
233 repo_name=orig.repo_name,
226 repo_name=orig.repo_name,
234 source_ref_type="rev",
227 source_ref_type="rev", source_ref="tip",
235 source_ref="tip",
228 target_ref_type="rev", target_ref="tip",
236 target_ref_type="rev",
229 params=dict(merge='1', target_repo=fork.repo_name),
237 target_ref="tip",
230 ),
238 params=dict(merge='1', target_repo=fork.repo_name),
239 ),
240 status=302)
231 status=302)
241 response = response.follow()
232 response = response.follow()
242 response.mustcontain("Repositories unrelated.")
233 response.mustcontain("Repositories unrelated.")
@@ -289,14 +280,12
289
280
290 response = self.app.get(
281 response = self.app.get(
291 route_path('repo_compare',
282 route_path('repo_compare',
292 repo_name=repo2.repo_name,
283 repo_name=repo2.repo_name,
293 source_ref_type="rev",
284 # parent of commit2, in target repo2
294 # parent of commit2, in target repo2
285 source_ref_type="rev", source_ref=commit1.raw_id,
295 source_ref=commit1.raw_id,
286 target_ref_type="rev", target_ref=commit4.raw_id,
296 target_ref_type="rev",
287 params=dict(merge='1', target_repo=repo1.repo_name),
297 target_ref=commit4.raw_id,
288 ))
298 params=dict(merge='1', target_repo=repo1.repo_name),
299 ))
300 response.mustcontain('%s@%s' % (repo2.repo_name, commit1.short_id))
289 response.mustcontain('%s@%s' % (repo2.repo_name, commit1.short_id))
301 response.mustcontain('%s@%s' % (repo1.repo_name, commit4.short_id))
290 response.mustcontain('%s@%s' % (repo1.repo_name, commit4.short_id))
302
291
@@ -304,9 +293,8
304 compare_page = ComparePage(response)
293 compare_page = ComparePage(response)
305 compare_page.contains_change_summary(1, 3, 0)
294 compare_page.contains_change_summary(1, 3, 0)
306 compare_page.contains_commits([commit2, commit3, commit4])
295 compare_page.contains_commits([commit2, commit3, commit4])
307 compare_page.contains_file_links_and_anchors([
296 anchor = 'a_c-{}-826e8142e6ba'.format(commit1.short_id)
308 ('file1', 'a_c--826e8142e6ba'),
297 compare_page.contains_file_links_and_anchors([('file1', anchor),])
309 ])
310
298
311 @pytest.mark.xfail_backends("svn")
299 @pytest.mark.xfail_backends("svn")
312 def test_compare_cherry_pick_commits_from_top(self, backend):
300 def test_compare_cherry_pick_commits_from_top(self, backend):
@@ -355,14 +343,11
355
343
356 response = self.app.get(
344 response = self.app.get(
357 route_path('repo_compare',
345 route_path('repo_compare',
358 repo_name=repo1.repo_name,
346 repo_name=repo1.repo_name,
359 source_ref_type="rev",
347 # parent of commit3, not in source repo2
360 # parent of commit3, not in source repo2
348 source_ref_type="rev", source_ref=commit2.raw_id,
361 source_ref=commit2.raw_id,
349 target_ref_type="rev", target_ref=commit5.raw_id,
362 target_ref_type="rev",
350 params=dict(merge='1'),))
363 target_ref=commit5.raw_id,
364 params=dict(merge='1'),
365 ))
366
351
367 response.mustcontain('%s@%s' % (repo1.repo_name, commit2.short_id))
352 response.mustcontain('%s@%s' % (repo1.repo_name, commit2.short_id))
368 response.mustcontain('%s@%s' % (repo1.repo_name, commit5.short_id))
353 response.mustcontain('%s@%s' % (repo1.repo_name, commit5.short_id))
@@ -372,9 +357,8
372 compare_page.contains_commits([commit3, commit4, commit5])
357 compare_page.contains_commits([commit3, commit4, commit5])
373
358
374 # files
359 # files
375 compare_page.contains_file_links_and_anchors([
360 anchor = 'a_c-{}-826e8142e6ba'.format(commit2.short_id)
376 ('file1', 'a_c--826e8142e6ba'),
361 compare_page.contains_file_links_and_anchors([('file1', anchor),])
377 ])
378
362
379 @pytest.mark.xfail_backends("svn")
363 @pytest.mark.xfail_backends("svn")
380 def test_compare_remote_branches(self, backend):
364 def test_compare_remote_branches(self, backend):
@@ -382,17 +366,17
382 repo2 = backend.create_fork()
366 repo2 = backend.create_fork()
383
367
384 commit_id1 = repo1.get_commit(commit_idx=3).raw_id
368 commit_id1 = repo1.get_commit(commit_idx=3).raw_id
369 commit_id1_short = repo1.get_commit(commit_idx=3).short_id
385 commit_id2 = repo1.get_commit(commit_idx=6).raw_id
370 commit_id2 = repo1.get_commit(commit_idx=6).raw_id
371 commit_id2_short = repo1.get_commit(commit_idx=6).short_id
386
372
387 response = self.app.get(
373 response = self.app.get(
388 route_path('repo_compare',
374 route_path('repo_compare',
389 repo_name=repo1.repo_name,
375 repo_name=repo1.repo_name,
390 source_ref_type="rev",
376 source_ref_type="rev", source_ref=commit_id1,
391 source_ref=commit_id1,
377 target_ref_type="rev", target_ref=commit_id2,
392 target_ref_type="rev",
378 params=dict(merge='1', target_repo=repo2.repo_name),
393 target_ref=commit_id2,
379 ))
394 params=dict(merge='1', target_repo=repo2.repo_name),
395 ))
396
380
397 response.mustcontain('%s@%s' % (repo1.repo_name, commit_id1))
381 response.mustcontain('%s@%s' % (repo1.repo_name, commit_id1))
398 response.mustcontain('%s@%s' % (repo2.repo_name, commit_id2))
382 response.mustcontain('%s@%s' % (repo2.repo_name, commit_id2))
@@ -405,9 +389,9
405
389
406 # files
390 # files
407 compare_page.contains_file_links_and_anchors([
391 compare_page.contains_file_links_and_anchors([
408 ('vcs/backends/hg.py', 'a_c--9c390eb52cd6'),
392 ('vcs/backends/hg.py', 'a_c-{}-9c390eb52cd6'.format(commit_id2_short)),
409 ('vcs/backends/__init__.py', 'a_c--41b41c1f2796'),
393 ('vcs/backends/__init__.py', 'a_c-{}-41b41c1f2796'.format(commit_id1_short)),
410 ('vcs/backends/base.py', 'a_c--2f574d260608'),
394 ('vcs/backends/base.py', 'a_c-{}-2f574d260608'.format(commit_id1_short)),
411 ])
395 ])
412
396
413 @pytest.mark.xfail_backends("svn")
397 @pytest.mark.xfail_backends("svn")
@@ -451,13 +435,11
451
435
452 response = self.app.get(
436 response = self.app.get(
453 route_path('repo_compare',
437 route_path('repo_compare',
454 repo_name=r2_name,
438 repo_name=r2_name,
455 source_ref_type="branch",
439 source_ref_type="branch", source_ref=commit_id1,
456 source_ref=commit_id1,
440 target_ref_type="branch", target_ref=commit_id2,
457 target_ref_type="branch",
441 params=dict(merge='1', target_repo=r1_name),
458 target_ref=commit_id2,
442 ))
459 params=dict(merge='1', target_repo=r1_name),
460 ))
461
443
462 response.mustcontain('%s@%s' % (r2_name, commit_id1))
444 response.mustcontain('%s@%s' % (r2_name, commit_id1))
463 response.mustcontain('%s@%s' % (r1_name, commit_id2))
445 response.mustcontain('%s@%s' % (r1_name, commit_id2))
@@ -472,13 +454,11
472 # compare !
454 # compare !
473 response = self.app.get(
455 response = self.app.get(
474 route_path('repo_compare',
456 route_path('repo_compare',
475 repo_name=r2_name,
457 repo_name=r2_name,
476 source_ref_type="branch",
458 source_ref_type="branch", source_ref=commit_id1,
477 source_ref=commit_id1,
459 target_ref_type="branch", target_ref=commit_id2,
478 target_ref_type="branch",
460 params=dict(merge='1', target_repo=r1_name),
479 target_ref=commit_id2,
461 ))
480 params=dict(merge='1', target_repo=r1_name),
481 ))
482
462
483 response.mustcontain('%s@%s' % (r2_name, commit_id1))
463 response.mustcontain('%s@%s' % (r2_name, commit_id1))
484 response.mustcontain('%s@%s' % (r1_name, commit_id2))
464 response.mustcontain('%s@%s' % (r1_name, commit_id2))
@@ -495,14 +475,12
495
475
496 response = self.app.get(
476 response = self.app.get(
497 route_path('repo_compare',
477 route_path('repo_compare',
498 repo_name=backend.repo_name,
478 repo_name=backend.repo_name,
499 source_ref_type="rev",
479 source_ref_type="rev", source_ref=commit0.raw_id,
500 source_ref=commit0.raw_id,
480 target_ref_type="rev", target_ref=commit1.raw_id,
501 target_ref_type="rev",
481 params=dict(merge='1')
502 target_ref=commit1.raw_id,
482 ),
503 params=dict(merge='1')
483 extra_environ=xhr_header, )
504 ),
505 extra_environ=xhr_header,)
506
484
507 # outgoing commits between those commits
485 # outgoing commits between those commits
508 compare_page = ComparePage(response)
486 compare_page = ComparePage(response)
@@ -514,13 +492,11
514
492
515 response = self.app.get(
493 response = self.app.get(
516 route_path('repo_compare',
494 route_path('repo_compare',
517 repo_name=badrepo,
495 repo_name=badrepo,
518 source_ref_type="rev",
496 source_ref_type="rev", source_ref='tip',
519 source_ref='tip',
497 target_ref_type="rev", target_ref='tip',
520 target_ref_type="rev",
498 params=dict(merge='1', target_repo=repo.repo_name)
521 target_ref='tip',
499 ),
522 params=dict(merge='1', target_repo=repo.repo_name)
523 ),
524 status=404)
500 status=404)
525
501
526 def test_errors_when_comparing_unknown_target_repo(self, backend):
502 def test_errors_when_comparing_unknown_target_repo(self, backend):
@@ -529,13 +505,11
529
505
530 response = self.app.get(
506 response = self.app.get(
531 route_path('repo_compare',
507 route_path('repo_compare',
532 repo_name=repo.repo_name,
508 repo_name=repo.repo_name,
533 source_ref_type="rev",
509 source_ref_type="rev", source_ref='tip',
534 source_ref='tip',
510 target_ref_type="rev", target_ref='tip',
535 target_ref_type="rev",
511 params=dict(merge='1', target_repo=badrepo),
536 target_ref='tip',
512 ),
537 params=dict(merge='1', target_repo=badrepo),
538 ),
539 status=302)
513 status=302)
540 redirected = response.follow()
514 redirected = response.follow()
541 redirected.mustcontain(
515 redirected.mustcontain(
@@ -547,12 +521,10
547
521
548 response = self.app.get(
522 response = self.app.get(
549 route_path('repo_compare',
523 route_path('repo_compare',
550 repo_name=backend_stub.repo_name,
524 repo_name=backend_stub.repo_name,
551 source_ref_type="rev",
525 source_ref_type="rev", source_ref=commit0.raw_id,
552 source_ref=commit0.raw_id,
526 target_ref_type="rev", target_ref=commit1.raw_id,
553 target_ref_type="rev",
527 ))
554 target_ref=commit1.raw_id,
555 ))
556
528
557 # outgoing commits between those commits
529 # outgoing commits between those commits
558 compare_page = ComparePage(response)
530 compare_page = ComparePage(response)
@@ -575,13 +547,11
575
547
576 response = self.app.get(
548 response = self.app.get(
577 route_path('repo_compare',
549 route_path('repo_compare',
578 repo_name=orig.repo_name,
550 repo_name=orig.repo_name,
579 source_ref_type="rev",
551 source_ref_type="rev", source_ref="tip",
580 source_ref="tip",
552 target_ref_type="rev", target_ref="tip",
581 target_ref_type="rev",
553 params=dict(merge='1', target_repo=fork.repo_name),
582 target_ref="tip",
554 ),
583 params=dict(merge='1', target_repo=fork.repo_name),
584 ),
585 status=302)
555 status=302)
586
556
587 assert_session_flash(
557 assert_session_flash(
@@ -597,13 +567,13
597 commit_id = repo.get_commit(commit_idx=-1).raw_id
567 commit_id = repo.get_commit(commit_idx=-1).raw_id
598 response = app.get(
568 response = app.get(
599 route_path('repo_compare',
569 route_path('repo_compare',
600 repo_name=repo.repo_name,
570 repo_name=repo.repo_name,
601 source_ref_type="tag",
571 source_ref_type="tag",
602 source_ref="%s@%s" % ('tags/v0.1', commit_id),
572 source_ref="%s@%s" % ('tags/v0.1', commit_id),
603 target_ref_type="tag",
573 target_ref_type="tag",
604 target_ref="%s@%s" % ('tags/v0.2', commit_id),
574 target_ref="%s@%s" % ('tags/v0.2', commit_id),
605 params=dict(merge='1'),
575 params=dict(merge='1'),
606 ),
576 ),
607 status=200)
577 status=200)
608
578
609 # Expecting no commits, since both paths are at the same revision
579 # Expecting no commits, since both paths are at the same revision
@@ -620,13 +590,13
620 target_id = repo.get_commit(commit_idx=-1).raw_id
590 target_id = repo.get_commit(commit_idx=-1).raw_id
621 response = app.get(
591 response = app.get(
622 route_path('repo_compare',
592 route_path('repo_compare',
623 repo_name=repo.repo_name,
593 repo_name=repo.repo_name,
624 source_ref_type="tag",
594 source_ref_type="tag",
625 source_ref="%s@%s" % ('tags/v0.1', source_id),
595 source_ref="%s@%s" % ('tags/v0.1', source_id),
626 target_ref_type="tag",
596 target_ref_type="tag",
627 target_ref="%s@%s" % ('tags/v0.2', target_id),
597 target_ref="%s@%s" % ('tags/v0.2', target_id),
628 params=dict(merge='1')
598 params=dict(merge='1')
629 ),
599 ),
630 status=200)
600 status=200)
631
601
632 # It should show commits
602 # It should show commits
@@ -694,4 +664,3
694 def target_source_are_enabled(self):
664 def target_source_are_enabled(self):
695 response = self.response
665 response = self.response
696 response.mustcontain("var enable_fields = true;")
666 response.mustcontain("var enable_fields = true;")
697
@@ -47,10 +47,8
47 route_path(
47 route_path(
48 'repo_compare',
48 'repo_compare',
49 repo_name=backend.repo_name,
49 repo_name=backend.repo_name,
50 source_ref_type="tag",
50 source_ref_type="tag", source_ref=tag1,
51 source_ref=tag1,
51 target_ref_type="tag", target_ref=tag2),
52 target_ref_type="tag",
53 target_ref=tag2),
54 status=200)
52 status=200)
55
53
56 response.mustcontain('%s@%s' % (backend.repo_name, tag1))
54 response.mustcontain('%s@%s' % (backend.repo_name, tag1))
@@ -69,18 +67,28
69 compare_page.contains_commits(commits)
67 compare_page.contains_commits(commits)
70
68
71 # files diff
69 # files diff
70 short_id = short_id_new = ''
71 if backend.alias == 'git':
72 short_id = '5a3a8fb00555'
73 short_id_new = '0ba5f8a46600'
74 if backend.alias == 'hg':
75 short_id = '17544fbfcd33'
76 short_id_new = 'a7e60bff65d5'
77
72 compare_page.contains_file_links_and_anchors([
78 compare_page.contains_file_links_and_anchors([
73 ('docs/api/utils/index.rst', 'a_c--1c5cf9e91c12'),
79 # modified
74 ('test_and_report.sh', 'a_c--e3305437df55'),
80 ('docs/api/utils/index.rst', 'a_c-{}-1c5cf9e91c12'.format(short_id)),
75 ('.hgignore', 'a_c--c8e92ef85cd1'),
81 ('test_and_report.sh', 'a_c-{}-e3305437df55'.format(short_id)),
76 ('.hgtags', 'a_c--6e08b694d687'),
82 # added
77 ('docs/api/index.rst', 'a_c--2c14b00f3393'),
83 ('.hgignore', 'a_c-{}-c8e92ef85cd1'.format(short_id_new)),
78 ('vcs/__init__.py', 'a_c--430ccbc82bdf'),
84 ('.hgtags', 'a_c-{}-6e08b694d687'.format(short_id_new)),
79 ('vcs/backends/hg.py', 'a_c--9c390eb52cd6'),
85 ('docs/api/index.rst', 'a_c-{}-2c14b00f3393'.format(short_id_new)),
80 ('vcs/utils/__init__.py', 'a_c--ebb592c595c0'),
86 ('vcs/__init__.py', 'a_c-{}-430ccbc82bdf'.format(short_id_new)),
81 ('vcs/utils/annotate.py', 'a_c--7abc741b5052'),
87 ('vcs/backends/hg.py', 'a_c-{}-9c390eb52cd6'.format(short_id_new)),
82 ('vcs/utils/diffs.py', 'a_c--2ef0ef106c56'),
88 ('vcs/utils/__init__.py', 'a_c-{}-ebb592c595c0'.format(short_id_new)),
83 ('vcs/utils/lazy.py', 'a_c--3150cb87d4b7'),
89 ('vcs/utils/annotate.py', 'a_c-{}-7abc741b5052'.format(short_id_new)),
90 ('vcs/utils/diffs.py', 'a_c-{}-2ef0ef106c56'.format(short_id_new)),
91 ('vcs/utils/lazy.py', 'a_c-{}-3150cb87d4b7'.format(short_id_new)),
84 ])
92 ])
85
93
86 @pytest.mark.xfail_backends("svn", msg="Depends on branch and tag support")
94 @pytest.mark.xfail_backends("svn", msg="Depends on branch and tag support")
@@ -104,12 +112,10
104
112
105 response = self.app.get(
113 response = self.app.get(
106 route_path(
114 route_path(
107 'repo_compare',
115 'repo_compare',
108 repo_name=backend.repo_name,
116 repo_name=backend.repo_name,
109 source_ref_type='branch',
117 source_ref_type='branch', source_ref=data['branch'],
110 source_ref=data['branch'],
118 target_ref_type="tag", target_ref=data['tag'],
111 target_ref_type="tag",
112 target_ref=data['tag'],
113 ))
119 ))
114
120
115 response.mustcontain('%s@%s' % (backend.repo_name, data['branch']))
121 response.mustcontain('%s@%s' % (backend.repo_name, data['branch']))
@@ -121,12 +127,10
121 head_id = backend.default_head_id
127 head_id = backend.default_head_id
122 response = self.app.get(
128 response = self.app.get(
123 route_path(
129 route_path(
124 'repo_compare',
130 'repo_compare',
125 repo_name=backend.repo_name,
131 repo_name=backend.repo_name,
126 source_ref_type="branch",
132 source_ref_type="branch", source_ref=head_id,
127 source_ref=head_id,
133 target_ref_type="branch", target_ref=head_id,
128 target_ref_type="branch",
129 target_ref=head_id,
130 ))
134 ))
131
135
132 response.mustcontain('%s@%s' % (backend.repo_name, head_id))
136 response.mustcontain('%s@%s' % (backend.repo_name, head_id))
@@ -138,16 +142,16
138 def test_compare_commits(self, backend):
142 def test_compare_commits(self, backend):
139 repo = backend.repo
143 repo = backend.repo
140 commit1 = repo.get_commit(commit_idx=0)
144 commit1 = repo.get_commit(commit_idx=0)
145 commit1_short_id = commit1.short_id
141 commit2 = repo.get_commit(commit_idx=1)
146 commit2 = repo.get_commit(commit_idx=1)
147 commit2_short_id = commit2.short_id
142
148
143 response = self.app.get(
149 response = self.app.get(
144 route_path(
150 route_path(
145 'repo_compare',
151 'repo_compare',
146 repo_name=backend.repo_name,
152 repo_name=backend.repo_name,
147 source_ref_type="rev",
153 source_ref_type="rev", source_ref=commit1.raw_id,
148 source_ref=commit1.raw_id,
154 target_ref_type="rev", target_ref=commit2.raw_id,
149 target_ref_type="rev",
150 target_ref=commit2.raw_id,
151 ))
155 ))
152 response.mustcontain('%s@%s' % (backend.repo_name, commit1.raw_id))
156 response.mustcontain('%s@%s' % (backend.repo_name, commit1.raw_id))
153 response.mustcontain('%s@%s' % (backend.repo_name, commit2.raw_id))
157 response.mustcontain('%s@%s' % (backend.repo_name, commit2.raw_id))
@@ -158,6 +162,6
158
162
159 # outgoing commits between those commits
163 # outgoing commits between those commits
160 compare_page.contains_commits([commit2])
164 compare_page.contains_commits([commit2])
161 compare_page.contains_file_links_and_anchors([
165 anchor = 'a_c-{}-c8e92ef85cd1'.format(commit2_short_id)
162 ('.hgignore', 'a_c--c8e92ef85cd1'),
166 response.mustcontain(anchor)
163 ])
167 compare_page.contains_file_links_and_anchors([('.hgignore', anchor),])
@@ -81,20 +81,21
81 repo = backend.repo
81 repo = backend.repo
82
82
83 self.app.get(
83 self.app.get(
84 route_path('pullrequest_new',
84 route_path('pullrequest_new', repo_name=repo.repo_name,
85 repo_name=repo.repo_name,
85 commit=repo.get_commit().raw_id),
86 commit=repo.get_commit().raw_id),
87 status=200)
86 status=200)
88
87
89 @pytest.mark.parametrize('pr_merge_enabled', [True, False])
88 @pytest.mark.parametrize('pr_merge_enabled', [True, False])
90 def test_show(self, pr_util, pr_merge_enabled):
89 @pytest.mark.parametrize('range_diff', ["0", "1"])
90 def test_show(self, pr_util, pr_merge_enabled, range_diff):
91 pull_request = pr_util.create_pull_request(
91 pull_request = pr_util.create_pull_request(
92 mergeable=pr_merge_enabled, enable_notifications=False)
92 mergeable=pr_merge_enabled, enable_notifications=False)
93
93
94 response = self.app.get(route_path(
94 response = self.app.get(route_path(
95 'pullrequest_show',
95 'pullrequest_show',
96 repo_name=pull_request.target_repo.scm_instance().name,
96 repo_name=pull_request.target_repo.scm_instance().name,
97 pull_request_id=pull_request.pull_request_id))
97 pull_request_id=pull_request.pull_request_id,
98 params={'range-diff': range_diff}))
98
99
99 for commit_id in pull_request.revisions:
100 for commit_id in pull_request.revisions:
100 response.mustcontain(commit_id)
101 response.mustcontain(commit_id)
@@ -105,9 +106,13
105 assert target_clone_url in response
106 assert target_clone_url in response
106
107
107 assert 'class="pull-request-merge"' in response
108 assert 'class="pull-request-merge"' in response
108 assert (
109 if pr_merge_enabled:
109 'Server-side pull request merging is disabled.'
110 response.mustcontain('Pull request reviewer approval is pending')
110 in response) != pr_merge_enabled
111 else:
112 response.mustcontain('Server-side pull request merging is disabled.')
113
114 if range_diff == "1":
115 response.mustcontain('Turn off: Show the diff as commit range')
111
116
112 def test_close_status_visibility(self, pr_util, user_util, csrf_token):
117 def test_close_status_visibility(self, pr_util, user_util, csrf_token):
113 # Logout
118 # Logout
@@ -245,7 +245,7
245 c.changes[commit.raw_id] = []
245 c.changes[commit.raw_id] = []
246
246
247 commit2 = commit
247 commit2 = commit
248 commit1 = commit.parents[0] if commit.parents else EmptyCommit()
248 commit1 = commit.first_parent
249
249
250 if method == 'show':
250 if method == 'show':
251 inline_comments = CommentsModel().get_inline_comments(
251 inline_comments = CommentsModel().get_inline_comments(
@@ -138,6 +138,13
138 })
138 })
139 return data
139 return data
140
140
141 def get_recache_flag(self):
142 for flag_name in ['force_recache', 'force-recache', 'no-cache']:
143 flag_val = self.request.GET.get(flag_name)
144 if str2bool(flag_val):
145 return True
146 return False
147
141 @LoginRequired()
148 @LoginRequired()
142 @HasRepoPermissionAnyDecorator(
149 @HasRepoPermissionAnyDecorator(
143 'repository.read', 'repository.write', 'repository.admin')
150 'repository.read', 'repository.write', 'repository.admin')
@@ -234,6 +241,30
234
241
235 return diffset
242 return diffset
236
243
244 def _get_range_diffset(self, source_scm, source_repo,
245 commit1, commit2, diff_limit, file_limit,
246 fulldiff, ign_whitespace_lcl, context_lcl):
247 vcs_diff = source_scm.get_diff(
248 commit1, commit2,
249 ignore_whitespace=ign_whitespace_lcl,
250 context=context_lcl)
251
252 diff_processor = diffs.DiffProcessor(
253 vcs_diff, format='newdiff', diff_limit=diff_limit,
254 file_limit=file_limit, show_full_diff=fulldiff)
255
256 _parsed = diff_processor.prepare()
257
258 diffset = codeblocks.DiffSet(
259 repo_name=source_repo.repo_name,
260 source_node_getter=codeblocks.diffset_node_getter(commit1),
261 target_node_getter=codeblocks.diffset_node_getter(commit2))
262
263 diffset = self.path_filter.render_patchset_filtered(
264 diffset, _parsed, commit1.raw_id, commit2.raw_id)
265
266 return diffset
267
237 @LoginRequired()
268 @LoginRequired()
238 @HasRepoPermissionAnyDecorator(
269 @HasRepoPermissionAnyDecorator(
239 'repository.read', 'repository.write', 'repository.admin')
270 'repository.read', 'repository.write', 'repository.admin')
@@ -265,6 +296,9
265 pull_request_id=pull_request_id))
296 pull_request_id=pull_request_id))
266
297
267 versions = pull_request_display_obj.versions()
298 versions = pull_request_display_obj.versions()
299 # used to store per-commit range diffs
300 c.changes = collections.OrderedDict()
301 c.range_diff_on = self.request.GET.get('range-diff') == "1"
268
302
269 c.at_version = at_version
303 c.at_version = at_version
270 c.at_version_num = (at_version
304 c.at_version_num = (at_version
@@ -453,14 +487,13
453 version_normalized = version or 'latest'
487 version_normalized = version or 'latest'
454 from_version_normalized = from_version or 'latest'
488 from_version_normalized = from_version or 'latest'
455
489
456 cache_path = self.rhodecode_vcs_repo.get_create_shadow_cache_pr_path(
490 cache_path = self.rhodecode_vcs_repo.get_create_shadow_cache_pr_path(target_repo)
457 target_repo)
458 cache_file_path = diff_cache_exist(
491 cache_file_path = diff_cache_exist(
459 cache_path, 'pull_request', pull_request_id, version_normalized,
492 cache_path, 'pull_request', pull_request_id, version_normalized,
460 from_version_normalized, source_ref_id, target_ref_id, c.fulldiff)
493 from_version_normalized, source_ref_id, target_ref_id, c.fulldiff)
461
494
462 caching_enabled = self._is_diff_cache_enabled(c.target_repo)
495 caching_enabled = self._is_diff_cache_enabled(c.target_repo)
463 force_recache = str2bool(self.request.GET.get('force_recache'))
496 force_recache = self.get_recache_flag()
464
497
465 cached_diff = None
498 cached_diff = None
466 if caching_enabled:
499 if caching_enabled:
@@ -471,7 +504,8
471 and len(cached_diff.get('commits', [])) == 5
504 and len(cached_diff.get('commits', [])) == 5
472 and cached_diff.get('commits')[0]
505 and cached_diff.get('commits')[0]
473 and cached_diff.get('commits')[3])
506 and cached_diff.get('commits')[3])
474 if not force_recache and has_proper_commit_cache:
507
508 if not force_recache and not c.range_diff_on and has_proper_commit_cache:
475 diff_commit_cache = \
509 diff_commit_cache = \
476 (ancestor_commit, commit_cache, missing_requirements,
510 (ancestor_commit, commit_cache, missing_requirements,
477 source_commit, target_commit) = cached_diff['commits']
511 source_commit, target_commit) = cached_diff['commits']
@@ -546,8 +580,41
546 c.deleted_files_comments[fname]['stats'] = 0
580 c.deleted_files_comments[fname]['stats'] = 0
547 c.deleted_files_comments[fname]['comments'] = list()
581 c.deleted_files_comments[fname]['comments'] = list()
548 for lno, comments in per_line_comments.items():
582 for lno, comments in per_line_comments