diff --git a/kallithea/config/routing.py b/kallithea/config/routing.py --- a/kallithea/config/routing.py +++ b/kallithea/config/routing.py @@ -675,7 +675,7 @@ def make_map(config): conditions=dict(function=check_repo)) rmap.connect('compare_url', - '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}', + '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref_name:.*?}...{other_ref_type}@{other_ref_name:.*?}', controller='compare', action='compare', conditions=dict(function=check_repo), requirements=dict( diff --git a/kallithea/controllers/compare.py b/kallithea/controllers/compare.py --- a/kallithea/controllers/compare.py +++ b/kallithea/controllers/compare.py @@ -191,18 +191,18 @@ class CompareController(BaseRepoControll other_repo = request.GET.get('other_repo', org_repo) c.org_repo = Repository.get_by_repo_name(org_repo) c.other_repo = Repository.get_by_repo_name(other_repo) - c.org_ref = c.other_ref = _('Select changeset') + c.org_ref_name = c.other_ref_name = _('Select changeset') return render('compare/compare_diff.html') @LoginRequired() @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin') - def compare(self, repo_name, org_ref_type, org_ref, other_ref_type, other_ref): + def compare(self, repo_name, org_ref_type, org_ref_name, other_ref_type, other_ref_name): # org_ref will be evaluated in org_repo org_repo = c.db_repo.repo_name - org_ref = (org_ref_type, org_ref) + org_ref = (org_ref_type, org_ref_name) # other_ref will be evaluated in other_repo - other_ref = (other_ref_type, other_ref) + other_ref = (other_ref_type, other_ref_name) other_repo = request.GET.get('other_repo', org_repo) # If merge is True: # Show what org would get if merged with other: @@ -222,9 +222,9 @@ class CompareController(BaseRepoControll # swap url for compare_diff page - never partial and never as_form c.swap_url = h.url('compare_url', repo_name=other_repo, - org_ref_type=other_ref[0], org_ref=other_ref[1], + org_ref_type=other_ref_type, org_ref_name=other_ref_name, other_repo=org_repo, - other_ref_type=org_ref[0], other_ref=org_ref[1], + other_ref_type=org_ref_type, other_ref_name=org_ref_name, merge=merge or '') org_repo = Repository.get_by_repo_name(org_repo) @@ -248,20 +248,20 @@ class CompareController(BaseRepoControll h.flash(msg, category='error') return redirect(url('compare_home', repo_name=c.repo_name)) - org_rev = self.__get_rev_or_redirect(ref=org_ref, repo=org_repo, partial=partial) - other_rev = self.__get_rev_or_redirect(ref=other_ref, repo=other_repo, partial=partial) + c.org_rev = self.__get_rev_or_redirect(ref=org_ref, repo=org_repo, partial=partial) + c.other_rev = self.__get_rev_or_redirect(ref=other_ref, repo=other_repo, partial=partial) c.compare_home = False c.org_repo = org_repo c.other_repo = other_repo - c.org_ref = org_ref[1] - c.other_ref = other_ref[1] - c.org_ref_type = org_ref[0] - c.other_ref_type = other_ref[0] + c.org_ref_name = org_ref_name + c.other_ref_name = other_ref_name + c.org_ref_type = org_ref_type + c.other_ref_type = other_ref_type c.cs_ranges, c.ancestor = self._get_changesets( - org_repo.scm_instance.alias, org_repo.scm_instance, org_rev, - other_repo.scm_instance, other_rev, merge) + org_repo.scm_instance.alias, org_repo.scm_instance, c.org_rev, + other_repo.scm_instance, c.other_rev, merge) c.statuses = c.db_repo.statuses( [x.raw_id for x in c.cs_ranges]) @@ -274,18 +274,20 @@ class CompareController(BaseRepoControll assert merge # case we want a simple diff without incoming changesets, # previewing what will be merged. - # 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' - % (c.ancestor, org_ref)) - org_rev = c.ancestor + # Make the diff on the other repo (which is known to have other_rev) + log.debug('Using ancestor %s as rev1 instead of %s' + % (c.ancestor, c.org_rev)) + rev1 = c.ancestor org_repo = other_repo + else: # comparing tips, not necessarily linearly related + rev1 = c.org_rev diff_limit = self.cut_off_limit if not c.fulldiff else None log.debug('running diff between %s and %s in %s' - % (org_rev, other_rev, org_repo.scm_instance.path)) + % (rev1, c.other_rev, org_repo.scm_instance.path)) + txtdiff = org_repo.scm_instance.get_diff(rev1=rev1, rev2=c.other_rev) - txtdiff = org_repo.scm_instance.get_diff(rev1=org_rev, rev2=other_rev) diff_processor = diffs.DiffProcessor(txtdiff or '', format='gitdiff', diff_limit=diff_limit) _parsed = diff_processor.prepare() diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -179,41 +179,27 @@ class PullrequestsController(BaseRepoCon :param pull_request: """ - org_repo = pull_request.org_repo - (org_ref_type, - org_ref_name, - org_ref_rev) = pull_request.org_ref.split(':') - - other_repo = org_repo - (other_ref_type, - other_ref_name, - other_ref_rev) = pull_request.other_ref.split(':') - - # despite opening revisions for bookmarks/branches/tags, we always - # convert this to rev to prevent changes after bookmark or branch change - org_ref = ('rev', org_ref_rev) - other_ref = ('rev', other_ref_rev) + c.org_repo = pull_request.org_repo + (c.org_ref_type, + c.org_ref_name, + c.org_rev) = pull_request.org_ref.split(':') - c.org_repo = org_repo - c.other_repo = other_repo - - c.fulldiff = fulldiff = request.GET.get('fulldiff') - - c.cs_ranges = [org_repo.get_changeset(x) for x in pull_request.revisions] + c.other_repo = c.org_repo + (c.other_ref_type, + c.other_ref_name, + c.other_rev) = pull_request.other_ref.split(':') - c.statuses = org_repo.statuses([x.raw_id for x in c.cs_ranges]) + c.cs_ranges = [c.org_repo.get_changeset(x) for x in pull_request.revisions] - c.org_ref = org_ref[1] - c.org_ref_type = org_ref[0] - c.other_ref = other_ref[1] - c.other_ref_type = other_ref[0] + c.statuses = c.org_repo.statuses([x.raw_id for x in c.cs_ranges]) - diff_limit = self.cut_off_limit if not fulldiff else None + c.fulldiff = request.GET.get('fulldiff') + diff_limit = self.cut_off_limit if not c.fulldiff else None # we swap org/other ref since we run a simple diff on one repo log.debug('running diff between %s and %s in %s' - % (other_ref, org_ref, org_repo.scm_instance.path)) - txtdiff = org_repo.scm_instance.get_diff(rev1=safe_str(other_ref[1]), rev2=safe_str(org_ref[1])) + % (c.other_rev, c.org_rev, c.org_repo.scm_instance.path)) + txtdiff = c.org_repo.scm_instance.get_diff(rev1=safe_str(c.other_rev), rev2=safe_str(c.org_rev)) diff_processor = diffs.DiffProcessor(txtdiff or '', format='gitdiff', diff_limit=diff_limit) diff --git a/kallithea/templates/base/base.html b/kallithea/templates/base/base.html --- a/kallithea/templates/base/base.html +++ b/kallithea/templates/base/base.html @@ -167,7 +167,7 @@
  • ${_('Settings')}
  • %endif %if c.db_repo.fork: -
  • +
  • ${_('Compare fork')}
  • %endif
  • ${_('Compare')}
  • diff --git a/kallithea/templates/bookmarks/bookmarks.html b/kallithea/templates/bookmarks/bookmarks.html --- a/kallithea/templates/bookmarks/bookmarks.html +++ b/kallithea/templates/bookmarks/bookmarks.html @@ -40,7 +40,7 @@ YUE.on('compare_bookmarks','click',funct var other = YUQ('input[name=compare_other]:checked')[0]; if(org && other){ - var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='book',org_ref='__ORG__',other_ref_type='book',other_ref='__OTHER__')}"; + var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='book',org_ref_name='__ORG__',other_ref_type='book',other_ref_name='__OTHER__')}"; var u = compare_url.replace('__ORG__',org.value) .replace('__OTHER__',other.value); window.location=u; diff --git a/kallithea/templates/branches/branches.html b/kallithea/templates/branches/branches.html --- a/kallithea/templates/branches/branches.html +++ b/kallithea/templates/branches/branches.html @@ -39,7 +39,7 @@ YUE.on('compare_branches','click',functi var other = YUQ('input[name=compare_other]:checked')[0]; if(org && other){ - var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref='__ORG__',other_ref_type='branch',other_ref='__OTHER__')}"; + var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref_name='__ORG__',other_ref_type='branch',other_ref_name='__OTHER__')}"; var u = compare_url.replace('__ORG__',org.value) .replace('__OTHER__',other.value); window.location=u; diff --git a/kallithea/templates/changelog/changelog.html b/kallithea/templates/changelog/changelog.html --- a/kallithea/templates/changelog/changelog.html +++ b/kallithea/templates/changelog/changelog.html @@ -52,7 +52,7 @@ ${self.repo_context_bar('changelog', c.f %if c.db_repo.fork: ${_('Compare fork with parent repo (%s)' % c.db_repo.fork.repo_name)} %endif ## text and href of open_new_pr is controlled from javascript diff --git a/kallithea/templates/changeset/changeset_range.html b/kallithea/templates/changeset/changeset_range.html --- a/kallithea/templates/changeset/changeset_range.html +++ b/kallithea/templates/changeset/changeset_range.html @@ -33,7 +33,7 @@ ${self.repo_context_bar('changelog')} r${c.cs_ranges[0].revision}:${h.short_id(c.cs_ranges[0].raw_id)} r${c.cs_ranges[-1].revision}:${h.short_id(c.cs_ranges[-1].raw_id)} - Compare Revisions + Compare Revisions diff --git a/kallithea/templates/changeset/diff_block.html b/kallithea/templates/changeset/diff_block.html --- a/kallithea/templates/changeset/diff_block.html +++ b/kallithea/templates/changeset/diff_block.html @@ -59,13 +59,13 @@
    ${h.safe_unicode(filenode_path)} | - ${c.org_ref_type}@${h.short_id(c.org_ref) if c.org_ref_type=='rev' else c.org_ref} + ${c.org_ref_type}@${h.short_id(c.org_ref_name) if c.org_ref_type=='rev' else c.org_ref_name} - ${c.other_ref_type}@${h.short_id(c.other_ref) if c.other_ref_type=='rev' else c.other_ref} + ${c.other_ref_type}@${h.short_id(c.other_ref_name) if c.other_ref_type=='rev' else c.other_ref_name}
    %if c.other_repo.repo_name == c.repo_name: - + %endif diff --git a/kallithea/templates/compare/compare_diff.html b/kallithea/templates/compare/compare_diff.html --- a/kallithea/templates/compare/compare_diff.html +++ b/kallithea/templates/compare/compare_diff.html @@ -5,7 +5,7 @@ %if c.compare_home: ${_('%s Compare') % c.repo_name} %else: - ${_('%s Compare') % c.repo_name} - ${'%s@%s' % (c.org_repo.repo_name, c.org_ref)} > ${'%s@%s' % (c.other_repo.repo_name, c.other_ref)} + ${_('%s Compare') % c.repo_name} - ${'%s@%s' % (c.org_repo.repo_name, c.org_ref_name)} > ${'%s@%s' % (c.other_repo.repo_name, c.other_ref_name)} %endif %if c.site_name: · ${c.site_name} @@ -93,7 +93,7 @@ ${self.repo_context_bar('changelog')} $(document).ready(function(){ var cache = {} $("#compare_org").select2({ - placeholder: "${'%s@%s' % (c.org_repo.repo_name, c.org_ref)}", + placeholder: "${'%s@%s' % (c.org_repo.repo_name, c.org_ref_name)}", formatSelection: function(obj){ return '{0}@{1}'.format("${c.org_repo.repo_name}", obj.text) }, @@ -133,7 +133,7 @@ ${self.repo_context_bar('changelog')} }, }); $("#compare_other").select2({ - placeholder: "${'%s@%s' % (c.other_repo.repo_name, c.other_ref)}", + placeholder: "${'%s@%s' % (c.other_repo.repo_name, c.other_ref_name)}", dropdownAutoWidth: true, formatSelection: function(obj){ return '{0}@{1}'.format("${c.other_repo.repo_name}", obj.text) @@ -177,7 +177,7 @@ ${self.repo_context_bar('changelog')} var org = $('#compare_org').select2('data'); var other = $('#compare_other').select2('data'); - var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='__other_ref_type__',org_ref='__org__',other_ref_type='__org_ref_type__',other_ref='__other__', other_repo=c.other_repo.repo_name)}"; + var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='__other_ref_type__',org_ref_name='__org__',other_ref_type='__org_ref_type__',other_ref_name='__other__', other_repo=c.other_repo.repo_name)}"; var u = compare_url.replace('__other_ref_type__',org.type) .replace('__org__',org.text) .replace('__org_ref_type__',other.type) diff --git a/kallithea/templates/forks/forks_data.html b/kallithea/templates/forks/forks_data.html --- a/kallithea/templates/forks/forks_data.html +++ b/kallithea/templates/forks/forks_data.html @@ -17,7 +17,7 @@
    ${_('Forked')} - ${h.age(f.created_on)} ${_('Compare fork')}
    diff --git a/kallithea/templates/pullrequests/pullrequest.html b/kallithea/templates/pullrequests/pullrequest.html --- a/kallithea/templates/pullrequests/pullrequest.html +++ b/kallithea/templates/pullrequests/pullrequest.html @@ -171,11 +171,11 @@ ${self.repo_context_bar('showpullrequest //url template var url = "${h.url('compare_url', repo_name='__other_repo__', - org_ref_type='__other_ref_type__', - org_ref='__other_ref__', + org_ref_type='rev', + org_ref_name='__other_ref_name__', other_repo='__org_repo__', - other_ref_type='__org_ref_type__', - other_ref='__org_ref__', + other_ref_type='rev', + other_ref_name='__org_ref_name__', as_form=True, merge=True, )}"; @@ -187,16 +187,14 @@ ${self.repo_context_bar('showpullrequest var select_refs = YUQ('#pull_request_form select.refs') var rev_data = { - 'org_repo': org_repo, - 'org_ref': org_ref[2], - 'org_ref_type': 'rev', - 'other_repo': other_repo, - 'other_ref': other_ref[2], - 'other_ref_type': 'rev', + '__org_repo__': org_repo, + '__org_ref_name__': org_ref[2], + '__other_repo__': other_repo, + '__other_ref_name__': other_ref[2], }; // gather the org/other ref and repo here for (k in rev_data){ - url = url.replace('__'+k+'__',rev_data[k]); + url = url.replace(k,rev_data[k]); } YUD.get('pull_request_overview').innerHTML = "${_('Loading ...')}"; diff --git a/kallithea/templates/pullrequests/pullrequest_show.html b/kallithea/templates/pullrequests/pullrequest_show.html --- a/kallithea/templates/pullrequests/pullrequest_show.html +++ b/kallithea/templates/pullrequests/pullrequest_show.html @@ -72,7 +72,7 @@ ${self.repo_context_bar('showpullrequest ${c.pull_request.org_repo.clone_url()} ## branch link is only valid if it is a branch - ${c.pull_request.org_ref_parts[0]}: ${c.pull_request.org_ref_parts[1]} + ${c.org_ref_type}: ${c.org_ref_name}
    diff --git a/kallithea/templates/tags/tags.html b/kallithea/templates/tags/tags.html --- a/kallithea/templates/tags/tags.html +++ b/kallithea/templates/tags/tags.html @@ -39,7 +39,7 @@ YUE.on('compare_tags','click',function(e var other = YUQ('input[name=compare_other]:checked')[0]; if(org && other){ - var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='tag',org_ref='__ORG__',other_ref_type='tag',other_ref='__OTHER__')}"; + var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='tag',org_ref_name='__ORG__',other_ref_type='tag',other_ref_name='__OTHER__')}"; var u = compare_url.replace('__ORG__',org.value) .replace('__OTHER__',other.value); window.location=u; diff --git a/kallithea/tests/functional/test_compare.py b/kallithea/tests/functional/test_compare.py --- a/kallithea/tests/functional/test_compare.py +++ b/kallithea/tests/functional/test_compare.py @@ -86,10 +86,10 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=repo1.repo_name, org_ref_type="branch", - org_ref=rev2, + org_ref_name=rev2, other_repo=repo2.repo_name, other_ref_type="branch", - other_ref=rev1, + other_ref_name=rev1, merge='1',)) response.mustcontain('%s@%s' % (repo1.repo_name, rev2)) @@ -134,10 +134,10 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=repo1.repo_name, org_ref_type="branch", - org_ref=rev2, + org_ref_name=rev2, other_repo=repo2.repo_name, other_ref_type="branch", - other_ref=rev1, + other_ref_name=rev1, merge='1',)) response.mustcontain('%s@%s' % (repo1.repo_name, rev2)) @@ -189,10 +189,10 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=repo1.repo_name, org_ref_type="branch", - org_ref=rev2, + org_ref_name=rev2, other_repo=repo2.repo_name, other_ref_type="branch", - other_ref=rev1, + other_ref_name=rev1, merge='1',)) response.mustcontain('%s@%s' % (repo1.repo_name, rev2)) @@ -244,10 +244,10 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=repo1.repo_name, org_ref_type="branch", - org_ref=rev2, + org_ref_name=rev2, other_repo=repo2.repo_name, other_ref_type="branch", - other_ref=rev1, + other_ref_name=rev1, merge='1',)) response.mustcontain('%s@%s' % (repo1.repo_name, rev2)) @@ -307,10 +307,10 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=repo2.repo_name, org_ref_type="rev", - org_ref=cs1.short_id, # parent of cs2, in repo2 + org_ref_name=cs1.short_id, # parent of cs2, in repo2 other_repo=repo1.repo_name, other_ref_type="rev", - other_ref=cs4.short_id, + other_ref_name=cs4.short_id, merge='True', )) response.mustcontain('%s@%s' % (repo2.repo_name, cs1.short_id)) @@ -369,9 +369,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=repo1.repo_name, org_ref_type="rev", - org_ref=cs2.short_id, # parent of cs3, not in repo2 + org_ref_name=cs2.short_id, # parent of cs3, not in repo2 other_ref_type="rev", - other_ref=cs5.short_id, + other_ref_name=cs5.short_id, merge='1',)) response.mustcontain('%s@%s' % (repo1.repo_name, cs2.short_id)) @@ -404,9 +404,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=HG_REPO, org_ref_type="rev", - org_ref=rev1, + org_ref_name=rev1, other_ref_type="rev", - other_ref=rev2, + other_ref_name=rev2, other_repo=HG_FORK, merge='1',)) @@ -434,9 +434,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=GIT_REPO, org_ref_type="rev", - org_ref=rev1, + org_ref_name=rev1, other_ref_type="rev", - other_ref=rev2, + other_ref_name=rev2, other_repo=GIT_FORK, merge='1',)) @@ -500,9 +500,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=r2_name, org_ref_type="branch", - org_ref=rev1, + org_ref_name=rev1, other_ref_type="branch", - other_ref=rev2, + other_ref_name=rev2, other_repo=r1_name, merge='1',)) @@ -521,9 +521,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=r2_name, org_ref_type="branch", - org_ref=rev1, + org_ref_name=rev1, other_ref_type="branch", - other_ref=rev2, + other_ref_name=rev2, other_repo=r1_name, merge='1', )) @@ -582,9 +582,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=r2_name, org_ref_type="branch", - org_ref=rev1, + org_ref_name=rev1, other_ref_type="branch", - other_ref=rev2, + other_ref_name=rev2, other_repo=r1_name, merge='1',)) @@ -603,9 +603,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=r2_name, org_ref_type="branch", - org_ref=rev1, + org_ref_name=rev1, other_ref_type="branch", - other_ref=rev2, + other_ref_name=rev2, other_repo=r1_name, merge='1', )) diff --git a/kallithea/tests/functional/test_compare_local.py b/kallithea/tests/functional/test_compare_local.py --- a/kallithea/tests/functional/test_compare_local.py +++ b/kallithea/tests/functional/test_compare_local.py @@ -10,9 +10,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=HG_REPO, org_ref_type="tag", - org_ref=tag1, + org_ref_name=tag1, other_ref_type="tag", - other_ref=tag2, + other_ref_name=tag2, ), status=200) response.mustcontain('%s@%s' % (HG_REPO, tag1)) response.mustcontain('%s@%s' % (HG_REPO, tag2)) @@ -48,9 +48,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=GIT_REPO, org_ref_type="tag", - org_ref=tag1, + org_ref_name=tag1, other_ref_type="tag", - other_ref=tag2, + other_ref_name=tag2, ), status=200) response.mustcontain('%s@%s' % (GIT_REPO, tag1)) response.mustcontain('%s@%s' % (GIT_REPO, tag2)) @@ -84,9 +84,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=HG_REPO, org_ref_type="branch", - org_ref='default', + org_ref_name='default', other_ref_type="branch", - other_ref='default', + other_ref_name='default', )) response.mustcontain('%s@default' % (HG_REPO)) @@ -100,9 +100,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=GIT_REPO, org_ref_type="branch", - org_ref='master', + org_ref_name='master', other_ref_type="branch", - other_ref='master', + other_ref_name='master', )) response.mustcontain('%s@master' % (GIT_REPO)) @@ -119,9 +119,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=HG_REPO, org_ref_type="rev", - org_ref=rev1, + org_ref_name=rev1, other_ref_type="rev", - other_ref=rev2, + other_ref_name=rev2, )) response.mustcontain('%s@%s' % (HG_REPO, rev1)) response.mustcontain('%s@%s' % (HG_REPO, rev2)) @@ -141,9 +141,9 @@ class TestCompareController(TestControll response = self.app.get(url('compare_url', repo_name=GIT_REPO, org_ref_type="rev", - org_ref=rev1, + org_ref_name=rev1, other_ref_type="rev", - other_ref=rev2, + other_ref_name=rev2, )) response.mustcontain('%s@%s' % (GIT_REPO, rev1)) response.mustcontain('%s@%s' % (GIT_REPO, rev2))