changeset 4353:67d5afe2fa1a

pull requests: show graph when creating PR
author Mads Kiilerich <madski@unity3d.com>
date Tue, 10 Dec 2013 19:30:37 +0100
parents c733124b6262
children 3865694df91e
files kallithea/controllers/compare.py kallithea/templates/compare/compare_cs.html kallithea/templates/pullrequests/pullrequest.html
diffstat 3 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/compare.py	Tue Dec 10 19:30:37 2013 +0100
+++ b/kallithea/controllers/compare.py	Tue Dec 10 19:30:37 2013 +0100
@@ -47,6 +47,8 @@
 from kallithea.lib.diffs import LimitedDiffContainer
 from kallithea.controllers.changeset import anchor_url, _ignorews_url,\
     _context_url, get_line_ctx, get_ignore_ws
+from kallithea.lib.graphmod import graph_data
+from kallithea.lib.compat import json
 
 log = logging.getLogger(__name__)
 
@@ -271,6 +273,12 @@
         c.statuses = c.db_repo.statuses(
             [x.raw_id for x in c.cs_ranges])
 
+        revs = [ctx.revision for ctx in reversed(c.cs_ranges)]
+        c.jsdata = json.dumps(graph_data(c.other_repo.scm_instance, revs))
+
+        c.statuses = c.db_repo.statuses([x.raw_id for x in
+                                                   c.cs_ranges])
+
         if partial:
             return render('compare/compare_cs.html')
         if merge and c.ancestor:
--- a/kallithea/templates/compare/compare_cs.html	Tue Dec 10 19:30:37 2013 +0100
+++ b/kallithea/templates/compare/compare_cs.html	Tue Dec 10 19:30:37 2013 +0100
@@ -17,7 +17,7 @@
     <div id="graph_content_pr" style="margin-left: 100px;">
 
     <table class="compare_view_commits noborder">
-    %for cnt, cs in enumerate(c.cs_ranges):
+    %for cnt, cs in enumerate(reversed(c.cs_ranges)):
         <tr id="chg_${cnt+1}">
         <td style="width:50px">
           %if cs.raw_id in c.statuses:
@@ -79,7 +79,9 @@
   %endif
 </div>
 
-%if not c.as_form:
+%if c.as_form:
+<div id="jsdata" style="display:none">${c.jsdata|n}</div>
+%else:
 <script type="text/javascript" src="${h.url('/js/graph.js')}"></script>
 %endif
 
--- a/kallithea/templates/pullrequests/pullrequest.html	Tue Dec 10 19:30:37 2013 +0100
+++ b/kallithea/templates/pullrequests/pullrequest.html	Tue Dec 10 19:30:37 2013 +0100
@@ -137,6 +137,7 @@
 
 </div>
 
+<script type="text/javascript" src="${h.url('/js/graph.js')}"></script>
 <script type="text/javascript">
   var _USERS_AC_DATA = ${c.users_array|n};
   var _GROUPS_AC_DATA = ${c.user_groups_array|n};
@@ -202,7 +203,11 @@
       }
 
       YUD.get('pull_request_overview').innerHTML = "${_('Loading ...')}";
-      ypjax(url,'pull_request_overview');
+      ypjax(url,'pull_request_overview', function(o){
+          var jsdata = eval('('+YUD.get('jsdata').innerHTML+')');
+          var r = new BranchRenderer('graph_canvas', 'graph_content_pr');
+          r.render(jsdata,100);
+      });
   }
 
   ## refresh automatically when something changes (org_repo can't change)