##// END OF EJS Templates
compare: swap org and other when they refer to different repos, ie are pull request style...
Mads Kiilerich -
r3322:c9b0f1d3 beta
parent child Browse files
Show More
@@ -493,8 +493,8 b' def make_map(config):'
493 controller='compare', action='index',
493 controller='compare', action='index',
494 conditions=dict(function=check_repo),
494 conditions=dict(function=check_repo),
495 requirements=dict(
495 requirements=dict(
496 org_ref_type='(branch|book|tag|rev|__org_ref_type__)',
496 org_ref_type='(branch|book|tag|rev|__other_ref_type__)',
497 other_ref_type='(branch|book|tag|rev|__other_ref_type__)')
497 other_ref_type='(branch|book|tag|rev|__org_ref_type__)')
498 )
498 )
499
499
500 rmap.connect('pullrequest_home',
500 rmap.connect('pullrequest_home',
@@ -132,7 +132,7 b' class CompareController(BaseRepoControll'
132
132
133 c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in
133 c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in
134 c.cs_ranges])
134 c.cs_ranges])
135 c.target_repo = c.repo_name
135 c.target_repo = c.other_repo.repo_name
136 # defines that we need hidden inputs with changesets
136 # defines that we need hidden inputs with changesets
137 c.as_form = request.GET.get('as_form', False)
137 c.as_form = request.GET.get('as_form', False)
138 if partial:
138 if partial:
@@ -150,7 +150,7 b' class CompareController(BaseRepoControll'
150 if c.cs_ranges[0].parents
150 if c.cs_ranges[0].parents
151 else EmptyChangeset(), 'raw_id'))
151 else EmptyChangeset(), 'raw_id'))
152 log.debug('Changed org_ref from %s to %s' % (_org_ref, org_ref))
152 log.debug('Changed org_ref from %s to %s' % (_org_ref, org_ref))
153 other_repo = org_repo
153 org_repo = other_repo
154
154
155 diff_limit = self.cut_off_limit if not fulldiff else None
155 diff_limit = self.cut_off_limit if not fulldiff else None
156
156
@@ -190,21 +190,21 b' class PullRequestModel(BaseModel):'
190
190
191 #case two independent repos
191 #case two independent repos
192 if org_repo != other_repo:
192 if org_repo != other_repo:
193 hgrepo = unionrepo.unionrepository(org_repo.baseui,
193 hgrepo = unionrepo.unionrepository(other_repo.baseui,
194 org_repo.path,
194 other_repo.path,
195 other_repo.path)
195 org_repo.path)
196 revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" %
196 # all the changesets we are looking for will be in other_repo,
197 (org_rev, other_rev)]
197 # so rev numbers from hgrepo can be used in other_repo
198
198
199 #no remote compare do it on the same repository
199 #no remote compare do it on the same repository
200 else:
200 else:
201 hgrepo = org_repo._repo
201 hgrepo = other_repo._repo
202 revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" %
203 (other_rev, org_rev)]
204
202
203 revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" %
204 (other_rev, org_rev)]
205 out = scmutil.revrange(hgrepo, revs)
205 out = scmutil.revrange(hgrepo, revs)
206 for cs in (out):
206 for cs in (out):
207 changesets.append(org_repo.get_changeset(cs))
207 changesets.append(other_repo.get_changeset(cs))
208
208
209 elif alias == 'git':
209 elif alias == 'git':
210 assert org_repo == other_repo, (org_repo, other_repo) # no git support for different repos
210 assert org_repo == other_repo, (org_repo, other_repo) # no git support for different repos
@@ -220,7 +220,7 b''
220 <li>${h.link_to(_('open new pull request'),h.url('pullrequest_home',repo_name=c.repo_name),class_='pull_request')}</li>
220 <li>${h.link_to(_('open new pull request'),h.url('pullrequest_home',repo_name=c.repo_name),class_='pull_request')}</li>
221 %endif
221 %endif
222 %if c.rhodecode_db_repo.fork:
222 %if c.rhodecode_db_repo.fork:
223 <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>
223 <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>
224 %endif
224 %endif
225 <li>${h.link_to(_('lightweight changelog'),h.url('shortlog_home',repo_name=c.repo_name),class_='shortlog')}</li>
225 <li>${h.link_to(_('lightweight changelog'),h.url('shortlog_home',repo_name=c.repo_name),class_='shortlog')}</li>
226 <li>${h.link_to(_('search'),h.url('search_repo',repo_name=c.repo_name),class_='search')}</li>
226 <li>${h.link_to(_('search'),h.url('search_repo',repo_name=c.repo_name),class_='search')}</li>
@@ -37,7 +37,7 b''
37 <a href="#" class="ui-btn small" id="rev_range_clear" style="display:none">${_('Clear selection')}</a>
37 <a href="#" class="ui-btn small" id="rev_range_clear" style="display:none">${_('Clear selection')}</a>
38
38
39 %if c.rhodecode_db_repo.fork:
39 %if c.rhodecode_db_repo.fork:
40 <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>
40 <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>
41 %endif
41 %endif
42 %if h.is_hg(c.rhodecode_repo):
42 %if h.is_hg(c.rhodecode_repo):
43 <a id="open_new_pr" href="${h.url('pullrequest_home',repo_name=c.repo_name)}" class="ui-btn small">${_('open new pull request')}</a>
43 <a id="open_new_pr" href="${h.url('pullrequest_home',repo_name=c.repo_name)}" class="ui-btn small">${_('open new pull request')}</a>
@@ -17,7 +17,7 b''
17 <div class="follower_date">${_('forked')} -
17 <div class="follower_date">${_('forked')} -
18 <span class="tooltip" title="${h.tooltip(h.fmt_date(f.created_on))}"> ${h.age(f.created_on)}</span>
18 <span class="tooltip" title="${h.tooltip(h.fmt_date(f.created_on))}"> ${h.age(f.created_on)}</span>
19 <a title="${_('compare fork with %s' % c.repo_name)}"
19 <a title="${_('compare fork with %s' % c.repo_name)}"
20 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')}"
20 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')}"
21 class="ui-btn small">${_('Compare fork')}</a>
21 class="ui-btn small">${_('Compare fork')}</a>
22 </div>
22 </div>
23 <div style="border-bottom: 1px solid #DDD;margin:10px 0px 10px 0px"></div>
23 <div style="border-bottom: 1px solid #DDD;margin:10px 0px 10px 0px"></div>
@@ -140,12 +140,12 b''
140 YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none');
140 YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none');
141 //url template
141 //url template
142 var url = "${h.url('compare_url',
142 var url = "${h.url('compare_url',
143 repo_name='__org_repo__',
143 repo_name='__other_repo__',
144 org_ref_type='__org_ref_type__',
144 org_ref_type='__other_ref_type__',
145 org_ref='__org_ref__',
145 org_ref='__other_ref__',
146 other_repo='__other_repo__',
146 other_repo='__org_repo__',
147 other_ref_type='__other_ref_type__',
147 other_ref_type='__org_ref_type__',
148 other_ref='__other_ref__',
148 other_ref='__org_ref__',
149 as_form=True,
149 as_form=True,
150 rev_start=request.GET.get('rev_start',''),
150 rev_start=request.GET.get('rev_start',''),
151 rev_end=request.GET.get('rev_end',''))}";
151 rev_end=request.GET.get('rev_end',''))}";
@@ -89,16 +89,16 b' class TestCompareController(TestControll'
89 rev1 = 'default'
89 rev1 = 'default'
90 rev2 = 'default'
90 rev2 = 'default'
91 response = self.app.get(url(controller='compare', action='index',
91 response = self.app.get(url(controller='compare', action='index',
92 repo_name=repo2.repo_name,
92 repo_name=repo1.repo_name,
93 org_ref_type="branch",
93 org_ref_type="branch",
94 org_ref=rev1,
94 org_ref=rev2,
95 other_repo=repo1.repo_name,
95 other_repo=repo2.repo_name,
96 other_ref_type="branch",
96 other_ref_type="branch",
97 other_ref=rev2,
97 other_ref=rev1,
98 ))
98 ))
99
99
100 try:
100 try:
101 response.mustcontain('%s@%s -&gt; %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2))
101 response.mustcontain('%s@%s -&gt; %s@%s' % (repo1.repo_name, rev2, repo2.repo_name, rev1))
102 response.mustcontain("""Showing 2 commits""")
102 response.mustcontain("""Showing 2 commits""")
103 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
103 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
104
104
@@ -108,9 +108,9 b' class TestCompareController(TestControll'
108 response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
108 response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
109 response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
109 response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
110 ## files
110 ## files
111 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))
111 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))
112 #swap
112 #swap
113 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))
113 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))
114 finally:
114 finally:
115 RepoModel().delete(r2_id)
115 RepoModel().delete(r2_id)
116 RepoModel().delete(r1_id)
116 RepoModel().delete(r1_id)
@@ -147,16 +147,16 b' class TestCompareController(TestControll'
147 rev1 = 'default'
147 rev1 = 'default'
148 rev2 = 'default'
148 rev2 = 'default'
149 response = self.app.get(url(controller='compare', action='index',
149 response = self.app.get(url(controller='compare', action='index',
150 repo_name=repo2.repo_name,
150 repo_name=repo1.repo_name,
151 org_ref_type="branch",
151 org_ref_type="branch",
152 org_ref=rev1,
152 org_ref=rev2,
153 other_repo=repo1.repo_name,
153 other_repo=repo2.repo_name,
154 other_ref_type="branch",
154 other_ref_type="branch",
155 other_ref=rev2,
155 other_ref=rev1,
156 ))
156 ))
157
157
158 try:
158 try:
159 response.mustcontain('%s@%s -&gt; %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2))
159 response.mustcontain('%s@%s -&gt; %s@%s' % (repo1.repo_name, rev2, repo2.repo_name, rev1))
160 response.mustcontain("""Showing 2 commits""")
160 response.mustcontain("""Showing 2 commits""")
161 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
161 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
162
162
@@ -166,9 +166,9 b' class TestCompareController(TestControll'
166 response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
166 response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
167 response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
167 response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
168 ## files
168 ## files
169 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))
169 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))
170 #swap
170 #swap
171 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))
171 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))
172 finally:
172 finally:
173 RepoModel().delete(r2_id)
173 RepoModel().delete(r2_id)
174 RepoModel().delete(r1_id)
174 RepoModel().delete(r1_id)
General Comments 0
You need to be logged in to leave comments. Login now