diff --git a/rhodecode/controllers/compare.py b/rhodecode/controllers/compare.py --- a/rhodecode/controllers/compare.py +++ b/rhodecode/controllers/compare.py @@ -89,11 +89,17 @@ class CompareController(BaseRepoControll # other_ref will be evaluated in other_repo other_ref = (other_ref_type, other_ref) other_repo = request.GET.get('other_repo', org_repo) + # If merge is True: + # Show what org would get if merged with other: + # List changesets that are ancestors of other but not of org. + # New changesets in org is thus ignored. + # Diff will be from common ancestor, and merges of org to other will thus be ignored. + # If merge is False: + # Make a raw diff from org to other, no matter if related or not. + # Changesets in one and not in the other will be ignored + merge = bool(request.GET.get('merge')) # fulldiff disables cut_off_limit c.fulldiff = request.GET.get('fulldiff') - # only consider this range of changesets - rev_start = request.GET.get('rev_start') - rev_end = request.GET.get('rev_end') # partial uses compare_cs.html template directly partial = request.environ.get('HTTP_X_PARTIAL_XHR') # as_form puts hidden input field with changeset revisions @@ -103,7 +109,8 @@ class CompareController(BaseRepoControll repo_name=other_repo, org_ref_type=other_ref[0], org_ref=other_ref[1], other_repo=org_repo, - other_ref_type=org_ref[0], other_ref=org_ref[1]) + other_ref_type=org_ref[0], other_ref=org_ref[1], + merge=merge or '') org_repo = Repository.get_by_repo_name(org_repo) other_repo = Repository.get_by_repo_name(other_repo) @@ -133,37 +140,23 @@ class CompareController(BaseRepoControll c.org_ref_type = org_ref[0] c.other_ref_type = other_ref[0] - if rev_start and rev_end: - # swap revs with cherry picked ones, save them for display - #org_ref = ('rev', rev_start) - #other_ref = ('rev', rev_end) - c.org_ref = rev_start[:12] - c.other_ref = rev_end[:12] - # get parent of - # rev start to include it in the diff - _cs = other_repo.scm_instance.get_changeset(rev_start) - rev_start = _cs.parents[0].raw_id if _cs.parents else EmptyChangeset().raw_id - org_ref = ('rev', rev_start) - other_ref = ('rev', rev_end) - #if we cherry pick it's not remote, make the other_repo org_repo - org_repo = other_repo - - c.cs_ranges, ancestor = PullRequestModel().get_compare_data( - org_repo, org_ref, other_repo, other_ref) + c.cs_ranges, c.ancestor = PullRequestModel().get_compare_data( + org_repo, org_ref, other_repo, other_ref, merge) c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in c.cs_ranges]) if partial: + assert c.ancestor return render('compare/compare_cs.html') - if ancestor and org_repo != other_repo: + if c.ancestor: + assert merge # case we want a simple diff without incoming changesets, # previewing what will be merged. - # Make the diff on the forked repo, with - # revision that is common ancestor + # Make the diff on the other repo (which is known to have other_ref) log.debug('Using ancestor %s as org_ref instead of %s' - % (ancestor, org_ref)) - org_ref = ('rev', ancestor) + % (c.ancestor, org_ref)) + org_ref = ('rev', c.ancestor) org_repo = other_repo diff_limit = self.cut_off_limit if not c.fulldiff else None