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 @@
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))