[PATCH RFC] pullrequest: reverse order of changeset list

Thomas De Schampheleire patrickdepinguin at gmail.com
Sat Apr 25 16:23:15 EDT 2015


# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1429991014 -7200
#      Sat Apr 25 21:43:34 2015 +0200
# Node ID 7f62f8ef3acc8ce197156d138936a56329f0d151
# Parent  471b0adcad4cb7e40db3599340fe1b6242d3a7b8
pullrequest: reverse order of changeset list

When reviewing a pullrequest, it makes sense to start with the parent-most
commit and end with the child-most commit (old to new). However, the list
of commits is not in that order.

Since the list of commits is displayed from a template (compare_cs.html)
used from several places, it's not possible to reverse the order
unconditionally. Instead, add a cs_order argument to define the order.

Notes:
- when creating a pull request (as opposed to displaying an existing one),
  the list of commits is still in the child->parent order. This list is
  obtained via AJAX, from the compare URL, and mako page arguments cannot
  be given here. To reverse this list, one would need to add the order
  argument to the URL.

- I think there may need to be reversing in the graph data too. This is
  currently not handled. Or can we assume that any series shown in a pull
  request will be linear?

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,3 +1,5 @@
+<%page args="cs_order='child_to_parent'" />
+
 ## Changesets table !
 <div class="container">
   %if not c.cs_ranges:
@@ -17,7 +19,13 @@
     <div id="graph_content_pr" style="margin-left: 100px;">
 
     <table class="compare_view_commits noborder">
-    %for cnt, cs in enumerate(reversed(c.cs_ranges)):
+    <%
+        if cs_order == 'parent_to_child':
+            ranges = c.cs_ranges
+        else:
+            ranges = reversed(c.cs_ranges)
+    %>
+    %for cnt, cs in enumerate(ranges):
         <tr id="chg_${cnt+1}">
         <td style="width:50px">
           %if cs.raw_id in c.statuses:
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
@@ -44,8 +44,10 @@
     %else:
         <div id="changeset_compare_view_content">
                 ##CS
-                <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${ungettext('Showing %s commit','Showing %s commits', len(c.cs_ranges)) % len(c.cs_ranges)}</div>
-                <%include file="compare_cs.html" />
+                <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
+                  ${ungettext('Showing %s commit','Showing %s commits (ordered from child to parent)', len(c.cs_ranges)) % len(c.cs_ranges)}
+                </div>
+                <%include file="compare_cs.html" args="cs_order='child_to_parent'" />
 
                 ## FILES
                 <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
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
@@ -291,9 +291,9 @@
               </div>
               ##CS
               <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
-                ${ungettext('Showing %s commit','Showing %s commits', len(c.cs_ranges)) % len(c.cs_ranges)}
+                ${ungettext('Showing %s commit','Showing %s commits (ordered from parent to child)', len(c.cs_ranges)) % len(c.cs_ranges)}
               </div>
-              <%include file="/compare/compare_cs.html" />
+              <%include file="/compare/compare_cs.html" args="cs_order='parent_to_child'" />
 
               <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
               ${_('Common ancestor')}:


More information about the kallithea-general mailing list