##// END OF EJS Templates
commits: detect missing commits on diffsets from new PR ancestor logic....
marcink -
r4400:96b3ab25 stable
parent child Browse files
Show More
@@ -568,6 +568,7 b' class RepoPullRequestsView(RepoAppView, '
568 c.commit_ranges.append(comm)
568 c.commit_ranges.append(comm)
569
569
570 c.missing_requirements = missing_requirements
570 c.missing_requirements = missing_requirements
571
571 c.ancestor_commit = ancestor_commit
572 c.ancestor_commit = ancestor_commit
572 c.statuses = source_repo.statuses(
573 c.statuses = source_repo.statuses(
573 [x.raw_id for x in c.commit_ranges])
574 [x.raw_id for x in c.commit_ranges])
@@ -596,66 +597,71 b' class RepoPullRequestsView(RepoAppView, '
596 if not force_recache and has_proper_diff_cache:
597 if not force_recache and has_proper_diff_cache:
597 c.diffset = cached_diff['diff']
598 c.diffset = cached_diff['diff']
598 else:
599 else:
599 c.diffset = self._get_diffset(
600 try:
600 c.source_repo.repo_name, commits_source_repo,
601 c.diffset = self._get_diffset(
601 c.ancestor_commit,
602 c.source_repo.repo_name, commits_source_repo,
602 source_ref_id, target_ref_id,
603 c.ancestor_commit,
603 target_commit, source_commit,
604 source_ref_id, target_ref_id,
604 diff_limit, file_limit, c.fulldiff,
605 target_commit, source_commit,
605 hide_whitespace_changes, diff_context)
606 diff_limit, file_limit, c.fulldiff,
606
607 hide_whitespace_changes, diff_context)
607 # save cached diff
608 if caching_enabled:
609 cache_diff(cache_file_path, c.diffset, diff_commit_cache)
610
611 c.limited_diff = c.diffset.limited_diff
612
613 # calculate removed files that are bound to comments
614 comment_deleted_files = [
615 fname for fname in display_inline_comments
616 if fname not in c.diffset.file_stats]
617
618 c.deleted_files_comments = collections.defaultdict(dict)
619 for fname, per_line_comments in display_inline_comments.items():
620 if fname in comment_deleted_files:
621 c.deleted_files_comments[fname]['stats'] = 0
622 c.deleted_files_comments[fname]['comments'] = list()
623 for lno, comments in per_line_comments.items():
624 c.deleted_files_comments[fname]['comments'].extend(comments)
625
626 # maybe calculate the range diff
627 if c.range_diff_on:
628 # TODO(marcink): set whitespace/context
629 context_lcl = 3
630 ign_whitespace_lcl = False
631
632 for commit in c.commit_ranges:
633 commit2 = commit
634 commit1 = commit.first_parent
635
636 range_diff_cache_file_path = diff_cache_exist(
637 cache_path, 'diff', commit.raw_id,
638 ign_whitespace_lcl, context_lcl, c.fulldiff)
639
640 cached_diff = None
641 if caching_enabled:
642 cached_diff = load_cached_diff(range_diff_cache_file_path)
643
644 has_proper_diff_cache = cached_diff and cached_diff.get('diff')
645 if not force_recache and has_proper_diff_cache:
646 diffset = cached_diff['diff']
647 else:
648 diffset = self._get_range_diffset(
649 commits_source_repo, source_repo,
650 commit1, commit2, diff_limit, file_limit,
651 c.fulldiff, ign_whitespace_lcl, context_lcl
652 )
653
654 # save cached diff
608 # save cached diff
655 if caching_enabled:
609 if caching_enabled:
656 cache_diff(range_diff_cache_file_path, diffset, None)
610 cache_diff(cache_file_path, c.diffset, diff_commit_cache)
611 except CommitDoesNotExistError:
612 log.exception('Failed to generate diffset')
613 c.missing_commits = True
614
615 if not c.missing_commits:
616
617 c.limited_diff = c.diffset.limited_diff
618
619 # calculate removed files that are bound to comments
620 comment_deleted_files = [
621 fname for fname in display_inline_comments
622 if fname not in c.diffset.file_stats]
623
624 c.deleted_files_comments = collections.defaultdict(dict)
625 for fname, per_line_comments in display_inline_comments.items():
626 if fname in comment_deleted_files:
627 c.deleted_files_comments[fname]['stats'] = 0
628 c.deleted_files_comments[fname]['comments'] = list()
629 for lno, comments in per_line_comments.items():
630 c.deleted_files_comments[fname]['comments'].extend(comments)
631
632 # maybe calculate the range diff
633 if c.range_diff_on:
634 # TODO(marcink): set whitespace/context
635 context_lcl = 3
636 ign_whitespace_lcl = False
657
637
658 c.changes[commit.raw_id] = diffset
638 for commit in c.commit_ranges:
639 commit2 = commit
640 commit1 = commit.first_parent
641
642 range_diff_cache_file_path = diff_cache_exist(
643 cache_path, 'diff', commit.raw_id,
644 ign_whitespace_lcl, context_lcl, c.fulldiff)
645
646 cached_diff = None
647 if caching_enabled:
648 cached_diff = load_cached_diff(range_diff_cache_file_path)
649
650 has_proper_diff_cache = cached_diff and cached_diff.get('diff')
651 if not force_recache and has_proper_diff_cache:
652 diffset = cached_diff['diff']
653 else:
654 diffset = self._get_range_diffset(
655 commits_source_repo, source_repo,
656 commit1, commit2, diff_limit, file_limit,
657 c.fulldiff, ign_whitespace_lcl, context_lcl
658 )
659
660 # save cached diff
661 if caching_enabled:
662 cache_diff(range_diff_cache_file_path, diffset, None)
663
664 c.changes[commit.raw_id] = diffset
659
665
660 # this is a hack to properly display links, when creating PR, the
666 # this is a hack to properly display links, when creating PR, the
661 # compare view and others uses different notation, and
667 # compare view and others uses different notation, and
@@ -465,9 +465,9 b''
465 <div class="alert alert-warning">
465 <div class="alert alert-warning">
466 <div>
466 <div>
467 <strong>${_('Missing commits')}:</strong>
467 <strong>${_('Missing commits')}:</strong>
468 ${_('This pull request cannot be displayed, because one or more commits no longer exist in the source repository.')}
468 ${_('This pull request cannot be displayed, because one or more commits no longer exist in the source repository.')}<br/>
469 ${_('Please update this pull request, push the commits back into the source repository, or consider closing this pull request.')}
469 ${_('Please update this pull request, push the commits back into the source repository, or consider closing this pull request.')}<br/>
470 ${_('Consider doing a {force_refresh_url} in case you think this is an error.').format(force_refresh_url=h.link_to('force refresh', h.current_route_path(request, force_refresh='1')))|n}
470 ${_('Consider doing a `force update commits` in case you think this is an error.')}
471 </div>
471 </div>
472 </div>
472 </div>
473 </div>
473 </div>
General Comments 0
You need to be logged in to leave comments. Login now