## Changesets table !
<div class="container">
  %if not c.cs_ranges:
    <span class="empty_data">${_('No changesets')}</span>
  %else:

    %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 cnt, cs in enumerate(reversed(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
          %if c.cs_comments.get(cs.raw_id):
              <div class="comments-container">
                  <div class="comments-cnt" title="${_('Changeset has comments')}">
                      <a href="${h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id,anchor='comment-%s' % c.cs_comments[cs.raw_id][0].comment_id)}">
                          ${len(c.cs_comments[cs.raw_id])}
                          <i class="icon-comment-alt icon-comment-colored"></i>
                      </a>
                  </div>
              </div>
          %endif
        </td>
        <td style="width: 140px"><span class="tooltip" title="${h.tooltip(h.age(cs.date))}">${cs.date}</span></td>
        <td><div class="gravatar" commit_id="${cs.raw_id}"><img alt="gravatar" src="${h.gravatar_url(h.email_or_none(cs.author),14)}" height="14" width="14"/></div></td>
        <td><div class="author">${h.person(cs.author)}</div></td>
        <td>${h.link_to(h.show_id(cs),h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id))}</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" commit_id="${cs.raw_id}" title="${_('Expand commit message')}">
            <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.a_rev) instead ...
      ${h.link_to(_('Show merge diff'),
        h.url('compare_url',
          repo_name=c.a_repo.repo_name,
          org_ref_type=c.a_ref_type, org_ref_name=c.a_ref_name,
          other_repo=c.cs_repo.repo_name,
          other_ref_type=c.cs_ref_type, other_ref_name=c.cs_ref_name,
          merge='1'),
        )}
      </div>
      <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
        ${_('Common ancestor')}:
        %if c.ancestor:
        ${h.link_to(h.short_id(c.ancestor),h.url('changeset_home',repo_name=c.repo_name,revision=c.ancestor))}
        %else:
        ${_('No common ancestor found - repositories are unrelated')}
        %endif
      </div>
    %endif
    %if c.cs_ranges_org is not None:
      ## TODO: list actual changesets?
      <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
        ${h.link_to_ref(c.cs_repo.repo_name, c.cs_ref_type, c.cs_ref_name, c.cs_rev)}
        ${_('is')}
        <a href="${c.swap_url}">${_('%s changesets') % (len(c.cs_ranges_org))}</a>
        ${_('behind')}
        ${h.link_to_ref(c.a_repo.repo_name, c.a_ref_type, c.a_ref_name)}
      </div>
    %endif
  %endif
</div>

%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

<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').click(function(e){
            var cid = $(this).attr('commit_id');
            $('#row-'+cid).toggleClass('hl', !$('#row-'+cid).hasClass('hl'));
        });
    });

</script>
