Show More
@@ -126,9 +126,8 b' class CompareController(BaseRepoControll' | |||||
126 | org_ref = ('rev', rev_start) |
|
126 | org_ref = ('rev', rev_start) | |
127 | other_ref = ('rev', rev_end) |
|
127 | other_ref = ('rev', rev_end) | |
128 |
|
128 | |||
129 | c.cs_ranges = PullRequestModel().get_compare_data( |
|
129 | c.cs_ranges, ancestor = PullRequestModel().get_compare_data( | |
130 |
|
|
130 | org_repo, org_ref, other_repo, other_ref) | |
131 | ) |
|
|||
132 |
|
131 | |||
133 | c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in |
|
132 | c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in | |
134 | c.cs_ranges]) |
|
133 | c.cs_ranges]) | |
@@ -141,15 +140,14 b' class CompareController(BaseRepoControll' | |||||
141 | c.org_ref = org_ref[1] |
|
140 | c.org_ref = org_ref[1] | |
142 | c.other_ref = other_ref[1] |
|
141 | c.other_ref = other_ref[1] | |
143 |
|
142 | |||
144 |
if |
|
143 | if ancestor and c.org_repo != c.other_repo: | |
145 |
# case we want a simple diff without incoming changesets, |
|
144 | # case we want a simple diff without incoming changesets, | |
146 | # for review purposes. Make the diff on the forked repo, with |
|
145 | # previewing what will be merged. | |
|
146 | # Make the diff on the forked repo, with | |||
147 | # revision that is common ancestor |
|
147 | # revision that is common ancestor | |
148 | _org_ref = org_ref |
|
148 | _org_ref = org_ref | |
149 | org_ref = ('rev', getattr(c.cs_ranges[0].parents[0] |
|
149 | log.debug('Using ancestor %s as org_ref instead of %s', ancestor, _org_ref) | |
150 | if c.cs_ranges[0].parents |
|
150 | org_ref = ('rev', ancestor) | |
151 | else EmptyChangeset(), 'raw_id')) |
|
|||
152 | log.debug('Changed org_ref from %s to %s' % (_org_ref, org_ref)) |
|
|||
153 | org_repo = other_repo |
|
151 | org_repo = other_repo | |
154 |
|
152 | |||
155 | diff_limit = self.cut_off_limit if not fulldiff else None |
|
153 | diff_limit = self.cut_off_limit if not fulldiff else None |
@@ -713,4 +713,4 b' def differ(org_repo, org_ref, other_repo' | |||||
713 | ignore_whitespace=ignore_whitespace, context=context) |
|
713 | ignore_whitespace=ignore_whitespace, context=context) | |
714 | return _diff |
|
714 | return _diff | |
715 |
|
715 | |||
716 | return '' |
|
716 | return '' # FIXME: when is it ever relevant to return nothing? |
@@ -160,8 +160,8 b' class PullRequestModel(BaseModel):' | |||||
160 |
|
160 | |||
161 | def _get_changesets(self, alias, org_repo, org_ref, other_repo, other_ref): |
|
161 | def _get_changesets(self, alias, org_repo, org_ref, other_repo, other_ref): | |
162 | """ |
|
162 | """ | |
163 |
Returns a list of changesets that |
|
163 | Returns a list of changesets that can be merged from org_repo@org_ref | |
164 | to other_repo@other_ref |
|
164 | to other_repo@other_ref ... and the ancestor that would be used for merge | |
165 |
|
165 | |||
166 | :param org_repo: |
|
166 | :param org_repo: | |
167 | :param org_ref: |
|
167 | :param org_ref: | |
@@ -170,7 +170,7 b' class PullRequestModel(BaseModel):' | |||||
170 | :param tmp: |
|
170 | :param tmp: | |
171 | """ |
|
171 | """ | |
172 |
|
172 | |||
173 |
|
|
173 | ancestor = None | |
174 |
|
174 | |||
175 | if alias == 'hg': |
|
175 | if alias == 'hg': | |
176 | # lookup up the exact node id |
|
176 | # lookup up the exact node id | |
@@ -202,9 +202,14 b' class PullRequestModel(BaseModel):' | |||||
202 |
|
202 | |||
203 | revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" % |
|
203 | revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" % | |
204 | (other_rev, org_rev)] |
|
204 | (other_rev, org_rev)] | |
205 | out = scmutil.revrange(hgrepo, revs) |
|
205 | changesets = [other_repo.get_changeset(cs) | |
206 | for cs in (out): |
|
206 | for cs in scmutil.revrange(hgrepo, revs)] | |
207 | changesets.append(other_repo.get_changeset(cs)) |
|
207 | ||
|
208 | if org_repo != other_repo: | |||
|
209 | ancestors = scmutil.revrange(hgrepo, | |||
|
210 | ["ancestor(id('%s'), id('%s'))" % (org_rev, other_rev)]) | |||
|
211 | if len(ancestors) == 1: | |||
|
212 | ancestor = hgrepo[ancestors[0]].hex() | |||
208 |
|
213 | |||
209 | elif alias == 'git': |
|
214 | elif alias == 'git': | |
210 | assert org_repo == other_repo, (org_repo, other_repo) # no git support for different repos |
|
215 | assert org_repo == other_repo, (org_repo, other_repo) # no git support for different repos | |
@@ -212,11 +217,10 b' class PullRequestModel(BaseModel):' | |||||
212 | 'log --reverse --pretty="format: %%H" -s -p %s..%s' % (org_ref[1], |
|
217 | 'log --reverse --pretty="format: %%H" -s -p %s..%s' % (org_ref[1], | |
213 | other_ref[1]) |
|
218 | other_ref[1]) | |
214 | ) |
|
219 | ) | |
215 | ids = re.findall(r'[0-9a-fA-F]{40}', so) |
|
220 | changesets = [org_repo.get_changeset(cs) | |
216 | for cs in (ids): |
|
221 | for cs in re.findall(r'[0-9a-fA-F]{40}', so)] | |
217 | changesets.append(org_repo.get_changeset(cs)) |
|
|||
218 |
|
222 | |||
219 | return changesets |
|
223 | return changesets, ancestor | |
220 |
|
224 | |||
221 | def get_compare_data(self, org_repo, org_ref, other_repo, other_ref): |
|
225 | def get_compare_data(self, org_repo, org_ref, other_repo, other_ref): | |
222 | """ |
|
226 | """ | |
@@ -242,7 +246,7 b' class PullRequestModel(BaseModel):' | |||||
242 | other_repo_scm = other_repo.scm_instance |
|
246 | other_repo_scm = other_repo.scm_instance | |
243 |
|
247 | |||
244 | alias = org_repo.scm_instance.alias |
|
248 | alias = org_repo.scm_instance.alias | |
245 | cs_ranges = self._get_changesets(alias, |
|
249 | cs_ranges, ancestor = self._get_changesets(alias, | |
246 | org_repo_scm, org_ref, |
|
250 | org_repo_scm, org_ref, | |
247 | other_repo_scm, other_ref) |
|
251 | other_repo_scm, other_ref) | |
248 | return cs_ranges |
|
252 | return cs_ranges, ancestor |
General Comments 0
You need to be logged in to leave comments.
Login now