Changeset - b36285f90f89
[Not reviewed]
beta
0 6 0
Mads Kiilerich - 13 years ago 2013-02-01 23:13:10
madski@unity3d.com
Grafted from: 9591848d9328
compare: rename optional compare_url parameter repo to other_repo

At the same time it is placed before other_ref_type and other_ref. Just to keep
a logical flow and (a new) consistency that will help the next refactoring.
6 files changed with 12 insertions and 11 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/compare.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
"""
 
    rhodecode.controllers.compare
 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
    compare controller for pylons showing differences between two
 
    repos, branches, bookmarks or tips
 

	
 
    :created_on: May 6, 2012
 
    :author: marcink
 
    :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
 
    :license: GPLv3, see COPYING for more details.
 
"""
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
import logging
 
import traceback
 

	
 
from webob.exc import HTTPNotFound
 
from pylons import request, response, session, tmpl_context as c, url
 
from pylons.controllers.util import abort, redirect
 
from pylons.i18n.translation import _
 

	
 
from rhodecode.lib.vcs.exceptions import EmptyRepositoryError, RepositoryError
 
from rhodecode.lib import helpers as h
 
from rhodecode.lib.base import BaseRepoController, render
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib import diffs
 

	
 
from rhodecode.model.db import Repository
 
from rhodecode.model.pull_request import PullRequestModel
 
from webob.exc import HTTPBadRequest
 
from rhodecode.lib.utils2 import str2bool
 
from rhodecode.lib.diffs import LimitedDiffContainer
 
from rhodecode.lib.vcs.backends.base import EmptyChangeset
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class CompareController(BaseRepoController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(CompareController, self).__before__()
 

	
 
    def __get_cs_or_redirect(self, rev, repo, redirect_after=True,
 
                             partial=False):
 
        """
 
        Safe way to get changeset if error occur it redirects to changeset with
 
        proper message. If partial is set then don't do redirect raise Exception
 
        instead
 

	
 
        :param rev: revision to fetch
 
        :param repo: repo instance
 
        """
 

	
 
        try:
 
            type_, rev = rev
 
            return repo.scm_instance.get_changeset(rev)
 
        except EmptyRepositoryError, e:
 
            if not redirect_after:
 
                return None
 
            h.flash(h.literal(_('There are no changesets yet')),
 
                    category='warning')
 
            redirect(url('summary_home', repo_name=repo.repo_name))
 

	
 
        except RepositoryError, e:
 
            log.error(traceback.format_exc())
 
            h.flash(str(e), category='warning')
 
            if not partial:
 
                redirect(h.url('summary_home', repo_name=repo.repo_name))
 
            raise HTTPBadRequest()
 

	
 
    def index(self, org_ref_type, org_ref, other_ref_type, other_ref):
 

	
 
        org_repo = c.rhodecode_db_repo.repo_name
 
        org_ref = (org_ref_type, org_ref)
 
        other_ref = (other_ref_type, other_ref)
 
        other_repo = request.GET.get('repo', org_repo)
 
        other_repo = request.GET.get('other_repo', org_repo)
 
        c.fulldiff = fulldiff = request.GET.get('fulldiff')
 
        rev_start = request.GET.get('rev_start')
 
        rev_end = request.GET.get('rev_end')
 

	
 
        c.swap_url = h.url('compare_url', repo_name=other_repo,
 
              org_ref_type=other_ref[0], org_ref=other_ref[1],
 
              other_ref_type=org_ref[0], other_ref=org_ref[1],
 
              repo=org_repo, as_form=request.GET.get('as_form'))
 
        c.swap_url = h.url('compare_url', as_form=request.GET.get('as_form'),
 
            repo_name=other_repo,
 
            org_ref_type=other_ref[0], org_ref=other_ref[1],
 
            repo=org_repo,
 
            other_ref_type=org_ref[0], other_ref=org_ref[1])
 

	
 
        c.org_repo = org_repo = Repository.get_by_repo_name(org_repo)
 
        c.other_repo = other_repo = Repository.get_by_repo_name(other_repo)
 

	
 
        if c.org_repo is None:
 
            log.error('Could not find org repo %s' % org_repo)
 
            raise HTTPNotFound
 
        if c.other_repo is None:
 
            log.error('Could not find other repo %s' % other_repo)
 
            raise HTTPNotFound
 

	
 
        if c.org_repo != c.other_repo and h.is_git(c.rhodecode_repo):
 
            log.error('compare of two remote repos not available for GIT REPOS')
 
            raise HTTPNotFound
 

	
 
        if c.org_repo.scm_instance.alias != c.other_repo.scm_instance.alias:
 
            log.error('compare of two different kind of remote repos not available')
 
            raise HTTPNotFound
 

	
 
        partial = request.environ.get('HTTP_X_PARTIAL_XHR')
 
        self.__get_cs_or_redirect(rev=org_ref, repo=org_repo, partial=partial)
 
        self.__get_cs_or_redirect(rev=other_ref, repo=other_repo, partial=partial)
 

	
 
        if rev_start and rev_end:
 
            #replace our org_ref with given CS
 
            org_ref = ('rev', rev_start)
 
            other_ref = ('rev', rev_end)
 

	
 
        c.cs_ranges = PullRequestModel().get_compare_data(
 
                                    org_repo, org_ref, other_repo, other_ref,
 
                                    )
 

	
 
        c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in
 
                                                   c.cs_ranges])
 
        c.target_repo = c.repo_name
 
        # defines that we need hidden inputs with changesets
 
        c.as_form = request.GET.get('as_form', False)
 
        if partial:
 
            return render('compare/compare_cs.html')
 

	
 
        c.org_ref = org_ref[1]
 
        c.other_ref = other_ref[1]
 

	
 
        if c.cs_ranges and c.org_repo != c.other_repo:
 
            # case we want a simple diff without incoming changesets, just
 
            # for review purposes. Make the diff on the forked repo, with
 
            # revision that is common ancestor
 
            _org_ref = org_ref
 
            org_ref = ('rev', getattr(c.cs_ranges[0].parents[0]
 
                                      if c.cs_ranges[0].parents
 
                                      else EmptyChangeset(), 'raw_id'))
 
            log.debug('Changed org_ref from %s to %s' % (_org_ref, org_ref))
 
            other_repo = org_repo
 

	
 
        diff_limit = self.cut_off_limit if not fulldiff else None
 

	
 
        _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref)
 

	
 
        diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff',
 
                                             diff_limit=diff_limit)
 
        _parsed = diff_processor.prepare()
 

	
 
        c.limited_diff = False
 
        if isinstance(_parsed, LimitedDiffContainer):
 
            c.limited_diff = True
 

	
 
        c.files = []
 
        c.changes = {}
 
        c.lines_added = 0
 
        c.lines_deleted = 0
 
        for f in _parsed:
 
            st = f['stats']
 
            if st[0] != 'b':
 
                c.lines_added += st[0]
 
                c.lines_deleted += st[1]
 
            fid = h.FID('', f['filename'])
 
            c.files.append([fid, f['operation'], f['filename'], f['stats']])
 
            diff = diff_processor.as_html(enable_comments=False, parsed_lines=[f])
 
            c.changes[fid] = [f['operation'], f['filename'], diff]
 

	
 
        return render('compare/compare_diff.html')
rhodecode/templates/base/base.html
Show inline comments
 
@@ -127,193 +127,193 @@
 
            </div>
 
            <div class="links_right">
 
            <ol class="links">
 
              <li>${h.link_to(_(u'Home'),h.url('home'))}</li>
 
              <li>${h.link_to(_(u'Journal'),h.url('journal'))}</li>
 
              <li>${h.link_to(_(u'My account'),h.url('admin_settings_my_account'))}</li>
 
              <li class="logout">${h.link_to(_(u'Log Out'),h.url('logout_home'))}</li>
 
            </ol>
 
            </div>
 
        %endif
 
      </div>
 
  </div>
 

	
 
    </li>
 
</%def>
 

	
 
<%def name="menu(current=None)">
 
        <%
 
        def is_current(selected):
 
            if selected == current:
 
                return h.literal('class="current"')
 
        %>
 
        <ul id="quick">
 
          <!-- repo switcher -->
 
          <li ${is_current('home')}>
 
              <a class="menu_link" id="repo_switcher" title="${_('Switch repository')}" href="${h.url('home')}">
 
              <span class="icon">
 
                  <img src="${h.url('/images/icons/database.png')}" alt="${_('Products')}" />
 
              </span>
 
              <span>${_('Repositories')}</span>
 
              </a>
 
              <ul id="repo_switcher_list" class="repo_switcher">
 
                  <li>
 
                      <a href="#">${_('loading...')}</a>
 
                  </li>
 
              </ul>
 
          </li>
 
        ## we render this menu only not for those pages
 
        %if current not in ['home','admin', 'search', 'journal']:
 
            ##REGULAR MENU
 
            <li ${is_current('summary')}>
 
               <a class="menu_link" title="${_('Summary page')}" href="${h.url('summary_home',repo_name=c.repo_name)}">
 
               <span class="icon">
 
                   <img src="${h.url('/images/icons/clipboard_16.png')}" alt="${_('Summary')}" />
 
               </span>
 
               <span>${_('Summary')}</span>
 
               </a>
 
            </li>
 
            <li ${is_current('changelog')}>
 
               <a class="menu_link" title="${_('Changeset list')}" href="${h.url('changelog_home',repo_name=c.repo_name)}">
 
               <span class="icon">
 
                   <img src="${h.url('/images/icons/time.png')}" alt="${_('Changelog')}" />
 
               </span>
 
               <span>${_('Changelog')}</span>
 
               </a>
 
            </li>
 
            <li ${is_current('switch_to')}>
 
               <a class="menu_link" id="branch_tag_switcher" title="${_('Switch to')}" href="#">
 
               <span class="icon">
 
                   <img src="${h.url('/images/icons/arrow_switch.png')}" alt="${_('Switch to')}" />
 
               </span>
 
               <span>${_('Switch to')}</span>
 
               </a>
 
                <ul id="switch_to_list" class="switch_to">
 
                    <li><a href="#">${_('loading...')}</a></li>
 
                </ul>
 
            </li>
 
            <li ${is_current('files')}>
 
               <a class="menu_link" title="${_('Show repository content')}" href="${h.url('files_home',repo_name=c.repo_name)}">
 
               <span class="icon">
 
                   <img src="${h.url('/images/icons/file.png')}" alt="${_('Files')}" />
 
               </span>
 
               <span>${_('Files')}</span>
 
               </a>
 
            </li>
 
            <li ${is_current('options')}>
 
               <a class="menu_link" title="${_('Options')}" href="#">
 
               <span class="icon">
 
                   <img src="${h.url('/images/icons/table_gear.png')}" alt="${_('Admin')}" />
 
               </span>
 
               <span>${_('Options')}</span>
 
               </a>
 
               <ul>
 
               %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
 
                 %if h.HasPermissionAll('hg.admin')('access settings on repository'):
 
                     <li>${h.link_to(_('repository settings'),h.url('edit_repo',repo_name=c.repo_name),class_='settings')}</li>
 
                 %else:
 
                     <li>${h.link_to(_('repository settings'),h.url('repo_settings_home',repo_name=c.repo_name),class_='settings')}</li>
 
                 %endif
 
               %endif
 

	
 
                <li>${h.link_to(_('fork'),h.url('repo_fork_home',repo_name=c.repo_name),class_='fork')}</li>
 
                %if h.is_hg(c.rhodecode_repo):
 
                 <li>${h.link_to(_('open new pull request'),h.url('pullrequest_home',repo_name=c.repo_name),class_='pull_request')}</li>
 
                %endif
 
                %if c.rhodecode_db_repo.fork:
 
                 <li>${h.link_to(_('compare fork'),h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref=request.GET.get('branch') or 'default',other_ref_type='branch',other_ref='default',repo=c.rhodecode_db_repo.fork.repo_name),class_='compare_request')}</li>
 
                 <li>${h.link_to(_('compare fork'),h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref=request.GET.get('branch') or 'default',other_repo=c.rhodecode_db_repo.fork.repo_name,other_ref_type='branch',other_ref='default'),class_='compare_request')}</li>
 
                %endif
 
                <li>${h.link_to(_('lightweight changelog'),h.url('shortlog_home',repo_name=c.repo_name),class_='shortlog')}</li>
 
                <li>${h.link_to(_('search'),h.url('search_repo',repo_name=c.repo_name),class_='search')}</li>
 

	
 
                %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.rhodecode_db_repo.enable_locking:
 
                  %if c.rhodecode_db_repo.locked[0]:
 
                    <li>${h.link_to(_('unlock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_del')}</li>
 
                  %else:
 
                    <li>${h.link_to(_('lock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_add')}</li>
 
                  %endif
 
                %endif
 

	
 
                % if h.HasPermissionAll('hg.admin')('access admin main page'):
 
                 <li>
 
                   ${h.link_to(_('admin'),h.url('admin_home'),class_='admin')}
 
                    <%def name="admin_menu()">
 
                    <ul>
 
                        <li>${h.link_to(_('admin journal'),h.url('admin_home'),class_='journal')}</li>
 
                        <li>${h.link_to(_('repositories'),h.url('repos'),class_='repos')}</li>
 
                        <li>${h.link_to(_('repositories groups'),h.url('repos_groups'),class_='repos_groups')}</li>
 
                        <li>${h.link_to(_('users'),h.url('users'),class_='users')}</li>
 
                        <li>${h.link_to(_('users groups'),h.url('users_groups'),class_='groups')}</li>
 
                        <li>${h.link_to(_('permissions'),h.url('edit_permission',id='default'),class_='permissions')}</li>
 
                        <li>${h.link_to(_('ldap'),h.url('ldap_home'),class_='ldap')}</li>
 
                        <li>${h.link_to(_('defaults'),h.url('defaults'),class_='defaults')}</li>
 
                        <li class="last">${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li>
 
                    </ul>
 
                    </%def>
 
                    ## ADMIN MENU
 
                    ${admin_menu()}
 
                 </li>
 
                % endif
 
               </ul>
 
            </li>
 
            <li>
 
                <a class="menu_link" title="${_('Followers')}" href="${h.url('repo_followers_home',repo_name=c.repo_name)}">
 
                <span class="icon_short">
 
                    <img src="${h.url('/images/icons/heart.png')}" alt="${_('Followers')}" />
 
                </span>
 
                <span id="current_followers_count" class="short">${c.repository_followers}</span>
 
                </a>
 
            </li>
 
            <li>
 
                <a class="menu_link" title="${_('Forks')}" href="${h.url('repo_forks_home',repo_name=c.repo_name)}">
 
                <span class="icon_short">
 
                    <img src="${h.url('/images/icons/arrow_divide.png')}" alt="${_('Forks')}" />
 
                </span>
 
                <span class="short">${c.repository_forks}</span>
 
                </a>
 
            </li>
 
            <li>
 
                <a class="menu_link" title="${_('Pull requests')}" href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}">
 
                <span class="icon_short">
 
                    <img src="${h.url('/images/icons/arrow_join.png')}" alt="${_('Pull requests')}" />
 
                </span>
 
                <span class="short">${c.repository_pull_requests}</span>
 
                </a>
 
            </li>
 
            ${usermenu()}
 
            <script type="text/javascript">
 
                YUE.on('branch_tag_switcher','mouseover',function(){
 
                   var loaded = YUD.hasClass('branch_tag_switcher','loaded');
 
                   if(!loaded){
 
                       YUD.addClass('branch_tag_switcher','loaded');
 
                       ypjax("${h.url('branch_tag_switcher',repo_name=c.repo_name)}",'switch_to_list',
 
                           function(o){},
 
                           function(o){YUD.removeClass('branch_tag_switcher','loaded');}
 
                           ,null);
 
                   }
 
                   return false;
 
                });
 
            </script>
 
        %else:
 
            ##ROOT MENU
 
            %if c.rhodecode_user.username != 'default':
 
             <li ${is_current('journal')}>
 
                <a class="menu_link" title="${_('Show recent activity')}"  href="${h.url('journal')}">
 
                <span class="icon">
 
                    <img src="${h.url('/images/icons/book.png')}" alt="${_('Journal')}" />
 
                </span>
 
                <span>${_('Journal')}</span>
 
                </a>
 
             </li>
 
            %else:
 
             <li ${is_current('journal')}>
 
                <a class="menu_link" title="${_('Public journal')}"  href="${h.url('public_journal')}">
 
                <span class="icon">
 
                    <img src="${h.url('/images/icons/book.png')}" alt="${_('Public journal')}" />
 
                </span>
 
                <span>${_('Public journal')}</span>
 
                </a>
 
             </li>
 
            %endif
 
            <li ${is_current('search')}>
 
                <a class="menu_link" title="${_('Search in repositories')}"  href="${h.url('search')}">
 
                <span class="icon">
rhodecode/templates/changelog/changelog.html
Show inline comments
 
## -*- coding: utf-8 -*-
 

	
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
${_('%s Changelog') % c.repo_name} - ${c.rhodecode_name}
 
</%def>
 

	
 
<%def name="breadcrumbs_links()">
 
    ${h.link_to(_(u'Home'),h.url('/'))}
 
    &raquo;
 
    ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
 
    &raquo;
 
    <% size = c.size if c.size <= c.total_cs else c.total_cs %>
 
    ${_('Changelog')} - ${ungettext('showing %d out of %d revision', 'showing %d out of %d revisions', size) % (size, c.total_cs)}
 
</%def>
 

	
 
<%def name="page_nav()">
 
    ${self.menu('changelog')}
 
</%def>
 

	
 
<%def name="main()">
 
<div class="box">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
    </div>
 
    <div class="table">
 
        % if c.pagination:
 
            <div id="graph">
 
                <div id="graph_nodes">
 
                    <canvas id="graph_canvas"></canvas>
 
                </div>
 
                <div id="graph_content">
 
                    <div class="info_box" style="clear: both;padding: 10px 6px;vertical-align: right;text-align: right;">
 
                    <a href="#" class="ui-btn small" id="rev_range_container" style="display:none"></a>
 
                    <a href="#" class="ui-btn small" id="rev_range_clear" style="display:none">${_('Clear selection')}</a>
 

	
 
                    %if c.rhodecode_db_repo.fork:
 
                        <a title="${_('compare fork with %s' % c.rhodecode_db_repo.fork.repo_name)}" href="${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref=request.GET.get('branch') or 'default',other_ref_type='branch',other_ref='default',repo=c.rhodecode_db_repo.fork.repo_name)}" class="ui-btn small">${_('Compare fork with parent')}</a>
 
                        <a title="${_('compare fork with %s' % c.rhodecode_db_repo.fork.repo_name)}" href="${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref=request.GET.get('branch') or 'default',other_repo=c.rhodecode_db_repo.fork.repo_name,other_ref_type='branch',other_ref='default')}" class="ui-btn small">${_('Compare fork with parent')}</a>
 
                    %endif
 
                    %if h.is_hg(c.rhodecode_repo):
 
                    <a id="open_new_pr" href="${h.url('pullrequest_home',repo_name=c.repo_name)}" class="ui-btn small">${_('open new pull request')}</a>
 
                    %endif
 
                    </div>
 
                    <div class="container_header">
 
                        ${h.form(h.url.current(),method='get')}
 
                        <div class="info_box" style="float:left">
 
                          ${h.submit('set',_('Show'),class_="ui-btn")}
 
                          ${h.text('size',size=1,value=c.size)}
 
                          ${_('revisions')}
 
                        </div>
 
                        ${h.end_form()}
 
                    <div style="float:right">${h.select('branch_filter',c.branch_name,c.branch_filters)}</div>
 
                    </div>
 

	
 
                %for cnt,cs in enumerate(c.pagination):
 
                    <div id="chg_${cnt+1}" class="container ${'tablerow%s' % (cnt%2)}">
 
                        <div class="left">
 
                            <div>
 
                            ${h.checkbox(cs.raw_id,class_="changeset_range")}
 
                            <span class="tooltip" title="${h.tooltip(h.age(cs.date))}"><a href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id)}"><span class="changeset_id">${cs.revision}:<span class="changeset_hash">${h.short_id(cs.raw_id)}</span></span></a></span>
 
                            </div>
 
                            <div class="author">
 
                                <div class="gravatar">
 
                                    <img alt="gravatar" src="${h.gravatar_url(h.email_or_none(cs.author),16)}"/>
 
                                </div>
 
                                <div title="${cs.author}" class="user">${h.shorter(h.person(cs.author),22)}</div>
 
                            </div>
 
                            <div class="date">${h.fmt_date(cs.date)}</div>
 
                        </div>
 
                        <div class="mid">
 
                            <div class="message">${h.urlify_commit(cs.message, c.repo_name,h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}</div>
 
                            <div class="expand"><span class="expandtext">&darr; ${_('show more')} &darr;</span></div>
 
                        </div>
 
                        <div class="right">
 
                                    <div class="changes">
 
                                        <div id="changed_total_${cs.raw_id}" style="float:right;" class="changed_total tooltip" title="${h.tooltip(_('Affected number of files, click to show more details'))}">${len(cs.affected_files)}</div>
 
                                        <div class="comments-container">
 
                                        %if len(c.comments.get(cs.raw_id,[])) > 0:
 
                                            <div class="comments-cnt" title="${('comments')}">
 
                                              <a href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id,anchor='comment-%s' % c.comments[cs.raw_id][0].comment_id)}">
 
                                               <div class="comments-cnt">${len(c.comments[cs.raw_id])}</div>
 
                                               <img src="${h.url('/images/icons/comments.png')}">
 
                                              </a>
 
                                            </div>
 
                                        %endif
 
                                        </div>
 
                                        <div class="changeset-status-container">
 
                                            %if c.statuses.get(cs.raw_id):
 
                                              <div title="${_('Changeset status')}" class="changeset-status-lbl">${c.statuses.get(cs.raw_id)[1]}</div>
 
                                              <div class="changeset-status-ico">
 
                                              %if c.statuses.get(cs.raw_id)[2]:
 
                                                <a class="tooltip" title="${_('Click to open associated pull request #%s' % c.statuses.get(cs.raw_id)[2])}" href="${h.url('pullrequest_show',repo_name=c.statuses.get(cs.raw_id)[3],pull_request_id=c.statuses.get(cs.raw_id)[2])}"><img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses.get(cs.raw_id)[0])}" /></a>
 
                                              %else:
 
                                                <img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses.get(cs.raw_id)[0])}" />
 
                                              %endif
 
                                              </div>
 
                                            %endif
 
                                        </div>
 
                                    </div>
 
                                   %if cs.parents:
 
                                    %for p_cs in reversed(cs.parents):
 
                                        <div class="parent">${_('Parent')}
 
                                            <span class="changeset_id">${p_cs.revision}:<span class="changeset_hash">${h.link_to(h.short_id(p_cs.raw_id),
 
                                            h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)}</span></span>
 
                                        </div>
 
                                    %endfor
 
                                   %else:
 
                                        <div class="parent">${_('No parents')}</div>
 
                                   %endif
 

	
 
                                <span class="logtags">
 
                                    %if len(cs.parents)>1:
 
                                    <span class="merge">${_('merge')}</span>
 
                                    %endif
 
                                    %if cs.branch:
 
                                    <span class="branchtag" title="${'%s %s' % (_('branch'),cs.branch)}">
 
                                       ${h.link_to(h.shorter(cs.branch),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}
 
                                    </span>
 
                                    %endif
 
                                    %if h.is_hg(c.rhodecode_repo):
 
                                      %for book in cs.bookmarks:
 
                                      <span class="bookbook" title="${'%s %s' % (_('bookmark'),book)}">
 
                                         ${h.link_to(h.shorter(book),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}
 
                                      </span>
 
                                      %endfor
 
                                    %endif
 
                                    %for tag in cs.tags:
 
                                        <span class="tagtag"  title="${'%s %s' % (_('tag'),tag)}">
 
                                        ${h.link_to(h.shorter(tag),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>
 
                                    %endfor
 
                                </span>
 
                        </div>
 
                    </div>
 

	
rhodecode/templates/forks/forks_data.html
Show inline comments
 
## -*- coding: utf-8 -*-
 

	
 
% if c.forks_pager:
 
    % for f in c.forks_pager:
 
        <div>
 
            <div class="fork_user">
 
                <div class="gravatar">
 
                    <img alt="gravatar" src="${h.gravatar_url(f.user.email,24)}"/>
 
                </div>
 
                <span style="font-size: 20px">
 
                 <b>${f.user.username}</b> (${f.user.name} ${f.user.lastname}) /
 
                  ${h.link_to(f.repo_name,h.url('summary_home',repo_name=f.repo_name))}
 
                </span>
 
                <div style="padding:5px 3px 3px 42px;">${f.description}</div>
 
            </div>
 
            <div style="clear:both;padding-top: 10px"></div>
 
            <div class="follower_date">${_('forked')} -
 
                <span class="tooltip" title="${h.tooltip(h.fmt_date(f.created_on))}"> ${h.age(f.created_on)}</span>
 
                <a title="${_('compare fork with %s' % c.repo_name)}"
 
                    href="${h.url('compare_url',repo_name=f.repo_name,org_ref_type='branch',org_ref='default',other_ref_type='branch',other_ref='default', repo=c.repo_name)}"
 
                    href="${h.url('compare_url',repo_name=f.repo_name,org_ref_type='branch',org_ref='default',other_repo=c.repo_name,other_ref_type='branch',other_ref='default')}"
 
                    class="ui-btn small">${_('Compare fork')}</a>
 
            </div>
 
            <div style="border-bottom: 1px solid #DDD;margin:10px 0px 10px 0px"></div>
 
        </div>
 
    % endfor
 
  <div class="pagination-wh pagination-left">
 
  <script type="text/javascript">
 
  YUE.onDOMReady(function(){
 
      YUE.delegate("forks","click",function(e, matchedEl, container){
 
          ypjax(e.target.href,"forks",function(){
 
              show_more_event();
 
              tooltip_activate();
 
              show_changeset_tooltip();
 
          });
 
          YUE.preventDefault(e);
 
      },'.pager_link');
 
  });
 
  </script>
 
  ${c.forks_pager.pager('$link_previous ~2~ $link_next')}
 
  </div>
 
% else:
 
    ${_('There are no forks yet')}
 
% endif
rhodecode/templates/pullrequests/pullrequest.html
Show inline comments
 
@@ -48,157 +48,157 @@
 
                    <img id="other_repo_gravatar" alt="gravatar" src=""/>
 
                </div>
 
                <span style="font-size: 20px">
 
                ${h.select('other_repo',c.default_pull_request ,c.other_repos,class_='refs')}:${h.select('other_ref',c.default_pull_request_rev,c.default_revs,class_='refs')}
 
                </span>
 
         <span style="padding:3px">
 
           <a id="refresh" href="#" class="tooltip" title="${h.tooltip(_('refresh overview'))}">
 
             <img style="margin:3px" class="icon" title="${_('Refresh')}" alt="${_('Refresh')}" src="${h.url('/images/icons/arrow_refresh.png')}"/>
 
           </a>
 
         </span>
 
                 <div id="other_repo_desc" style="padding:5px 3px 3px 42px;"></div>
 
            </div>
 
            <div style="clear:both;padding-top: 10px"></div>
 
        </div>
 
       <div style="clear:both;padding-top: 10px"></div>
 
       ## overview pulled by ajax
 
       <div style="float:left" id="pull_request_overview"></div>
 
       <div style="float:left;clear:both;padding:10px 10px 10px 0px;display:none">
 
            <a id="pull_request_overview_url" href="#">${_('Detailed compare view')}</a>
 
       </div>
 
     </div>
 
    <div style="float:left; border-left:1px dashed #eee">
 
        <h4>${_('Pull request reviewers')}</h4>
 
        <div id="reviewers" style="padding:0px 0px 0px 15px">
 
          ## members goes here !
 
          <div class="group_members_wrap">
 
            <ul id="review_members" class="group_members">
 
            %for member in c.review_members:
 
              <li id="reviewer_${member.user_id}">
 
                <div class="reviewers_member">
 
                  <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(member.email,14)}"/> </div>
 
                  <div style="float:left">${member.full_name} (${_('owner')})</div>
 
                  <input type="hidden" value="${member.user_id}" name="review_members" />
 
                  <span class="delete_icon action_button" onclick="removeReviewer(${member.user_id})"></span>
 
                </div>
 
              </li>
 
            %endfor
 
            </ul>
 
          </div>
 

	
 
          <div class='ac'>
 
            <div class="reviewer_ac">
 
               ${h.text('user', class_='yui-ac-input')}
 
               <span class="help-block">${_('Add reviewer to this pull request.')}</span>
 
               <div id="reviewers_container"></div>
 
            </div>
 
          </div>
 
        </div>
 
    </div>
 
    <h3>${_('Create new pull request')}</h3>
 

	
 
    <div class="form">
 
        <!-- fields -->
 

	
 
        <div class="fields">
 

	
 
             <div class="field">
 
                <div class="label">
 
                    <label for="pullrequest_title">${_('Title')}:</label>
 
                </div>
 
                <div class="input">
 
                    ${h.text('pullrequest_title',size=30)}
 
                </div>
 
             </div>
 

	
 
            <div class="field">
 
                <div class="label label-textarea">
 
                    <label for="pullrequest_desc">${_('description')}:</label>
 
                </div>
 
                <div class="textarea text-area editor">
 
                    ${h.textarea('pullrequest_desc',size=30)}
 
                </div>
 
            </div>
 

	
 
            <div class="buttons">
 
                ${h.submit('save',_('Send pull request'),class_="ui-btn large")}
 
                ${h.reset('reset',_('Reset'),class_="ui-btn large")}
 
           </div>
 
        </div>
 
    </div>
 
    ${h.end_form()}
 

	
 
</div>
 

	
 
<script type="text/javascript">
 
  var _USERS_AC_DATA = ${c.users_array|n};
 
  var _GROUPS_AC_DATA = ${c.users_groups_array|n};
 
  PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
 

	
 
  var other_repos_info = ${c.other_repos_info|n};
 

	
 
  var loadPreview = function(){
 
      YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none');
 
      var url = "${h.url('compare_url',
 
                         repo_name='org_repo',
 
                         org_ref_type='org_ref_type', org_ref='org_ref',
 
                         other_repo='other_repo',
 
                         other_ref_type='other_ref_type', other_ref='other_ref',
 
                         repo='other_repo',
 
                         as_form=True,
 
                         rev_start=request.GET.get('rev_start',''),
 
                         rev_end=request.GET.get('rev_end',''))}";
 

	
 
      var select_refs = YUQ('#pull_request_form select.refs')
 
      var rev_data = {}; // gather the org/other ref and repo here
 
      for(var i=0;i<select_refs.length;i++){
 
        var select_ref = select_refs[i];
 
        var select_ref_data = select_ref.value.split(':');
 
        var key = null;
 
        var val = null;
 

	
 
        if(select_ref_data.length>1){
 
          key = select_ref.name+"_type";
 
          val = select_ref_data[0];
 
          url = url.replace(key,val);
 
          rev_data[key] = val;
 

	
 
          key = select_ref.name;
 
          val = select_ref_data[1];
 
          url = url.replace(key,val);
 
          rev_data[key] = val;
 

	
 
        }else{
 
          key = select_ref.name;
 
          val = select_ref.value;
 
          url = url.replace(key,val);
 
          rev_data[key] = val;
 
        }
 
      }
 

	
 
      YUE.on('other_repo', 'change', function(e){
 
          var repo_name = e.currentTarget.value;
 
          // replace the <select> of changed repo
 
          YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs'];
 
      });
 

	
 
      ypjax(url,'pull_request_overview', function(data){
 
          var sel_box = YUQ('#pull_request_form #other_repo')[0];
 
          var repo_name = sel_box.options[sel_box.selectedIndex].value;
 
          YUD.get('pull_request_overview_url').href = url;
 
          YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','');
 
          YUD.get('other_repo_gravatar').src = other_repos_info[repo_name]['gravatar'];
 
          YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description'];
 
          YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs'];
 
          // select back the revision that was just compared
 
          setSelectValue(YUD.get('other_ref'), rev_data['other_ref']);
 
      })
 
  }
 
  YUE.on('refresh','click',function(e){
 
     loadPreview()
 
  })
 

	
 
  //lazy load overview after 0.5s
 
  setTimeout(loadPreview, 500)
 

	
 
</script>
 

	
 
</%def>
rhodecode/tests/functional/test_compare.py
Show inline comments
 
from rhodecode.tests import *
 
from rhodecode.model.repo import RepoModel
 
from rhodecode.model.meta import Session
 
from rhodecode.model.db import Repository
 
from rhodecode.model.scm import ScmModel
 
from rhodecode.lib.vcs.backends.base import EmptyChangeset
 

	
 

	
 
def _fork_repo(fork_name, vcs_type, parent=None):
 
    if vcs_type =='hg':
 
        _REPO = HG_REPO
 
    elif vcs_type == 'git':
 
        _REPO = GIT_REPO
 

	
 
    if parent:
 
        _REPO = parent
 

	
 
    form_data = dict(
 
        repo_name=fork_name,
 
        repo_name_full=fork_name,
 
        repo_group=None,
 
        repo_type=vcs_type,
 
        description='',
 
        private=False,
 
        copy_permissions=False,
 
        landing_rev='tip',
 
        update_after_clone=False,
 
        fork_parent_id=Repository.get_by_repo_name(_REPO),
 
    )
 
    repo = RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN)
 

	
 
    Session().commit()
 
    return Repository.get_by_repo_name(fork_name)
 

	
 

	
 
def _commit_change(repo, filename, content, message, vcs_type, parent=None, newfile=False):
 
    repo = Repository.get_by_repo_name(repo)
 
    _cs = parent
 
    if not parent:
 
        _cs = EmptyChangeset(alias=vcs_type)
 

	
 
    if newfile:
 
        cs = ScmModel().create_node(
 
            repo=repo.scm_instance, repo_name=repo.repo_name,
 
            cs=_cs, user=TEST_USER_ADMIN_LOGIN,
 
            author=TEST_USER_ADMIN_LOGIN,
 
            message=message,
 
            content=content,
 
            f_path=filename
 
        )
 
    else:
 
        cs = ScmModel().commit_change(
 
            repo=repo.scm_instance, repo_name=repo.repo_name,
 
            cs=parent, user=TEST_USER_ADMIN_LOGIN,
 
            author=TEST_USER_ADMIN_LOGIN,
 
            message=message,
 
            content=content,
 
            f_path=filename
 
        )
 
    return cs
 

	
 

	
 
class TestCompareController(TestController):
 

	
 
    def test_compare_forks_on_branch_extra_commits_hg(self):
 
        self.log_user()
 

	
 
        repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
 
                                        description='diff-test',
 
                                        owner=TEST_USER_ADMIN_LOGIN)
 
        r1_id = repo1.repo_id
 
        Session().commit()
 
        #commit something !
 
        cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
 
                             message='commit1', vcs_type='hg', parent=None, newfile=True)
 

	
 
        #fork this repo
 
        repo2 = _fork_repo('one-fork', 'hg', parent='one')
 
        Session().commit()
 
        r2_id = repo2.repo_id
 

	
 
        #add two extra commit into fork
 
        cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n',
 
                             message='commit2', vcs_type='hg', parent=cs0)
 

	
 
        cs2 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\nline3\n',
 
                             message='commit3', vcs_type='hg', parent=cs1)
 

	
 
        rev1 = 'default'
 
        rev2 = 'default'
 
        response = self.app.get(url(controller='compare', action='index',
 
                                    repo_name=repo2.repo_name,
 
                                    org_ref_type="branch",
 
                                    org_ref=rev1,
 
                                    other_repo=repo1.repo_name,
 
                                    other_ref_type="branch",
 
                                    other_ref=rev2,
 
                                    repo=repo1.repo_name
 
                                    ))
 

	
 
        try:
 
            response.mustcontain('%s@%s -&gt; %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2))
 
            response.mustcontain("""Showing 2 commits""")
 
            response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
 

	
 
            response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""")
 
            response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""")
 

	
 
            response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
 
            response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
 
            ## files
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2))
 

	
 
        finally:
 
            RepoModel().delete(r2_id)
 
            RepoModel().delete(r1_id)
 

	
 

	
 
    def test_compare_forks_on_branch_extra_commits_origin_has_incomming_hg(self):
 
        self.log_user()
 

	
 
        repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
 
                                        description='diff-test',
 
                                        owner=TEST_USER_ADMIN_LOGIN)
 
        r1_id = repo1.repo_id
 
        Session().commit()
 
        #commit something !
 
        cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
 
                             message='commit1', vcs_type='hg', parent=None, newfile=True)
 

	
 
        #fork this repo
 
        repo2 = _fork_repo('one-fork', 'hg', parent='one')
 
        Session().commit()
 

	
 
        #now commit something to origin repo
 
        cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n',
 
                                  message='commit2', vcs_type='hg', parent=cs0, newfile=True)
 

	
 
        r2_id = repo2.repo_id
 

	
 
        #add two extra commit into fork
 
        cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n',
 
                             message='commit2', vcs_type='hg', parent=cs0)
 

	
 
        cs2 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\nline3\n',
 
                             message='commit3', vcs_type='hg', parent=cs1)
 

	
 
        rev1 = 'default'
 
        rev2 = 'default'
 
        response = self.app.get(url(controller='compare', action='index',
 
                                    repo_name=repo2.repo_name,
 
                                    org_ref_type="branch",
 
                                    org_ref=rev1,
 
                                    other_repo=repo1.repo_name,
 
                                    other_ref_type="branch",
 
                                    other_ref=rev2,
 
                                    repo=repo1.repo_name
 
                                    ))
 

	
 
        try:
 
            response.mustcontain('%s@%s -&gt; %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2))
 
            response.mustcontain("""Showing 2 commits""")
 
            response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
 

	
 
            response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""")
 
            response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""")
 

	
 
            response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
 
            response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
 
            ## files
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2))
 

	
 
        finally:
 
            RepoModel().delete(r2_id)
 
            RepoModel().delete(r1_id)
 

	
 

	
 
#    def test_compare_remote_repos_remote_flag_off(self):
 
#        self.log_user()
 
#        _fork_repo(HG_FORK, 'hg')
 
#
 
#        rev1 = '56349e29c2af'
 
#        rev2 = '7d4bc8ec6be5'
 
#
 
#        response = self.app.get(url(controller='compare', action='index',
 
#                                    repo_name=HG_REPO,
 
#                                    org_ref_type="rev",
 
#                                    org_ref=rev1,
 
#                                    other_ref_type="rev",
 
#                                    other_ref=rev2,
 
#                                    repo=HG_FORK,
 
#                                    bundle=False,
 
#                                    ))
 
#
 
#        try:
 
#            response.mustcontain('%s@%s -&gt; %s@%s' % (HG_REPO, rev1, HG_FORK, rev2))
 
#            ## outgoing changesets between those revisions
 
#
 
#            response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO))
 
#            response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO))
 
#            response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2))
 
#
 
#            ## files
 
#            response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2))
 
#            response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2))
 
#            response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2))
 
#        finally:
 
#            RepoModel().delete(HG_FORK)
 

	
 

	
 

	
 
#
 
#    def test_compare_remote_branches_hg(self):
 
#        self.log_user()
 
#
 
#        _fork_repo(HG_FORK, 'hg')
 
#
 
#        rev1 = '56349e29c2af'
 
#        rev2 = '7d4bc8ec6be5'
 
#
 
#        response = self.app.get(url(controller='compare', action='index',
 
#                                    repo_name=HG_REPO,
 
#                                    org_ref_type="rev",
 
#                                    org_ref=rev1,
 
#                                    other_ref_type="rev",
 
#                                    other_ref=rev2,
 
#                                    repo=HG_FORK,
 
#                                    ))
 
#
 
#        try:
 
#            response.mustcontain('%s@%s -&gt; %s@%s' % (HG_REPO, rev1, HG_FORK, rev2))
 
#            ## outgoing changesets between those revisions
 
#
 
#            response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO))
 
#            response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO))
 
#            response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2))
 
#
 
#            ## files
 
#            response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2))
 
#            response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2))
 
#            response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2))
 
#        finally:
 
#            RepoModel().delete(HG_FORK)
 
#
 
#    def test_org_repo_new_commits_after_forking_simple_diff(self):
 
#        self.log_user()
 
#
 
#        repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
 
#                                        description='diff-test',
 
#                                        owner=TEST_USER_ADMIN_LOGIN)
 
#
 
#        Session().commit()
 
#        r1_id = repo1.repo_id
0 comments (0 inline, 0 general)