Changeset - c9b0f1d363c7
[Not reviewed]
beta
0 8 0
Mads Kiilerich - 13 years ago 2013-02-01 23:13:10
madski@unity3d.com
compare: swap org and other when they refer to different repos, ie are pull request style

Pull requests will have a different from/to description - but in a consistent
and slightly better way that can be improved later.

A pull request diff is empathic: "How will this look for the peer I'm proposing to" style.
8 files changed with 35 insertions and 35 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -472,50 +472,50 @@ def make_map(config):
 

	
 
    rmap.connect('changeset_download_home',
 
                 '/{repo_name:.*?}/changeset-download/{revision}',
 
                 controller='changeset', action='changeset_download',
 
                 revision='tip', conditions=dict(function=check_repo))
 

	
 
    rmap.connect('changeset_comment',
 
                 '/{repo_name:.*?}/changeset/{revision}/comment',
 
                controller='changeset', revision='tip', action='comment',
 
                conditions=dict(function=check_repo))
 

	
 
    rmap.connect('changeset_comment_delete',
 
                 '/{repo_name:.*?}/changeset/comment/{comment_id}/delete',
 
                controller='changeset', action='delete_comment',
 
                conditions=dict(function=check_repo, method=["DELETE"]))
 

	
 
    rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}',
 
                 controller='changeset', action='changeset_info')
 

	
 
    rmap.connect('compare_url',
 
                 '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}',
 
                 controller='compare', action='index',
 
                 conditions=dict(function=check_repo),
 
                 requirements=dict(
 
                            org_ref_type='(branch|book|tag|rev|__org_ref_type__)',
 
                            other_ref_type='(branch|book|tag|rev|__other_ref_type__)')
 
                            org_ref_type='(branch|book|tag|rev|__other_ref_type__)',
 
                            other_ref_type='(branch|book|tag|rev|__org_ref_type__)')
 
                 )
 

	
 
    rmap.connect('pullrequest_home',
 
                 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
 
                 action='index', conditions=dict(function=check_repo,
 
                                                 method=["GET"]))
 

	
 
    rmap.connect('pullrequest',
 
                 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
 
                 action='create', conditions=dict(function=check_repo,
 
                                                  method=["POST"]))
 

	
 
    rmap.connect('pullrequest_show',
 
                 '/{repo_name:.*?}/pull-request/{pull_request_id}',
 
                 controller='pullrequests',
 
                 action='show', conditions=dict(function=check_repo,
 
                                                method=["GET"]))
 
    rmap.connect('pullrequest_update',
 
                 '/{repo_name:.*?}/pull-request/{pull_request_id}',
 
                 controller='pullrequests',
 
                 action='update', conditions=dict(function=check_repo,
 
                                                method=["PUT"]))
 
    rmap.connect('pullrequest_delete',
 
                 '/{repo_name:.*?}/pull-request/{pull_request_id}',
rhodecode/controllers/compare.py
Show inline comments
 
@@ -111,67 +111,67 @@ class CompareController(BaseRepoControll
 

	
 
        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
 
        c.target_repo = c.other_repo.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
 
            org_repo = other_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']])
rhodecode/model/pull_request.py
Show inline comments
 
@@ -169,63 +169,63 @@ class PullRequestModel(BaseModel):
 
        :param other_ref:
 
        :param tmp:
 
        """
 

	
 
        changesets = []
 

	
 
        if alias == 'hg':
 
            # lookup up the exact node id
 
            _revset_predicates = {
 
                    'branch': 'branch',
 
                    'book': 'bookmark',
 
                    'tag': 'tag',
 
                    'rev': 'id',
 
                }
 
            org_rev_spec = "%s('%s')" % (_revset_predicates[org_ref[0]],
 
                                         safe_str(org_ref[1]))
 
            org_rev = scmutil.revsingle(org_repo._repo,
 
                                         org_rev_spec)
 
            other_rev_spec = "%s('%s')" % (_revset_predicates[other_ref[0]],
 
                                           safe_str(other_ref[1]))
 
            other_rev = scmutil.revsingle(other_repo._repo, other_rev_spec)
 

	
 
            #case two independent repos
 
            if org_repo != other_repo:
 
                hgrepo = unionrepo.unionrepository(org_repo.baseui,
 
                                                   org_repo.path,
 
                                                   other_repo.path)
 
                revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" %
 
                        (org_rev, other_rev)]
 
                hgrepo = unionrepo.unionrepository(other_repo.baseui,
 
                                                   other_repo.path,
 
                                                   org_repo.path)
 
                # all the changesets we are looking for will be in other_repo,
 
                # so rev numbers from hgrepo can be used in other_repo
 

	
 
            #no remote compare do it on the same repository
 
            else:
 
                hgrepo = org_repo._repo
 
                hgrepo = other_repo._repo
 

	
 
                revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" %
 
                        (other_rev, org_rev)]
 

	
 
            out = scmutil.revrange(hgrepo, revs)
 
            for cs in (out):
 
                changesets.append(org_repo.get_changeset(cs))
 
                changesets.append(other_repo.get_changeset(cs))
 

	
 
        elif alias == 'git':
 
            assert org_repo == other_repo, (org_repo, other_repo) # no git support for different repos
 
            so, se = org_repo.run_git_command(
 
                'log --reverse --pretty="format: %%H" -s -p %s..%s' % (org_ref[1],
 
                                                                       other_ref[1])
 
            )
 
            ids = re.findall(r'[0-9a-fA-F]{40}', so)
 
            for cs in (ids):
 
                changesets.append(org_repo.get_changeset(cs))
 

	
 
        return changesets
 

	
 
    def get_compare_data(self, org_repo, org_ref, other_repo, other_ref):
 
        """
 
        Returns incoming changesets for mercurial repositories
 

	
 
        :param org_repo:
 
        :type org_repo:
 
        :param org_ref:
 
        :type org_ref:
 
        :param other_repo:
 
        :type other_repo:
 
        :param other_ref:
rhodecode/templates/base/base.html
Show inline comments
 
@@ -199,49 +199,49 @@
 
               <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_repo=c.rhodecode_db_repo.fork.repo_name,other_ref_type='branch',other_ref='default'),class_='compare_request')}</li>
 
                 <li>${h.link_to(_('compare fork'),h.url('compare_url',repo_name=c.rhodecode_db_repo.fork.repo_name,org_ref_type='branch',org_ref='default',other_repo=c.repo_name,other_ref_type='branch',other_ref=request.GET.get('branch') or '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>
rhodecode/templates/changelog/changelog.html
Show inline comments
 
@@ -16,49 +16,49 @@ ${_('%s Changelog') % c.repo_name} - ${c
 
</%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_repo=c.rhodecode_db_repo.fork.repo_name,other_ref_type='branch',other_ref='default')}" 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.rhodecode_db_repo.fork.repo_name,org_ref_type='branch',org_ref='default',other_repo=c.repo_name,other_ref_type='branch',other_ref=request.GET.get('branch') or '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">
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_repo=c.repo_name,other_ref_type='branch',other_ref='default')}"
 
                    href="${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref='default',other_repo=f.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
 
@@ -119,54 +119,54 @@
 
                </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');
 
      //url template
 
      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_name='__other_repo__',
 
                         org_ref_type='__other_ref_type__',
 
                         org_ref='__other_ref__',
 
                         other_repo='__org_repo__',
 
                         other_ref_type='__org_ref_type__',
 
                         other_ref='__org_ref__',
 
                         as_form=True,
 
                         rev_start=request.GET.get('rev_start',''),
 
                         rev_end=request.GET.get('rev_end',''))}";
 
      var org_repo = YUQ('#pull_request_form #org_repo')[0].value;
 
      var org_ref = YUQ('#pull_request_form #org_ref')[0].value.split(':');
 
      
 
      var other_repo = YUQ('#pull_request_form #other_repo')[0].value;
 
      var other_ref = YUQ('#pull_request_form #other_ref')[0].value.split(':');
 
      
 
      var select_refs = YUQ('#pull_request_form select.refs')
 
      var rev_data = {
 
    	  'org_repo': org_repo,
 
    	  'org_ref': org_ref[1],
 
    	  'org_ref_type': org_ref[0],
 
    	  'other_repo': other_repo,
 
          'other_ref': other_ref[1],
 
          'other_ref_type': other_ref[0],    	  
 
      }; // gather the org/other ref and repo here
 
      
 
      for (k in rev_data){
 
    	  url = url.replace('__'+k+'__',rev_data[k]);
 
      }
 

	
 
      YUE.on('other_repo', 'change', function(e){
rhodecode/tests/functional/test_compare.py
Show inline comments
 
@@ -68,128 +68,128 @@ class TestCompareController(TestControll
 
        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,
 
                                    repo_name=repo1.repo_name,
 
                                    org_ref_type="branch",
 
                                    org_ref=rev1,
 
                                    other_repo=repo1.repo_name,
 
                                    org_ref=rev2,
 
                                    other_repo=repo2.repo_name,
 
                                    other_ref_type="branch",
 
                                    other_ref=rev2,
 
                                    other_ref=rev1,
 
                                    ))
 

	
 
        try:
 
            response.mustcontain('%s@%s -&gt; %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2))
 
            response.mustcontain('%s@%s -&gt; %s@%s' % (repo1.repo_name, rev2, repo2.repo_name, rev1))
 
            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?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo1.repo_name, rev2, rev1, repo2.repo_name))
 
            #swap
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo1.repo_name, rev1, rev2, repo2.repo_name))
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
 
        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,
 
                                    repo_name=repo1.repo_name,
 
                                    org_ref_type="branch",
 
                                    org_ref=rev1,
 
                                    other_repo=repo1.repo_name,
 
                                    org_ref=rev2,
 
                                    other_repo=repo2.repo_name,
 
                                    other_ref_type="branch",
 
                                    other_ref=rev2,
 
                                    other_ref=rev1,
 
                                    ))
 

	
 
        try:
 
            response.mustcontain('%s@%s -&gt; %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2))
 
            response.mustcontain('%s@%s -&gt; %s@%s' % (repo1.repo_name, rev2, repo2.repo_name, rev1))
 
            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?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo1.repo_name, rev2, rev1, repo2.repo_name))
 
            #swap
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo1.repo_name, rev1, rev2, repo2.repo_name))
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
 
        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))
0 comments (0 inline, 0 general)