diff --git a/kallithea/templates/changelog/changelog_table.html b/kallithea/templates/changelog/changelog_table.html --- a/kallithea/templates/changelog/changelog_table.html +++ b/kallithea/templates/changelog/changelog_table.html @@ -1,7 +1,8 @@ ## Render changelog table with id 'changesets' with the range of changesets, ## statuses, and comments. ## Optionally, pass a js snippet to run whenever a table resize is triggered. -<%def name="changelog(repo_name, cs_range, cs_statuses, cs_comments, show_checkbox=False, show_branch=True, resize_js='')"> +<%def name="changelog(repo_name, cs_range, cs_statuses, cs_comments, show_checkbox=False, show_branch=True, show_index=False, resize_js='')"> + <% num_cs = len(cs_range) %> %for cnt,cs in enumerate(cs_range): @@ -11,6 +12,22 @@ ${h.checkbox(cs.raw_id,class_="changeset_range")} %endif + %if show_index: + + %endif
+ <% + index = num_cs - cnt + if index == 1: + title = _('First (oldest) changeset in this list') + elif index == num_cs: + title = _('Last (most recent) changeset in this list') + else: + title = _('Position in this list of changesets') + %> + + ${index} + + %if cs_statuses.get(cs.raw_id): %if cs_statuses.get(cs.raw_id)[2]: diff --git a/kallithea/templates/compare/compare_cs.html b/kallithea/templates/compare/compare_cs.html --- a/kallithea/templates/compare/compare_cs.html +++ b/kallithea/templates/compare/compare_cs.html @@ -1,4 +1,5 @@ -## Changesets table ! +## Changesets table with graph +<%namespace name="changelog_table" file="/changelog/changelog_table.html"/>
%if not c.cs_ranges: ${_('No changesets')} @@ -28,68 +29,9 @@
- - - %for cnt, cs in enumerate(reversed(c.cs_ranges)): - - - - - - - - - - - %endfor -
- %if cs.raw_id in c.cs_statuses: - - %endif - %if c.cs_comments.get(cs.raw_id): - - %endif - - <% - num_cs = len(c.cs_ranges) - index = num_cs - cnt - if index == 1: - title = _('First (oldest) changeset in this list') - elif index == num_cs: - title = _('Last (most recent) changeset in this list') - else: - title = _('Position in this list of changesets') - %> - - ${index} - - ${cs.date} - ${h.gravatar(h.email_or_none(cs.author), size=16)} - ${h.person(cs.author)} - ${h.link_to(h.show_id(cs),h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id), class_='changeset_hash')} - %if cs.branch: - ${h.link_to(cs.branch,h.url('changelog_home',repo_name=c.cs_repo.repo_name,branch=cs.branch))} - %endif - - - -
- %for tag in cs.tags: - - ${h.link_to(tag,h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))} - - %endfor -
-
${h.urlify_text(cs.message, c.repo_name)}
-
- + ${changelog_table.changelog(c.cs_repo.repo_name, list(reversed(c.cs_ranges)), c.cs_statuses, c.cs_comments, + show_index=True, + resize_js='graph.render(jsdata)')}
%if c.is_ajax_preview: 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 @@ -6,8 +6,8 @@ from kallithea.tests.fixture import Fixt fixture = Fixture() -def _commit_ref(sha, msg): - return '''
%s
''' % msg +def _commit_ref(repo_name, sha, msg): + return '''''' % (repo_name, sha, msg) class TestCompareController(TestController): @@ -65,8 +65,8 @@ class TestCompareController(TestControll response.mustcontain("""Showing 2 commits""") response.mustcontain("""1 file changed with 2 insertions and 0 deletions""") - response.mustcontain(_commit_ref(cs1.raw_id, 'commit2')) - response.mustcontain(_commit_ref(cs2.raw_id, 'commit3')) + response.mustcontain(_commit_ref(repo2.repo_name, cs1.raw_id, 'commit2')) + response.mustcontain(_commit_ref(repo2.repo_name, cs2.raw_id, 'commit3')) response.mustcontain("""r1:%s""" % (repo2.repo_name, cs1.raw_id, cs1.short_id)) response.mustcontain("""r2:%s""" % (repo2.repo_name, cs2.raw_id, cs2.short_id)) @@ -116,8 +116,8 @@ class TestCompareController(TestControll response.mustcontain("""Showing 2 commits""") response.mustcontain("""1 file changed with 2 insertions and 0 deletions""") - response.mustcontain(_commit_ref(cs1.raw_id, 'commit2')) - response.mustcontain(_commit_ref(cs2.raw_id, 'commit3')) + response.mustcontain(_commit_ref(repo2.repo_name, cs1.raw_id, 'commit2')) + response.mustcontain(_commit_ref(repo2.repo_name, cs2.raw_id, 'commit3')) response.mustcontain("""r1:%s""" % (repo2.repo_name, cs1.raw_id, cs1.short_id)) response.mustcontain("""r2:%s""" % (repo2.repo_name, cs2.raw_id, cs2.short_id)) @@ -175,8 +175,8 @@ class TestCompareController(TestControll response.mustcontain("""Showing 2 commits""") response.mustcontain("""1 file changed with 2 insertions and 0 deletions""") - response.mustcontain(_commit_ref(cs1.raw_id, 'commit2')) - response.mustcontain(_commit_ref(cs2.raw_id, 'commit3')) + response.mustcontain(_commit_ref(repo2.repo_name, cs1.raw_id, 'commit2')) + response.mustcontain(_commit_ref(repo2.repo_name, cs2.raw_id, 'commit3')) response.mustcontain("""r1:%s""" % (repo2.repo_name, cs1.raw_id, cs1.short_id)) response.mustcontain("""r2:%s""" % (repo2.repo_name, cs2.raw_id, cs2.short_id)) @@ -234,8 +234,8 @@ class TestCompareController(TestControll response.mustcontain("""Showing 2 commits""") response.mustcontain("""1 file changed with 2 insertions and 0 deletions""") - response.mustcontain(_commit_ref(cs1.raw_id, 'commit2')) - response.mustcontain(_commit_ref(cs2.raw_id, 'commit3')) + response.mustcontain(_commit_ref(repo2.repo_name, cs1.raw_id, 'commit2')) + response.mustcontain(_commit_ref(repo2.repo_name, cs2.raw_id, 'commit3')) response.mustcontain("""r1:%s""" % (repo2.repo_name, cs1.raw_id, cs1.short_id)) response.mustcontain("""r2:%s""" % (repo2.repo_name, cs2.raw_id, cs2.short_id)) @@ -302,9 +302,9 @@ class TestCompareController(TestControll response.mustcontain("""Showing 3 commits""") response.mustcontain("""1 file changed with 3 insertions and 0 deletions""") - response.mustcontain(_commit_ref(cs2.raw_id, 'commit3')) - response.mustcontain(_commit_ref(cs3.raw_id, 'commit4')) - response.mustcontain(_commit_ref(cs4.raw_id, 'commit5')) + response.mustcontain(_commit_ref(repo1.repo_name, cs2.raw_id, 'commit3')) + response.mustcontain(_commit_ref(repo1.repo_name, cs3.raw_id, 'commit4')) + response.mustcontain(_commit_ref(repo1.repo_name, cs4.raw_id, 'commit5')) response.mustcontain("""r2:%s""" % (repo1.repo_name, cs2.raw_id, cs2.short_id)) response.mustcontain("""r3:%s""" % (repo1.repo_name, cs3.raw_id, cs3.short_id)) @@ -368,9 +368,9 @@ class TestCompareController(TestControll response.mustcontain("""Showing 3 commits""") response.mustcontain("""1 file changed with 3 insertions and 0 deletions""") - response.mustcontain(_commit_ref(cs3.raw_id, 'commit4')) - response.mustcontain(_commit_ref(cs4.raw_id, 'commit5')) - response.mustcontain(_commit_ref(cs5.raw_id, 'commit6')) + response.mustcontain(_commit_ref(repo1.repo_name, cs3.raw_id, 'commit4')) + response.mustcontain(_commit_ref(repo1.repo_name, cs4.raw_id, 'commit5')) + response.mustcontain(_commit_ref(repo1.repo_name, cs5.raw_id, 'commit6')) response.mustcontain("""r3:%s""" % (repo1.repo_name, cs3.raw_id, cs3.short_id)) response.mustcontain("""r4:%s""" % (repo1.repo_name, cs4.raw_id, cs4.short_id))