Changeset - c733124b6262
[Not reviewed]
default
0 3 0
Mads Kiilerich - 12 years ago 2013-12-10 19:30:37
madski@unity3d.com
pull requests: show graph when displaying PR
3 files changed with 38 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/changeset.py
Show inline comments
 
@@ -36,12 +36,13 @@ from pylons.i18n.translation import _
 
from pylons.controllers.util import redirect
 
from kallithea.lib.utils import jsonify
 

	
 
from kallithea.lib.vcs.exceptions import RepositoryError, \
 
    ChangesetDoesNotExistError
 

	
 
from kallithea.lib.compat import json
 
import kallithea.lib.helpers as h
 
from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator,\
 
    NotAnonymous
 
from kallithea.lib.base import BaseRepoController, render
 
from kallithea.lib.utils import action_logger
 
from kallithea.lib.compat import OrderedDict
 
@@ -52,12 +53,13 @@ from kallithea.model.changeset_status im
 
from kallithea.model.meta import Session
 
from kallithea.model.repo import RepoModel
 
from kallithea.lib.diffs import LimitedDiffContainer
 
from kallithea.lib.exceptions import StatusChangeOnClosedPullRequestError
 
from kallithea.lib.vcs.backends.base import EmptyChangeset
 
from kallithea.lib.utils2 import safe_unicode, safe_str
 
from kallithea.lib.graphmod import graph_data
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
def _update_with_GET(params, GET):
 
    for k in ['diff1', 'diff2', 'diff']:
 
@@ -310,12 +312,14 @@ class ChangesetController(BaseRepoContro
 
        elif method == 'show':
 
            self.__load_data()
 
            if len(c.cs_ranges) == 1:
 
                return render('changeset/changeset.html')
 
            else:
 
                c.cs_ranges_org = None
 
                revs = [ctx.revision for ctx in reversed(c.cs_ranges)]
 
                c.jsdata = json.dumps(graph_data(c.db_repo_scm_instance, revs))
 
                return render('changeset/changeset_range.html')
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def index(self, revision, method='show'):
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -57,12 +57,13 @@ from kallithea.model.comment import Chan
 
from kallithea.model.changeset_status import ChangesetStatusModel
 
from kallithea.model.forms import PullRequestForm, PullRequestPostForm
 
from kallithea.lib.utils2 import safe_int
 
from kallithea.controllers.changeset import anchor_url, _ignorews_url,\
 
    _context_url, get_line_ctx, get_ignore_ws
 
from kallithea.controllers.compare import CompareController
 
from kallithea.lib.graphmod import graph_data
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class PullrequestsController(BaseRepoController):
 

	
 
@@ -197,12 +198,14 @@ class PullrequestsController(BaseRepoCon
 
         c.other_ref_name,
 
         c.other_rev) = pull_request.other_ref.split(':')
 

	
 
        org_scm_instance = c.org_repo.scm_instance # property with expensive cache invalidation check!!!
 
        c.cs_ranges = [org_scm_instance.get_changeset(x) for x in pull_request.revisions]
 
        c.cs_ranges_org = None # not stored and not important and moving target - could be calculated ...
 
        revs = [ctx.revision for ctx in reversed(c.cs_ranges)]
 
        c.jsdata = json.dumps(graph_data(org_scm_instance, revs))
 

	
 
        c.statuses = c.org_repo.statuses([x.raw_id for x in c.cs_ranges])
 

	
 
        ignore_whitespace = request.GET.get('ignorews') == '1'
 
        line_context = request.GET.get('context', 3)
 
        c.ignorews_url = _ignorews_url
kallithea/templates/compare/compare_cs.html
Show inline comments
 
@@ -7,15 +7,21 @@
 
    %if c.ancestor:
 
    <div class="ancestor">${_('Ancestor')}:
 
      ${h.link_to(h.short_id(c.ancestor),h.url('changeset_home',repo_name=c.repo_name,revision=c.ancestor))}
 
    </div>
 
    %endif
 

	
 
    <div id="graph_nodes">
 
        <canvas id="graph_canvas"></canvas>
 
    </div>
 

	
 
    <div id="graph_content_pr" style="margin-left: 100px;">
 

	
 
    <table class="compare_view_commits noborder">
 
    %for cs in reversed(c.cs_ranges):
 
        <tr id="row-${cs.raw_id}">
 
    %for cnt, cs in enumerate(c.cs_ranges):
 
        <tr id="chg_${cnt+1}">
 
        <td style="width:50px">
 
          %if cs.raw_id in c.statuses:
 
            <div title="${_('Changeset status: %s') % c.statuses[cs.raw_id][1]}" class="changeset-status-ico">
 
                <img height="16" width="16" src="${h.url('/images/icons/flag_status_%s.png' % c.statuses[cs.raw_id][0])}" />
 
            </div>
 
          %endif
 
@@ -33,12 +39,15 @@
 
            <i class="icon-resize-vertical" style="color:#DDD"></i>
 
        </td>
 
        <td><div id="C-${cs.raw_id}" class="message">${h.urlify_commit(cs.message, c.repo_name)}</div></td>
 
        </tr>
 
    %endfor
 
    </table>
 

	
 
    </div>
 

	
 
    %if c.as_form:
 
      <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
 
      ## links should perhaps use ('rev', c.org_rev) instead ...
 
      ${h.link_to(_('Show merge diff'),
 
        h.url('compare_url',
 
          repo_name=c.org_repo.repo_name,
 
@@ -67,16 +76,32 @@
 
        ${h.link_to_ref(c.org_repo.repo_name, c.org_ref_type, c.org_ref_name, c.org_rev)}
 
      </div>
 
    %endif
 
  %endif
 
</div>
 

	
 
<script>
 
$('.expand_commit').on('click',function(e){
 
%if not c.as_form:
 
<script type="text/javascript" src="${h.url('/js/graph.js')}"></script>
 
%endif
 

	
 
<script type="text/javascript">
 

	
 
    $(document).ready(function(){
 
%if not c.as_form:
 
        var jsdata = ${c.jsdata|n};
 
        var r = new BranchRenderer('graph_canvas', 'graph_content_pr');
 
        r.render(jsdata,100);
 
%endif
 

	
 
        $('.expand_commit').click(function(e){
 
    var cid = $(this).attr('commit_id');
 
    $('#C-'+cid).toggleClass('expanded');
 
            r.render(jsdata,100);
 
});
 
$('.gravatar').on('click',function(e){
 

	
 
        $('.gravatar').click(function(e){
 
    var cid = $(this).attr('commit_id');
 
    $('#row-'+cid).toggleClass('hl', !$('#row-'+cid).hasClass('hl'));
 
});
 
</script>
 
    });
 

	
 
</script>
 
\ No newline at end of file
0 comments (0 inline, 0 general)