Show More
@@ -89,6 +89,15 b' class CompareController(BaseRepoControll' | |||
|
89 | 89 | # other_ref will be evaluated in other_repo |
|
90 | 90 | other_ref = (other_ref_type, other_ref) |
|
91 | 91 | other_repo = request.GET.get('other_repo', org_repo) |
|
92 | # If merge is True: | |
|
93 | # Show what org would get if merged with other: | |
|
94 | # List changesets that are ancestors of other but not of org. | |
|
95 | # New changesets in org is thus ignored. | |
|
96 | # Diff will be from common ancestor, and merges of org to other will thus be ignored. | |
|
97 | # If merge is False: | |
|
98 | # Make a raw diff from org to other, no matter if related or not. | |
|
99 | # Changesets in one and not in the other will be ignored | |
|
100 | merge = bool(request.GET.get('merge')) | |
|
92 | 101 | # fulldiff disables cut_off_limit |
|
93 | 102 | c.fulldiff = request.GET.get('fulldiff') |
|
94 | 103 | # partial uses compare_cs.html template directly |
@@ -100,7 +109,8 b' class CompareController(BaseRepoControll' | |||
|
100 | 109 | repo_name=other_repo, |
|
101 | 110 | org_ref_type=other_ref[0], org_ref=other_ref[1], |
|
102 | 111 | other_repo=org_repo, |
|
103 |
other_ref_type=org_ref[0], other_ref=org_ref[1] |
|
|
112 | other_ref_type=org_ref[0], other_ref=org_ref[1], | |
|
113 | merge=merge or '') | |
|
104 | 114 | |
|
105 | 115 | org_repo = Repository.get_by_repo_name(org_repo) |
|
106 | 116 | other_repo = Repository.get_by_repo_name(other_repo) |
@@ -130,22 +140,23 b' class CompareController(BaseRepoControll' | |||
|
130 | 140 | c.org_ref_type = org_ref[0] |
|
131 | 141 | c.other_ref_type = other_ref[0] |
|
132 | 142 | |
|
133 | c.cs_ranges, ancestor = PullRequestModel().get_compare_data( | |
|
134 | org_repo, org_ref, other_repo, other_ref) | |
|
143 | c.cs_ranges, c.ancestor = PullRequestModel().get_compare_data( | |
|
144 | org_repo, org_ref, other_repo, other_ref, merge) | |
|
135 | 145 | |
|
136 | 146 | c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in |
|
137 | 147 | c.cs_ranges]) |
|
138 | 148 | if partial: |
|
149 | assert c.ancestor | |
|
139 | 150 | return render('compare/compare_cs.html') |
|
140 | 151 | |
|
141 | if ancestor and org_repo != other_repo: | |
|
152 | if c.ancestor: | |
|
153 | assert merge | |
|
142 | 154 | # case we want a simple diff without incoming changesets, |
|
143 | 155 | # previewing what will be merged. |
|
144 |
# Make the diff on the |
|
|
145 | # revision that is common ancestor | |
|
156 | # Make the diff on the other repo (which is known to have other_ref) | |
|
146 | 157 | log.debug('Using ancestor %s as org_ref instead of %s' |
|
147 | % (ancestor, org_ref)) | |
|
148 | org_ref = ('rev', ancestor) | |
|
158 | % (c.ancestor, org_ref)) | |
|
159 | org_ref = ('rev', c.ancestor) | |
|
149 | 160 | org_repo = other_repo |
|
150 | 161 | |
|
151 | 162 | diff_limit = self.cut_off_limit if not c.fulldiff else None |
@@ -196,9 +196,9 b' class PullrequestsController(BaseRepoCon' | |||
|
196 | 196 | return redirect(url('pullrequest_home', repo_name=repo_name)) |
|
197 | 197 | |
|
198 | 198 | org_repo = _form['org_repo'] |
|
199 |
org_ref = _form[' |
|
|
199 | org_ref = 'rev:merge:%s' % _form['merge_rev'] | |
|
200 | 200 | other_repo = _form['other_repo'] |
|
201 |
other_ref = _form[' |
|
|
201 | other_ref = 'rev:ancestor:%s' % _form['ancestor_rev'] | |
|
202 | 202 | revisions = _form['revisions'] |
|
203 | 203 | reviewers = _form['review_members'] |
|
204 | 204 | |
@@ -281,10 +281,6 b' class PullrequestsController(BaseRepoCon' | |||
|
281 | 281 | |
|
282 | 282 | c.cs_ranges = [org_repo.get_changeset(x) for x in pull_request.revisions] |
|
283 | 283 | |
|
284 | other_ref = ('rev', getattr(c.cs_ranges[0].parents[0] | |
|
285 | if c.cs_ranges[0].parents | |
|
286 | else EmptyChangeset(), 'raw_id')) | |
|
287 | ||
|
288 | 284 | c.statuses = org_repo.statuses([x.raw_id for x in c.cs_ranges]) |
|
289 | 285 | |
|
290 | 286 | c.org_ref = org_ref[1] |
@@ -385,6 +381,7 b' class PullrequestsController(BaseRepoCon' | |||
|
385 | 381 | c.changeset_statuses = ChangesetStatus.STATUSES |
|
386 | 382 | |
|
387 | 383 | c.as_form = False |
|
384 | c.ancestor = None # there is one - but right here we don't know which | |
|
388 | 385 | return render('/pullrequests/pullrequest_show.html') |
|
389 | 386 | |
|
390 | 387 | @NotAnonymous() |
@@ -395,4 +395,7 b' def PullRequestForm(repo_id):' | |||
|
395 | 395 | pullrequest_title = v.UnicodeString(strip=True, required=True, min=3) |
|
396 | 396 | pullrequest_desc = v.UnicodeString(strip=True, required=False) |
|
397 | 397 | |
|
398 | ancestor_rev = v.UnicodeString(strip=True, required=True) | |
|
399 | merge_rev = v.UnicodeString(strip=True, required=True) | |
|
400 | ||
|
398 | 401 | return _PullRequestForm |
@@ -161,7 +161,7 b' class PullRequestModel(BaseModel):' | |||
|
161 | 161 | pull_request.updated_on = datetime.datetime.now() |
|
162 | 162 | Session().add(pull_request) |
|
163 | 163 | |
|
164 | def _get_changesets(self, alias, org_repo, org_ref, other_repo, other_ref): | |
|
164 | def _get_changesets(self, alias, org_repo, org_ref, other_repo, other_ref, merge): | |
|
165 | 165 | """ |
|
166 | 166 | Returns a list of changesets that can be merged from org_repo@org_ref |
|
167 | 167 | to other_repo@other_ref ... and the ancestor that would be used for merge |
@@ -211,16 +211,21 b' class PullRequestModel(BaseModel):' | |||
|
211 | 211 | else: |
|
212 | 212 | hgrepo = other_repo._repo |
|
213 | 213 | |
|
214 | revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" % | |
|
215 | (other_rev, org_rev)] | |
|
216 | changesets = [other_repo.get_changeset(cs) | |
|
217 | for cs in scmutil.revrange(hgrepo, revs)] | |
|
214 | if merge: | |
|
215 | revs = ["ancestors(id('%s')) and not ancestors(id('%s')) and not id('%s')" % | |
|
216 | (other_rev, org_rev, org_rev)] | |
|
218 | 217 | |
|
219 | if org_repo != other_repo: | |
|
220 | 218 | ancestors = scmutil.revrange(hgrepo, |
|
221 | 219 | ["ancestor(id('%s'), id('%s'))" % (org_rev, other_rev)]) |
|
222 | 220 | if len(ancestors) == 1: |
|
223 | 221 | ancestor = hgrepo[ancestors[0]].hex() |
|
222 | else: | |
|
223 | # TODO: have both + and - changesets | |
|
224 | revs = ["id('%s') :: id('%s') - id('%s')" % | |
|
225 | (org_rev, other_rev, org_rev)] | |
|
226 | ||
|
227 | changesets = [other_repo.get_changeset(cs) | |
|
228 | for cs in scmutil.revrange(hgrepo, revs)] | |
|
224 | 229 | |
|
225 | 230 | elif alias == 'git': |
|
226 | 231 | assert org_repo == other_repo, (org_repo, other_repo) # no git support for different repos |
@@ -233,7 +238,7 b' class PullRequestModel(BaseModel):' | |||
|
233 | 238 | |
|
234 | 239 | return changesets, ancestor |
|
235 | 240 | |
|
236 | def get_compare_data(self, org_repo, org_ref, other_repo, other_ref): | |
|
241 | def get_compare_data(self, org_repo, org_ref, other_repo, other_ref, merge): | |
|
237 | 242 | """ |
|
238 | 243 | Returns incoming changesets for mercurial repositories |
|
239 | 244 | |
@@ -251,5 +256,6 b' class PullRequestModel(BaseModel):' | |||
|
251 | 256 | |
|
252 | 257 | cs_ranges, ancestor = self._get_changesets(org_repo.scm_instance.alias, |
|
253 | 258 | org_repo.scm_instance, org_ref, |
|
254 |
other_repo.scm_instance, other_ref |
|
|
259 | other_repo.scm_instance, other_ref, | |
|
260 | merge) | |
|
255 | 261 | return cs_ranges, ancestor |
@@ -37,7 +37,7 b'' | |||
|
37 | 37 | <a href="#" class="ui-btn small" id="rev_range_clear" style="display:none">${_('Clear selection')}</a> |
|
38 | 38 | |
|
39 | 39 | %if c.rhodecode_db_repo.fork: |
|
40 | <a id="compare_fork" 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> | |
|
40 | <a id="compare_fork" 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',merge=1)}" class="ui-btn small">${_('Compare fork with parent')}</a> | |
|
41 | 41 | %endif |
|
42 | 42 | %if h.is_hg(c.rhodecode_repo): |
|
43 | 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> |
@@ -1,9 +1,9 b'' | |||
|
1 | 1 | ## Changesets table ! |
|
2 | 2 | <div class="container"> |
|
3 | <table class="compare_view_commits noborder"> | |
|
4 | 3 | %if not c.cs_ranges: |
|
5 | 4 | <span class="empty_data">${_('No changesets')}</span> |
|
6 | 5 | %else: |
|
6 | <table class="compare_view_commits noborder"> | |
|
7 | 7 | %for cnt, cs in enumerate(c.cs_ranges): |
|
8 | 8 | <tr> |
|
9 | 9 | <td><div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(h.email_or_none(cs.author),14)}"/></div></td> |
@@ -22,7 +22,15 b'' | |||
|
22 | 22 | <td><div class="message tooltip" title="${h.tooltip(cs.message)}" style="white-space:normal">${h.urlify_commit(h.shorter(cs.message, 60),c.repo_name)}</div></td> |
|
23 | 23 | </tr> |
|
24 | 24 | %endfor |
|
25 | ||
|
25 | </table> | |
|
26 | %if c.ancestor: | |
|
27 | <span class="ancestor">${_('Ancestor')}: | |
|
28 | ${h.link_to(c.ancestor,h.url('changeset_home',repo_name=c.repo_name,revision=c.ancestor))} | |
|
29 | </span> | |
|
26 | 30 | %endif |
|
27 | </table> | |
|
31 | %if c.as_form: | |
|
32 | ${h.hidden('ancestor_rev',c.ancestor)} | |
|
33 | ${h.hidden('merge_rev',c.cs_ranges[-1].raw_id)} | |
|
34 | %endif | |
|
35 | %endif | |
|
28 | 36 | </div> |
@@ -133,6 +133,7 b'' | |||
|
133 | 133 | other_ref_type='__org_ref_type__', |
|
134 | 134 | other_ref='__org_ref__', |
|
135 | 135 | as_form=True, |
|
136 | merge=True, | |
|
136 | 137 | )}"; |
|
137 | 138 | var org_repo = YUQ('#pull_request_form #org_repo')[0].value; |
|
138 | 139 | var org_ref = YUQ('#pull_request_form #org_ref')[0].value.split(':'); |
@@ -106,6 +106,7 b' class TestCompareController(TestControll' | |||
|
106 | 106 | other_repo=repo2.repo_name, |
|
107 | 107 | other_ref_type="branch", |
|
108 | 108 | other_ref=rev1, |
|
109 | merge='1', | |
|
109 | 110 | )) |
|
110 | 111 | |
|
111 | 112 | response.mustcontain('%s@%s -> %s@%s' % (repo1.repo_name, rev2, repo2.repo_name, rev1)) |
@@ -118,9 +119,9 b' class TestCompareController(TestControll' | |||
|
118 | 119 | response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id)) |
|
119 | 120 | response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id)) |
|
120 | 121 | ## files |
|
121 | 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)) | |
|
122 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s&merge=1#C--826e8142e6ba">file1</a>""" % (repo1.repo_name, rev2, rev1, repo2.repo_name)) | |
|
122 | 123 | #swap |
|
123 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name)) | |
|
124 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s&merge=True">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name)) | |
|
124 | 125 | |
|
125 | 126 | def test_compare_forks_on_branch_extra_commits_origin_has_incomming_hg(self): |
|
126 | 127 | self.log_user() |
@@ -160,6 +161,7 b' class TestCompareController(TestControll' | |||
|
160 | 161 | other_repo=repo2.repo_name, |
|
161 | 162 | other_ref_type="branch", |
|
162 | 163 | other_ref=rev1, |
|
164 | merge='x', | |
|
163 | 165 | )) |
|
164 | 166 | response.mustcontain('%s@%s -> %s@%s' % (repo1.repo_name, rev2, repo2.repo_name, rev1)) |
|
165 | 167 | response.mustcontain("""Showing 2 commits""") |
@@ -171,9 +173,9 b' class TestCompareController(TestControll' | |||
|
171 | 173 | response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id)) |
|
172 | 174 | response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id)) |
|
173 | 175 | ## files |
|
174 | 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)) | |
|
176 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s&merge=x#C--826e8142e6ba">file1</a>""" % (repo1.repo_name, rev2, rev1, repo2.repo_name)) | |
|
175 | 177 | #swap |
|
176 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name)) | |
|
178 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s&merge=True">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name)) | |
|
177 | 179 | |
|
178 | 180 | def test_compare_cherry_pick_changesets_from_bottom(self): |
|
179 | 181 | |
@@ -222,6 +224,7 b' class TestCompareController(TestControll' | |||
|
222 | 224 | other_repo=repo1.repo_name, |
|
223 | 225 | other_ref_type="rev", |
|
224 | 226 | other_ref=cs4.short_id, |
|
227 | merge='True', | |
|
225 | 228 | )) |
|
226 | 229 | response.mustcontain('%s@%s -> %s@%s' % (repo2.repo_name, cs1.short_id, repo1.repo_name, cs4.short_id)) |
|
227 | 230 | response.mustcontain("""Showing 3 commits""") |
@@ -281,6 +284,7 b' class TestCompareController(TestControll' | |||
|
281 | 284 | org_ref=cs2.short_id, # parent of cs3, not in repo2 |
|
282 | 285 | other_ref_type="rev", |
|
283 | 286 | other_ref=cs5.short_id, |
|
287 | merge='1', | |
|
284 | 288 | )) |
|
285 | 289 | |
|
286 | 290 | response.mustcontain('%s@%s -> %s@%s' % (repo1.repo_name, cs2.short_id, repo1.repo_name, cs5.short_id)) |
@@ -319,6 +323,7 b' class TestCompareController(TestControll' | |||
|
319 | 323 | other_ref_type="rev", |
|
320 | 324 | other_ref=rev2, |
|
321 | 325 | other_repo=HG_FORK, |
|
326 | merge='1', | |
|
322 | 327 | )) |
|
323 | 328 | response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_FORK, rev2)) |
|
324 | 329 | ## outgoing changesets between those revisions |
@@ -328,9 +333,9 b' class TestCompareController(TestControll' | |||
|
328 | 333 | response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_FORK, rev2)) |
|
329 | 334 | |
|
330 | 335 | ## files |
|
331 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK)) | |
|
332 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK)) | |
|
333 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK)) | |
|
336 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s&merge=1#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK)) | |
|
337 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s&merge=1#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK)) | |
|
338 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s&merge=1#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK)) | |
|
334 | 339 | |
|
335 | 340 | def test_org_repo_new_commits_after_forking_simple_diff(self): |
|
336 | 341 | self.log_user() |
@@ -401,6 +406,7 b' class TestCompareController(TestControll' | |||
|
401 | 406 | other_ref_type="branch", |
|
402 | 407 | other_ref=rev2, |
|
403 | 408 | other_repo=r1_name, |
|
409 | merge='1', | |
|
404 | 410 | )) |
|
405 | 411 | response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) |
|
406 | 412 | response.mustcontain('No files') |
@@ -425,6 +431,7 b' class TestCompareController(TestControll' | |||
|
425 | 431 | other_ref_type="branch", |
|
426 | 432 | other_ref=rev2, |
|
427 | 433 | other_repo=r1_name, |
|
434 | merge='1', | |
|
428 | 435 | )) |
|
429 | 436 | |
|
430 | 437 | response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) |
General Comments 0
You need to be logged in to leave comments.
Login now