##// END OF EJS Templates
pull-requests: allow to show range diff in pr view
marcink -
r3124:ddd1ae7b default
parent child Browse files
Show More
@@ -303,7 +303,8 b' class PathFilter(object):'
303 303
304 304 def render_patchset_filtered(self, diffset, patchset, source_ref=None, target_ref=None):
305 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 308 result.has_hidden_changes = has_hidden_changes
308 309 return result
309 310
@@ -135,12 +135,18 b' class TestRepoCommitCommentsView(TestCon'
135 135 if backend.alias == 'svn':
136 136 response.mustcontain(
137 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 141 response.mustcontain(
142 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 152 assert Notification.query().count() == 1
@@ -104,13 +104,11 b' class TestCompareView(object):'
104 104 # Comparing the revisions
105 105 response = self.app.get(
106 106 route_path('repo_compare',
107 repo_name=origin.repo_name,
108 source_ref_type="rev",
109 source_ref=commit3.raw_id,
110 target_ref_type="rev",
111 target_ref=commit4.raw_id,
112 params=dict(merge='1', target_repo=fork.repo_name)
113 ))
107 repo_name=origin.repo_name,
108 source_ref_type="rev", source_ref=commit3.raw_id,
109 target_ref_type="rev", target_ref=commit4.raw_id,
110 params=dict(merge='1', target_repo=fork.repo_name)
111 ))
114 112
115 113 compare_page = ComparePage(response)
116 114 compare_page.contains_commits([commit4])
@@ -142,13 +140,11 b' class TestCompareView(object):'
142 140
143 141 response = self.app.get(
144 142 route_path('repo_compare',
145 repo_name=repo1.repo_name,
146 source_ref_type="branch",
147 source_ref=commit_id2,
148 target_ref_type="branch",
149 target_ref=commit_id1,
150 params=dict(merge='1', target_repo=repo2.repo_name)
151 ))
143 repo_name=repo1.repo_name,
144 source_ref_type="branch", source_ref=commit_id2,
145 target_ref_type="branch", target_ref=commit_id1,
146 params=dict(merge='1', target_repo=repo2.repo_name)
147 ))
152 148
153 149 response.mustcontain('%s@%s' % (repo1.repo_name, commit_id2))
154 150 response.mustcontain('%s@%s' % (repo2.repo_name, commit_id1))
@@ -156,9 +152,9 b' class TestCompareView(object):'
156 152 compare_page = ComparePage(response)
157 153 compare_page.contains_change_summary(1, 2, 0)
158 154 compare_page.contains_commits([commit1, commit2])
159 compare_page.contains_file_links_and_anchors([
160 ('file1', 'a_c--826e8142e6ba'),
161 ])
155
156 anchor = 'a_c-{}-826e8142e6ba'.format(commit0.short_id)
157 compare_page.contains_file_links_and_anchors([('file1', anchor), ])
162 158
163 159 # Swap is removed when comparing branches since it's a PR feature and
164 160 # it is then a preview mode
@@ -199,13 +195,11 b' class TestCompareView(object):'
199 195
200 196 response = self.app.get(
201 197 route_path('repo_compare',
202 repo_name=repo1.repo_name,
203 source_ref_type="branch",
204 source_ref=commit_id2,
205 target_ref_type="branch",
206 target_ref=commit_id1,
207 params=dict(merge='1', target_repo=repo2.repo_name),
208 ))
198 repo_name=repo1.repo_name,
199 source_ref_type="branch", source_ref=commit_id2,
200 target_ref_type="branch", target_ref=commit_id1,
201 params=dict(merge='1', target_repo=repo2.repo_name),
202 ))
209 203
210 204 response.mustcontain('%s@%s' % (repo1.repo_name, commit_id2))
211 205 response.mustcontain('%s@%s' % (repo2.repo_name, commit_id1))
@@ -213,9 +207,8 b' class TestCompareView(object):'
213 207 compare_page = ComparePage(response)
214 208 compare_page.contains_change_summary(1, 2, 0)
215 209 compare_page.contains_commits([commit1, commit2])
216 compare_page.contains_file_links_and_anchors([
217 ('file1', 'a_c--826e8142e6ba'),
218 ])
210 anchor = 'a_c-{}-826e8142e6ba'.format(commit0.short_id)
211 compare_page.contains_file_links_and_anchors([('file1', anchor), ])
219 212
220 213 # Swap is removed when comparing branches since it's a PR feature and
221 214 # it is then a preview mode
@@ -230,13 +223,11 b' class TestCompareView(object):'
230 223
231 224 response = self.app.get(
232 225 route_path('repo_compare',
233 repo_name=orig.repo_name,
234 source_ref_type="rev",
235 source_ref="tip",
236 target_ref_type="rev",
237 target_ref="tip",
238 params=dict(merge='1', target_repo=fork.repo_name),
239 ),
226 repo_name=orig.repo_name,
227 source_ref_type="rev", source_ref="tip",
228 target_ref_type="rev", target_ref="tip",
229 params=dict(merge='1', target_repo=fork.repo_name),
230 ),
240 231 status=302)
241 232 response = response.follow()
242 233 response.mustcontain("Repositories unrelated.")
@@ -289,14 +280,12 b' class TestCompareView(object):'
289 280
290 281 response = self.app.get(
291 282 route_path('repo_compare',
292 repo_name=repo2.repo_name,
293 source_ref_type="rev",
294 # parent of commit2, in target repo2
295 source_ref=commit1.raw_id,
296 target_ref_type="rev",
297 target_ref=commit4.raw_id,
298 params=dict(merge='1', target_repo=repo1.repo_name),
299 ))
283 repo_name=repo2.repo_name,
284 # parent of commit2, in target repo2
285 source_ref_type="rev", source_ref=commit1.raw_id,
286 target_ref_type="rev", target_ref=commit4.raw_id,
287 params=dict(merge='1', target_repo=repo1.repo_name),
288 ))
300 289 response.mustcontain('%s@%s' % (repo2.repo_name, commit1.short_id))
301 290 response.mustcontain('%s@%s' % (repo1.repo_name, commit4.short_id))
302 291
@@ -304,9 +293,8 b' class TestCompareView(object):'
304 293 compare_page = ComparePage(response)
305 294 compare_page.contains_change_summary(1, 3, 0)
306 295 compare_page.contains_commits([commit2, commit3, commit4])
307 compare_page.contains_file_links_and_anchors([
308 ('file1', 'a_c--826e8142e6ba'),
309 ])
296 anchor = 'a_c-{}-826e8142e6ba'.format(commit1.short_id)
297 compare_page.contains_file_links_and_anchors([('file1', anchor),])
310 298
311 299 @pytest.mark.xfail_backends("svn")
312 300 def test_compare_cherry_pick_commits_from_top(self, backend):
@@ -355,14 +343,11 b' class TestCompareView(object):'
355 343
356 344 response = self.app.get(
357 345 route_path('repo_compare',
358 repo_name=repo1.repo_name,
359 source_ref_type="rev",
360 # parent of commit3, not in source repo2
361 source_ref=commit2.raw_id,
362 target_ref_type="rev",
363 target_ref=commit5.raw_id,
364 params=dict(merge='1'),
365 ))
346 repo_name=repo1.repo_name,
347 # parent of commit3, not in source repo2
348 source_ref_type="rev", source_ref=commit2.raw_id,
349 target_ref_type="rev", target_ref=commit5.raw_id,
350 params=dict(merge='1'),))
366 351
367 352 response.mustcontain('%s@%s' % (repo1.repo_name, commit2.short_id))
368 353 response.mustcontain('%s@%s' % (repo1.repo_name, commit5.short_id))
@@ -372,9 +357,8 b' class TestCompareView(object):'
372 357 compare_page.contains_commits([commit3, commit4, commit5])
373 358
374 359 # files
375 compare_page.contains_file_links_and_anchors([
376 ('file1', 'a_c--826e8142e6ba'),
377 ])
360 anchor = 'a_c-{}-826e8142e6ba'.format(commit2.short_id)
361 compare_page.contains_file_links_and_anchors([('file1', anchor),])
378 362
379 363 @pytest.mark.xfail_backends("svn")
380 364 def test_compare_remote_branches(self, backend):
@@ -382,17 +366,17 b' class TestCompareView(object):'
382 366 repo2 = backend.create_fork()
383 367
384 368 commit_id1 = repo1.get_commit(commit_idx=3).raw_id
369 commit_id1_short = repo1.get_commit(commit_idx=3).short_id
385 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 373 response = self.app.get(
388 374 route_path('repo_compare',
389 repo_name=repo1.repo_name,
390 source_ref_type="rev",
391 source_ref=commit_id1,
392 target_ref_type="rev",
393 target_ref=commit_id2,
394 params=dict(merge='1', target_repo=repo2.repo_name),
395 ))
375 repo_name=repo1.repo_name,
376 source_ref_type="rev", source_ref=commit_id1,
377 target_ref_type="rev", target_ref=commit_id2,
378 params=dict(merge='1', target_repo=repo2.repo_name),
379 ))
396 380
397 381 response.mustcontain('%s@%s' % (repo1.repo_name, commit_id1))
398 382 response.mustcontain('%s@%s' % (repo2.repo_name, commit_id2))
@@ -405,9 +389,9 b' class TestCompareView(object):'
405 389
406 390 # files
407 391 compare_page.contains_file_links_and_anchors([
408 ('vcs/backends/hg.py', 'a_c--9c390eb52cd6'),
409 ('vcs/backends/__init__.py', 'a_c--41b41c1f2796'),
410 ('vcs/backends/base.py', 'a_c--2f574d260608'),
392 ('vcs/backends/hg.py', 'a_c-{}-9c390eb52cd6'.format(commit_id2_short)),
393 ('vcs/backends/__init__.py', 'a_c-{}-41b41c1f2796'.format(commit_id1_short)),
394 ('vcs/backends/base.py', 'a_c-{}-2f574d260608'.format(commit_id1_short)),
411 395 ])
412 396
413 397 @pytest.mark.xfail_backends("svn")
@@ -451,13 +435,11 b' class TestCompareView(object):'
451 435
452 436 response = self.app.get(
453 437 route_path('repo_compare',
454 repo_name=r2_name,
455 source_ref_type="branch",
456 source_ref=commit_id1,
457 target_ref_type="branch",
458 target_ref=commit_id2,
459 params=dict(merge='1', target_repo=r1_name),
460 ))
438 repo_name=r2_name,
439 source_ref_type="branch", source_ref=commit_id1,
440 target_ref_type="branch", target_ref=commit_id2,
441 params=dict(merge='1', target_repo=r1_name),
442 ))
461 443
462 444 response.mustcontain('%s@%s' % (r2_name, commit_id1))
463 445 response.mustcontain('%s@%s' % (r1_name, commit_id2))
@@ -472,13 +454,11 b' class TestCompareView(object):'
472 454 # compare !
473 455 response = self.app.get(
474 456 route_path('repo_compare',
475 repo_name=r2_name,
476 source_ref_type="branch",
477 source_ref=commit_id1,
478 target_ref_type="branch",
479 target_ref=commit_id2,
480 params=dict(merge='1', target_repo=r1_name),
481 ))
457 repo_name=r2_name,
458 source_ref_type="branch", source_ref=commit_id1,
459 target_ref_type="branch", target_ref=commit_id2,
460 params=dict(merge='1', target_repo=r1_name),
461 ))
482 462
483 463 response.mustcontain('%s@%s' % (r2_name, commit_id1))
484 464 response.mustcontain('%s@%s' % (r1_name, commit_id2))
@@ -495,14 +475,12 b' class TestCompareView(object):'
495 475
496 476 response = self.app.get(
497 477 route_path('repo_compare',
498 repo_name=backend.repo_name,
499 source_ref_type="rev",
500 source_ref=commit0.raw_id,
501 target_ref_type="rev",
502 target_ref=commit1.raw_id,
503 params=dict(merge='1')
504 ),
505 extra_environ=xhr_header,)
478 repo_name=backend.repo_name,
479 source_ref_type="rev", source_ref=commit0.raw_id,
480 target_ref_type="rev", target_ref=commit1.raw_id,
481 params=dict(merge='1')
482 ),
483 extra_environ=xhr_header, )
506 484
507 485 # outgoing commits between those commits
508 486 compare_page = ComparePage(response)
@@ -514,13 +492,11 b' class TestCompareView(object):'
514 492
515 493 response = self.app.get(
516 494 route_path('repo_compare',
517 repo_name=badrepo,
518 source_ref_type="rev",
519 source_ref='tip',
520 target_ref_type="rev",
521 target_ref='tip',
522 params=dict(merge='1', target_repo=repo.repo_name)
523 ),
495 repo_name=badrepo,
496 source_ref_type="rev", source_ref='tip',
497 target_ref_type="rev", target_ref='tip',
498 params=dict(merge='1', target_repo=repo.repo_name)
499 ),
524 500 status=404)
525 501
526 502 def test_errors_when_comparing_unknown_target_repo(self, backend):
@@ -529,13 +505,11 b' class TestCompareView(object):'
529 505
530 506 response = self.app.get(
531 507 route_path('repo_compare',
532 repo_name=repo.repo_name,
533 source_ref_type="rev",
534 source_ref='tip',
535 target_ref_type="rev",
536 target_ref='tip',
537 params=dict(merge='1', target_repo=badrepo),
538 ),
508 repo_name=repo.repo_name,
509 source_ref_type="rev", source_ref='tip',
510 target_ref_type="rev", target_ref='tip',
511 params=dict(merge='1', target_repo=badrepo),
512 ),
539 513 status=302)
540 514 redirected = response.follow()
541 515 redirected.mustcontain(
@@ -547,12 +521,10 b' class TestCompareView(object):'
547 521
548 522 response = self.app.get(
549 523 route_path('repo_compare',
550 repo_name=backend_stub.repo_name,
551 source_ref_type="rev",
552 source_ref=commit0.raw_id,
553 target_ref_type="rev",
554 target_ref=commit1.raw_id,
555 ))
524 repo_name=backend_stub.repo_name,
525 source_ref_type="rev", source_ref=commit0.raw_id,
526 target_ref_type="rev", target_ref=commit1.raw_id,
527 ))
556 528
557 529 # outgoing commits between those commits
558 530 compare_page = ComparePage(response)
@@ -575,13 +547,11 b' class TestCompareView(object):'
575 547
576 548 response = self.app.get(
577 549 route_path('repo_compare',
578 repo_name=orig.repo_name,
579 source_ref_type="rev",
580 source_ref="tip",
581 target_ref_type="rev",
582 target_ref="tip",
583 params=dict(merge='1', target_repo=fork.repo_name),
584 ),
550 repo_name=orig.repo_name,
551 source_ref_type="rev", source_ref="tip",
552 target_ref_type="rev", target_ref="tip",
553 params=dict(merge='1', target_repo=fork.repo_name),
554 ),
585 555 status=302)
586 556
587 557 assert_session_flash(
@@ -597,13 +567,13 b' class TestCompareControllerSvn(object):'
597 567 commit_id = repo.get_commit(commit_idx=-1).raw_id
598 568 response = app.get(
599 569 route_path('repo_compare',
600 repo_name=repo.repo_name,
601 source_ref_type="tag",
602 source_ref="%s@%s" % ('tags/v0.1', commit_id),
603 target_ref_type="tag",
604 target_ref="%s@%s" % ('tags/v0.2', commit_id),
605 params=dict(merge='1'),
606 ),
570 repo_name=repo.repo_name,
571 source_ref_type="tag",
572 source_ref="%s@%s" % ('tags/v0.1', commit_id),
573 target_ref_type="tag",
574 target_ref="%s@%s" % ('tags/v0.2', commit_id),
575 params=dict(merge='1'),
576 ),
607 577 status=200)
608 578
609 579 # Expecting no commits, since both paths are at the same revision
@@ -620,13 +590,13 b' class TestCompareControllerSvn(object):'
620 590 target_id = repo.get_commit(commit_idx=-1).raw_id
621 591 response = app.get(
622 592 route_path('repo_compare',
623 repo_name=repo.repo_name,
624 source_ref_type="tag",
625 source_ref="%s@%s" % ('tags/v0.1', source_id),
626 target_ref_type="tag",
627 target_ref="%s@%s" % ('tags/v0.2', target_id),
628 params=dict(merge='1')
629 ),
593 repo_name=repo.repo_name,
594 source_ref_type="tag",
595 source_ref="%s@%s" % ('tags/v0.1', source_id),
596 target_ref_type="tag",
597 target_ref="%s@%s" % ('tags/v0.2', target_id),
598 params=dict(merge='1')
599 ),
630 600 status=200)
631 601
632 602 # It should show commits
@@ -694,4 +664,3 b' class ComparePage(AssertResponse):'
694 664 def target_source_are_enabled(self):
695 665 response = self.response
696 666 response.mustcontain("var enable_fields = true;")
697
@@ -47,10 +47,8 b' class TestCompareView(object):'
47 47 route_path(
48 48 'repo_compare',
49 49 repo_name=backend.repo_name,
50 source_ref_type="tag",
51 source_ref=tag1,
52 target_ref_type="tag",
53 target_ref=tag2),
50 source_ref_type="tag", source_ref=tag1,
51 target_ref_type="tag", target_ref=tag2),
54 52 status=200)
55 53
56 54 response.mustcontain('%s@%s' % (backend.repo_name, tag1))
@@ -69,18 +67,28 b' class TestCompareView(object):'
69 67 compare_page.contains_commits(commits)
70 68
71 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 78 compare_page.contains_file_links_and_anchors([
73 ('docs/api/utils/index.rst', 'a_c--1c5cf9e91c12'),
74 ('test_and_report.sh', 'a_c--e3305437df55'),
75 ('.hgignore', 'a_c--c8e92ef85cd1'),
76 ('.hgtags', 'a_c--6e08b694d687'),
77 ('docs/api/index.rst', 'a_c--2c14b00f3393'),
78 ('vcs/__init__.py', 'a_c--430ccbc82bdf'),
79 ('vcs/backends/hg.py', 'a_c--9c390eb52cd6'),
80 ('vcs/utils/__init__.py', 'a_c--ebb592c595c0'),
81 ('vcs/utils/annotate.py', 'a_c--7abc741b5052'),
82 ('vcs/utils/diffs.py', 'a_c--2ef0ef106c56'),
83 ('vcs/utils/lazy.py', 'a_c--3150cb87d4b7'),
79 # modified
80 ('docs/api/utils/index.rst', 'a_c-{}-1c5cf9e91c12'.format(short_id)),
81 ('test_and_report.sh', 'a_c-{}-e3305437df55'.format(short_id)),
82 # added
83 ('.hgignore', 'a_c-{}-c8e92ef85cd1'.format(short_id_new)),
84 ('.hgtags', 'a_c-{}-6e08b694d687'.format(short_id_new)),
85 ('docs/api/index.rst', 'a_c-{}-2c14b00f3393'.format(short_id_new)),
86 ('vcs/__init__.py', 'a_c-{}-430ccbc82bdf'.format(short_id_new)),
87 ('vcs/backends/hg.py', 'a_c-{}-9c390eb52cd6'.format(short_id_new)),
88 ('vcs/utils/__init__.py', 'a_c-{}-ebb592c595c0'.format(short_id_new)),
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 94 @pytest.mark.xfail_backends("svn", msg="Depends on branch and tag support")
@@ -104,12 +112,10 b' class TestCompareView(object):'
104 112
105 113 response = self.app.get(
106 114 route_path(
107 'repo_compare',
108 repo_name=backend.repo_name,
109 source_ref_type='branch',
110 source_ref=data['branch'],
111 target_ref_type="tag",
112 target_ref=data['tag'],
115 'repo_compare',
116 repo_name=backend.repo_name,
117 source_ref_type='branch', source_ref=data['branch'],
118 target_ref_type="tag", target_ref=data['tag'],
113 119 ))
114 120
115 121 response.mustcontain('%s@%s' % (backend.repo_name, data['branch']))
@@ -121,12 +127,10 b' class TestCompareView(object):'
121 127 head_id = backend.default_head_id
122 128 response = self.app.get(
123 129 route_path(
124 'repo_compare',
125 repo_name=backend.repo_name,
126 source_ref_type="branch",
127 source_ref=head_id,
128 target_ref_type="branch",
129 target_ref=head_id,
130 'repo_compare',
131 repo_name=backend.repo_name,
132 source_ref_type="branch", source_ref=head_id,
133 target_ref_type="branch", target_ref=head_id,
130 134 ))
131 135
132 136 response.mustcontain('%s@%s' % (backend.repo_name, head_id))
@@ -138,16 +142,16 b' class TestCompareView(object):'
138 142 def test_compare_commits(self, backend):
139 143 repo = backend.repo
140 144 commit1 = repo.get_commit(commit_idx=0)
145 commit1_short_id = commit1.short_id
141 146 commit2 = repo.get_commit(commit_idx=1)
147 commit2_short_id = commit2.short_id
142 148
143 149 response = self.app.get(
144 150 route_path(
145 'repo_compare',
146 repo_name=backend.repo_name,
147 source_ref_type="rev",
148 source_ref=commit1.raw_id,
149 target_ref_type="rev",
150 target_ref=commit2.raw_id,
151 'repo_compare',
152 repo_name=backend.repo_name,
153 source_ref_type="rev", source_ref=commit1.raw_id,
154 target_ref_type="rev", target_ref=commit2.raw_id,
151 155 ))
152 156 response.mustcontain('%s@%s' % (backend.repo_name, commit1.raw_id))
153 157 response.mustcontain('%s@%s' % (backend.repo_name, commit2.raw_id))
@@ -158,6 +162,6 b' class TestCompareView(object):'
158 162
159 163 # outgoing commits between those commits
160 164 compare_page.contains_commits([commit2])
161 compare_page.contains_file_links_and_anchors([
162 ('.hgignore', 'a_c--c8e92ef85cd1'),
163 ])
165 anchor = 'a_c-{}-c8e92ef85cd1'.format(commit2_short_id)
166 response.mustcontain(anchor)
167 compare_page.contains_file_links_and_anchors([('.hgignore', anchor),])
@@ -81,20 +81,21 b' class TestPullrequestsView(object):'
81 81 repo = backend.repo
82 82
83 83 self.app.get(
84 route_path('pullrequest_new',
85 repo_name=repo.repo_name,
86 commit=repo.get_commit().raw_id),
84 route_path('pullrequest_new', repo_name=repo.repo_name,
85 commit=repo.get_commit().raw_id),
87 86 status=200)
88 87
89 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 91 pull_request = pr_util.create_pull_request(
92 92 mergeable=pr_merge_enabled, enable_notifications=False)
93 93
94 94 response = self.app.get(route_path(
95 95 'pullrequest_show',
96 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 100 for commit_id in pull_request.revisions:
100 101 response.mustcontain(commit_id)
@@ -105,9 +106,13 b' class TestPullrequestsView(object):'
105 106 assert target_clone_url in response
106 107
107 108 assert 'class="pull-request-merge"' in response
108 assert (
109 'Server-side pull request merging is disabled.'
110 in response) != pr_merge_enabled
109 if pr_merge_enabled:
110 response.mustcontain('Pull request reviewer approval is pending')
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 117 def test_close_status_visibility(self, pr_util, user_util, csrf_token):
113 118 # Logout
@@ -245,7 +245,7 b' class RepoCommitsView(RepoAppView):'
245 245 c.changes[commit.raw_id] = []
246 246
247 247 commit2 = commit
248 commit1 = commit.parents[0] if commit.parents else EmptyCommit()
248 commit1 = commit.first_parent
249 249
250 250 if method == 'show':
251 251 inline_comments = CommentsModel().get_inline_comments(
@@ -138,6 +138,13 b' class RepoPullRequestsView(RepoAppView, '
138 138 })
139 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 148 @LoginRequired()
142 149 @HasRepoPermissionAnyDecorator(
143 150 'repository.read', 'repository.write', 'repository.admin')
@@ -234,6 +241,30 b' class RepoPullRequestsView(RepoAppView, '
234 241
235 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 268 @LoginRequired()
238 269 @HasRepoPermissionAnyDecorator(
239 270 'repository.read', 'repository.write', 'repository.admin')
@@ -265,6 +296,9 b' class RepoPullRequestsView(RepoAppView, '
265 296 pull_request_id=pull_request_id))
266 297
267 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 303 c.at_version = at_version
270 304 c.at_version_num = (at_version
@@ -453,14 +487,13 b' class RepoPullRequestsView(RepoAppView, '
453 487 version_normalized = version or 'latest'
454 488 from_version_normalized = from_version or 'latest'
455 489
456 cache_path = self.rhodecode_vcs_repo.get_create_shadow_cache_pr_path(
457 target_repo)
490 cache_path = self.rhodecode_vcs_repo.get_create_shadow_cache_pr_path(target_repo)
458 491 cache_file_path = diff_cache_exist(
459 492 cache_path, 'pull_request', pull_request_id, version_normalized,
460 493 from_version_normalized, source_ref_id, target_ref_id, c.fulldiff)
461 494
462 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 498 cached_diff = None
466 499 if caching_enabled:
@@ -471,7 +504,8 b' class RepoPullRequestsView(RepoAppView, '
471 504 and len(cached_diff.get('commits', [])) == 5
472 505 and cached_diff.get('commits')[0]
473 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 509 diff_commit_cache = \
476 510 (ancestor_commit, commit_cache, missing_requirements,
477 511 source_commit, target_commit) = cached_diff['commits']
@@ -546,8 +580,41 b' class RepoPullRequestsView(RepoAppView, '
546 580 c.deleted_files_comments[fname]['stats'] = 0
547 581 c.deleted_files_comments[fname]['comments'] = list()
548 582 for lno, comments in per_line_comments.items():
549 c.deleted_files_comments[fname]['comments'].extend(
550 comments)
583 c.deleted_files_comments[fname]['comments'].extend(comments)
584
585 # maybe calculate the range diff
586 if c.range_diff_on:
587 # TODO(marcink): set whitespace/context
588 context_lcl = 3
589 ign_whitespace_lcl = False
590
591 for commit in c.commit_ranges:
592 commit2 = commit
593 commit1 = commit.first_parent
594
595 range_diff_cache_file_path = diff_cache_exist(
596 cache_path, 'diff', commit.raw_id,
597 ign_whitespace_lcl, context_lcl, c.fulldiff)
598
599 cached_diff = None
600 if caching_enabled:
601 cached_diff = load_cached_diff(range_diff_cache_file_path)
602
603 has_proper_diff_cache = cached_diff and cached_diff.get('diff')
604 if not force_recache and has_proper_diff_cache:
605 diffset = cached_diff['diff']
606 else:
607 diffset = self._get_range_diffset(
608 source_scm, source_repo,
609 commit1, commit2, diff_limit, file_limit,
610 c.fulldiff, ign_whitespace_lcl, context_lcl
611 )
612
613 # save cached diff
614 if caching_enabled:
615 cache_diff(range_diff_cache_file_path, diffset, None)
616
617 c.changes[commit.raw_id] = diffset
551 618
552 619 # this is a hack to properly display links, when creating PR, the
553 620 # compare view and others uses different notation, and
@@ -607,7 +674,7 b' class RepoPullRequestsView(RepoAppView, '
607 674 commit_cache = collections.OrderedDict()
608 675 missing_requirements = False
609 676 try:
610 pre_load = ["author", "branch", "date", "message"]
677 pre_load = ["author", "branch", "date", "message", "parents"]
611 678 show_revs = pull_request_at_ver.revisions
612 679 for rev in show_revs:
613 680 comm = commits_source_repo.get_commit(
@@ -469,6 +469,13 b' class DiffSet(object):'
469 469
470 470 source_file = self.source_nodes.get(source_filename, source_filename)
471 471 target_file = self.target_nodes.get(target_filename, target_filename)
472 raw_id_uid = ''
473 if self.source_nodes.get(source_filename):
474 raw_id_uid = self.source_nodes[source_filename].commit.raw_id
475
476 if not raw_id_uid and self.target_nodes.get(target_filename):
477 # in case this is a new file we only have it in target
478 raw_id_uid = self.target_nodes[target_filename].commit.raw_id
472 479
473 480 source_filenode, target_filenode = None, None
474 481
@@ -512,7 +519,9 b' class DiffSet(object):'
512 519 'hunks': [],
513 520 'hunk_ops': None,
514 521 'diffset': self,
522 'raw_id': raw_id_uid,
515 523 })
524
516 525 file_chunks = patch['chunks'][1:]
517 526 for hunk in file_chunks:
518 527 hunkbit = self.parse_hunk(hunk, source_file, target_file)
@@ -821,6 +821,13 b' class BaseCommit(object):'
821 821 """
822 822 raise NotImplementedError
823 823
824 @LazyProperty
825 def first_parent(self):
826 """
827 Returns list of parent commits.
828 """
829 return self.parents[0] if self.parents else EmptyCommit()
830
824 831 @property
825 832 def merge(self):
826 833 """
@@ -1099,8 +1106,7 b' class BaseCommit(object):'
1099 1106 """
1100 1107 Returns a `Diff` object representing the change made by this commit.
1101 1108 """
1102 parent = (
1103 self.parents[0] if self.parents else self.repository.EMPTY_COMMIT)
1109 parent = self.first_parent
1104 1110 diff = self.repository.get_diff(
1105 1111 parent, self,
1106 1112 ignore_whitespace=ignore_whitespace,
@@ -47,7 +47,7 b" return '%s_%s_%i' % (h.safeid(filename),"
47 47 deleted_files_comments=None,
48 48
49 49 # for cache purpose
50 inline_comments=None
50 inline_comments=None,
51 51
52 52 )">
53 53 %if use_comments:
@@ -118,7 +118,7 b' collapse_all = len(diffset.files) > coll'
118 118 <h2 class="clearinner">
119 119 ## invidual commit
120 120 % if commit:
121 <a class="tooltip revision" title="${h.tooltip(commit.message)}" href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=commit.raw_id)}">${('r%s:%s' % (commit.idx,h.short_id(commit.raw_id)))}</a> -
121 <a class="tooltip revision" title="${h.tooltip(commit.message)}" href="${h.route_path('repo_commit',repo_name=diffset.repo_name,commit_id=commit.raw_id)}">${('r%s:%s' % (commit.idx,h.short_id(commit.raw_id)))}</a> -
122 122 ${h.age_component(commit.date)}
123 123 % if diffset.limited_diff:
124 124 - ${_('The requested commit is too big and content was truncated.')}
@@ -158,7 +158,7 b' collapse_all = len(diffset.files) > coll'
158 158 <div
159 159 class="filediff"
160 160 data-f-path="${filediff.patch['filename']}"
161 id="a_${h.FID('', filediff.patch['filename'])}"
161 id="a_${h.FID(filediff.raw_id, filediff.patch['filename'])}"
162 162 >
163 163
164 164 <label for="filediff-collapse-${id(filediff)}" class="filediff-heading">
@@ -290,7 +290,7 b' collapse_all = len(diffset.files) > coll'
290 290 %>
291 291 <div class="filediffs filediff-outdated" style="${display_state}">
292 292 <input ${(collapse_all and 'checked' or '')} class="filediff-collapse-state" id="filediff-collapse-${id(filename)}" type="checkbox">
293 <div class="filediff" data-f-path="${filename}" id="a_${h.FID('', filename)}">
293 <div class="filediff" data-f-path="${filename}" id="a_${h.FID(filediff.raw_id, filename)}">
294 294 <label for="filediff-collapse-${id(filename)}" class="filediff-heading">
295 295 <div class="filediff-collapse-indicator"></div>
296 296 <span class="pill">
@@ -301,7 +301,7 b' collapse_all = len(diffset.files) > coll'
301 301 ## file op, doesn't need translation
302 302 <span class="pill" op="removed">removed in this version</span>
303 303 </span>
304 <a class="pill filediff-anchor" href="#a_${h.FID('', filename)}">ΒΆ</a>
304 <a class="pill filediff-anchor" href="#a_${h.FID(filediff.raw_id, filename)}">ΒΆ</a>
305 305 <span class="pill-group" style="float: right">
306 306 <span class="pill" op="deleted">-${comments_dict['stats']}</span>
307 307 </span>
@@ -384,7 +384,7 b' from rhodecode.lib.diffs import NEW_FILE'
384 384 <i style="color: #aaa" class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${final_path}" title="${_('Copy the full path')}" onclick="return false;"></i>
385 385 </span>
386 386 ## anchor link
387 <a class="pill filediff-anchor" href="#a_${h.FID('', filediff.patch['filename'])}">ΒΆ</a>
387 <a class="pill filediff-anchor" href="#a_${h.FID(filediff.raw_id, filediff.patch['filename'])}">ΒΆ</a>
388 388
389 389 <span class="pill-group" style="float: right">
390 390
@@ -493,10 +493,10 b' from rhodecode.lib.diffs import NEW_FILE'
493 493
494 494 ## TODO: dan: refactor ignorews_url and context_url into the diff renderer same as diffmode=unified/sideside. Also use ajax to load more context (by clicking hunks)
495 495 %if hasattr(c, 'ignorews_url'):
496 ${c.ignorews_url(request, h.FID('', filediff.patch['filename']))}
496 ${c.ignorews_url(request, h.FID(filediff.raw_id, filediff.patch['filename']))}
497 497 %endif
498 498 %if hasattr(c, 'context_url'):
499 ${c.context_url(request, h.FID('', filediff.patch['filename']))}
499 ${c.context_url(request, h.FID(filediff.raw_id, filediff.patch['filename']))}
500 500 %endif
501 501
502 502 %if use_comments:
@@ -721,7 +721,7 b' def get_comments_for(diff_type, comments'
721 721 <td>unknown diff mode</td>
722 722 </tr>
723 723 % endif
724 </%def>
724 </%def>file changes
725 725
726 726
727 727 <%def name="render_add_comment_button()">
@@ -730,7 +730,7 b' def get_comments_for(diff_type, comments'
730 730 </button>
731 731 </%def>
732 732
733 <%def name="render_diffset_menu(diffset=None)">
733 <%def name="render_diffset_menu(diffset=None, range_diff_on=None)">
734 734
735 735 <div class="diffset-menu clearinner">
736 736 <div class="pull-right">
@@ -747,6 +747,21 b' def get_comments_for(diff_type, comments'
747 747 title="${h.tooltip(_('View unified'))}" href="${h.current_route_path(request, diffmode='unified')}">
748 748 <span>${_('Unified')}</span>
749 749 </a>
750 % if range_diff_on is True:
751 <a
752 title="${_('Turn off: Show the diff as commit range')}"
753 class="btn btn-primary"
754 href="${h.current_route_path(request, **{"range-diff":"0"})}">
755 <span>${_('Range Diff')}</span>
756 </a>
757 % elif range_diff_on is False:
758 <a
759 title="${_('Show the diff as commit range')}"
760 class="btn"
761 href="${h.current_route_path(request, **{"range-diff":"1"})}">
762 <span>${_('Range Diff')}</span>
763 </a>
764 % endif
750 765 </div>
751 766 </div>
752 767
@@ -834,7 +849,7 b' def get_comments_for(diff_type, comments'
834 849 var preloadData = {
835 850 results: [
836 851 % for filediff in diffset.files:
837 {id:"a_${h.FID('', filediff.patch['filename'])}",
852 {id:"a_${h.FID(filediff.raw_id, filediff.patch['filename'])}",
838 853 text:"${filediff.patch['filename']}",
839 854 ops:${h.json.dumps(filediff.patch['stats'])|n}}${('' if loop.last else ',')}
840 855 % endfor
@@ -448,16 +448,6 b''
448 448 onclick="$('.compare_select').hide();$('.compare_select_hidden').show(); return false">
449 449 ${_ungettext('Collapse %s commit','Collapse %s commits', len(c.commit_ranges)) % len(c.commit_ranges)}
450 450 </a>
451 <%
452 range_commit_id = '{}...{}'.format(c.commit_ranges[-1].raw_id, c.commit_ranges[0].raw_id)
453 %>
454 <a
455 class="btn"
456 href="${request.route_path('repo_commit', repo_name=c.source_repo.repo_name, commit_id=range_commit_id)}"
457 >
458 ${_('Show range diff')}
459 </a>
460
461 451 </div>
462 452 </div>
463 453
@@ -578,13 +568,28 b''
578 568
579 569 <div class="cs_files">
580 570 <%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/>
581 ${cbdiffs.render_diffset_menu(c.diffset)}
582 ${cbdiffs.render_diffset(
583 c.diffset, use_comments=True,
584 collapse_when_files_over=30,
585 disable_new_comments=not c.allowed_to_comment,
586 deleted_files_comments=c.deleted_files_comments,
587 inline_comments=c.inline_comments)}
571
572 ${cbdiffs.render_diffset_menu(c.diffset, range_diff_on=c.range_diff_on)}
573
574 % if c.range_diff_on:
575 % for commit in c.commit_ranges:
576 ${cbdiffs.render_diffset(
577 c.changes[commit.raw_id],
578 commit=commit, use_comments=True,
579 collapse_when_files_over=5,
580 disable_new_comments=True,
581 deleted_files_comments=c.deleted_files_comments,
582 inline_comments=c.inline_comments)}
583 % endfor
584 % else:
585 ${cbdiffs.render_diffset(
586 c.diffset, use_comments=True,
587 collapse_when_files_over=30,
588 disable_new_comments=not c.allowed_to_comment,
589 deleted_files_comments=c.deleted_files_comments,
590 inline_comments=c.inline_comments)}
591 % endif
592
588 593 </div>
589 594 % else:
590 595 ## skipping commits we need to clear the view for missing commits
General Comments 0
You need to be logged in to leave comments. Login now