changeset 6850:00905ed03136

pullrequests: use shared changelog_table implementation It will show pretty much the same information as before, but in a different order.
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 28 Aug 2017 05:25:40 +0200
parents f92d08061a24
children 789de118156b
files kallithea/templates/changelog/changelog_table.html kallithea/templates/compare/compare_cs.html kallithea/tests/functional/test_compare.py
diffstat 3 files changed, 39 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/templates/changelog/changelog_table.html	Thu Nov 03 20:03:03 2016 +0100
+++ b/kallithea/templates/changelog/changelog_table.html	Mon Aug 28 05:25:40 2017 +0200
@@ -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) %>
     <table class="table" id="changesets">
     <tbody>
       %for cnt,cs in enumerate(cs_range):
@@ -11,6 +12,22 @@
           ${h.checkbox(cs.raw_id,class_="changeset_range")}
         </td>
         %endif
+        %if show_index:
+        <td class="changeset-logical-index">
+          <%
+              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')
+          %>
+          <span data-toggle="tooltip" title="${title}">
+            ${index}
+          </span>
+        </td>
+        %endif
         <td class="status">
           %if cs_statuses.get(cs.raw_id):
             %if cs_statuses.get(cs.raw_id)[2]:
--- a/kallithea/templates/compare/compare_cs.html	Thu Nov 03 20:03:03 2016 +0100
+++ b/kallithea/templates/compare/compare_cs.html	Mon Aug 28 05:25:40 2017 +0200
@@ -1,4 +1,5 @@
-## Changesets table !
+## Changesets table with graph
+<%namespace name="changelog_table" file="/changelog/changelog_table.html"/>
 <div>
   %if not c.cs_ranges:
     <span class="empty_data">${_('No changesets')}</span>
@@ -28,68 +29,9 @@
     </div>
 
     <div id="graph_content_pr">
-
-    <table class="table compare_view_commits">
-    %for cnt, cs in enumerate(reversed(c.cs_ranges)):
-      <tr id="chg_${cnt+1}" class="${'mergerow' if len(cs.parents) > 1 else ''}">
-        <td>
-          %if cs.raw_id in c.cs_statuses:
-              <i class="icon-circle changeset-status-${c.cs_statuses[cs.raw_id][0]}" title="${_('Changeset status: %s') % c.cs_statuses[cs.raw_id][1]}"></i>
-          %endif
-          %if c.cs_comments.get(cs.raw_id):
-              <div class="comments-container">
-                  <div class="comments-cnt" title="${_('Changeset has comments')}">
-                      <a href="${c.cs_comments[cs.raw_id][0].url()}">
-                          ${len(c.cs_comments[cs.raw_id])}
-                          <i class="icon-comment"></i>
-                      </a>
-                  </div>
-              </div>
-          %endif
-        </td>
-        <td class="changeset-logical-index">
-          <%
-              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')
-          %>
-          <span data-toggle="tooltip" title="${title}">
-            ${index}
-          </span>
-        </td>
-        <td><span data-toggle="tooltip" title="${h.age(cs.date)}">${cs.date}</span></td>
-        <td class="author">
-            ${h.gravatar(h.email_or_none(cs.author), size=16)}
-            <span data-toggle="tooltip" title="${cs.author}" class="user">${h.person(cs.author)}</span>
-        </td>
-        <td>${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')}</td>
-        <td>
-        %if cs.branch:
-        <span class="branchtag">${h.link_to(cs.branch,h.url('changelog_home',repo_name=c.cs_repo.repo_name,branch=cs.branch))}</span>
-        %endif
-        </td>
-        <td class="expand_commit" title="${_('Expand commit message')}">
-            <i class="icon-align-left"></i>
-        </td>
-        <td class="mid">
-            <div class="pull-right">
-                %for tag in cs.tags:
-                    <span class="tagtag" title="${_('Tag %s') % tag}">
-                        ${h.link_to(tag,h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}
-                    </span>
-                %endfor
-            </div>
-            <div class="message">${h.urlify_text(cs.message, c.repo_name)}</div>
-        </td>
-      </tr>
-    %endfor
-    </table>
-
+      ${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)')}
     </div>
 
     %if c.is_ajax_preview:
--- a/kallithea/tests/functional/test_compare.py	Thu Nov 03 20:03:03 2016 +0100
+++ b/kallithea/tests/functional/test_compare.py	Mon Aug 28 05:25:40 2017 +0200
@@ -6,8 +6,8 @@
 
 fixture = Fixture()
 
-def _commit_ref(sha, msg):
-    return '''<div class="message">%s</div>''' % msg
+def _commit_ref(repo_name, sha, msg):
+    return '''<div class="message-firstline"><a class="message-link" href="/%s/changeset/%s">%s</a></div>''' % (repo_name, sha, msg)
 
 
 class TestCompareController(TestController):
@@ -65,8 +65,8 @@
         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("""<a class="changeset_hash" href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
         response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
@@ -116,8 +116,8 @@
         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("""<a class="changeset_hash" href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
         response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
@@ -175,8 +175,8 @@
         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("""<a class="changeset_hash" href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
         response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
@@ -234,8 +234,8 @@
         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("""<a class="changeset_hash" href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
         response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
@@ -302,9 +302,9 @@
         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("""<a class="changeset_hash" href="/%s/changeset/%s">r2:%s</a>""" % (repo1.repo_name, cs2.raw_id, cs2.short_id))
         response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r3:%s</a>""" % (repo1.repo_name, cs3.raw_id, cs3.short_id))
@@ -368,9 +368,9 @@
         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("""<a class="changeset_hash" href="/%s/changeset/%s">r3:%s</a>""" % (repo1.repo_name, cs3.raw_id, cs3.short_id))
         response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r4:%s</a>""" % (repo1.repo_name, cs4.raw_id, cs4.short_id))