Mercurial > kallithea
comparison rhodecode/model/pull_request.py @ 3303:ae5ac36cdf83 beta
pull request: use unionrepo instead of outgoing
This makes it possible to look the 'moving target' symbols up in the right repo.
Using a revset with the right revisions also removes the need for pruning
changesets that are outside the requested range.
It will also not be confused by changesets that for some reason has been pulled
to the repo but haven't been merged yet. They are going to be 'merged' by the
'pull' request and should thus be a part of what is reviewed.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 03 Jan 2013 18:05:18 +0100 |
parents | 3c91ec4419a6 |
children | fc08484c5bf3 |
comparison
equal
deleted
inserted
replaced
3302:ead7a902998c | 3303:ae5ac36cdf83 |
---|---|
22 # | 22 # |
23 # You should have received a copy of the GNU General Public License | 23 # You should have received a copy of the GNU General Public License |
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 | 25 |
26 import logging | 26 import logging |
27 import binascii | |
28 import datetime | 27 import datetime |
29 import re | 28 import re |
30 | 29 |
31 from pylons.i18n.translation import _ | 30 from pylons.i18n.translation import _ |
32 | 31 |
33 from rhodecode.model.meta import Session | 32 from rhodecode.model.meta import Session |
34 from rhodecode.lib import helpers as h | 33 from rhodecode.lib import helpers as h, unionrepo |
35 from rhodecode.model import BaseModel | 34 from rhodecode.model import BaseModel |
36 from rhodecode.model.db import PullRequest, PullRequestReviewers, Notification,\ | 35 from rhodecode.model.db import PullRequest, PullRequestReviewers, Notification,\ |
37 ChangesetStatus | 36 ChangesetStatus |
38 from rhodecode.model.notification import NotificationModel | 37 from rhodecode.model.notification import NotificationModel |
39 from rhodecode.lib.utils2 import safe_unicode | 38 from rhodecode.lib.utils2 import safe_unicode |
40 | 39 |
41 from rhodecode.lib.vcs.utils.hgcompat import discovery, localrepo, scmutil, \ | 40 from rhodecode.lib.vcs.utils.hgcompat import scmutil |
42 findcommonoutgoing | |
43 from rhodecode.lib.vcs.utils import safe_str | 41 from rhodecode.lib.vcs.utils import safe_str |
44 | 42 |
45 log = logging.getLogger(__name__) | 43 log = logging.getLogger(__name__) |
46 | 44 |
47 | 45 |
190 safe_str(other_ref[1])) | 188 safe_str(other_ref[1])) |
191 other_rev = scmutil.revsingle(other_repo._repo, other_rev_spec) | 189 other_rev = scmutil.revsingle(other_repo._repo, other_rev_spec) |
192 | 190 |
193 #case two independent repos | 191 #case two independent repos |
194 if org_repo != other_repo: | 192 if org_repo != other_repo: |
195 revs = [ | 193 hgrepo = unionrepo.unionrepository(org_repo.baseui, |
196 org_repo._repo.lookup(org_ref[1]), | 194 org_repo.path, |
197 org_repo._repo.lookup(other_ref[1]), # lookup up in the wrong repo! | 195 other_repo.path) |
198 ] | 196 revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" % |
199 | 197 (org_rev, other_rev)] |
200 obj = findcommonoutgoing(org_repo._repo, | |
201 localrepo.locallegacypeer(other_repo._repo.local()), | |
202 revs, | |
203 force=True) | |
204 revs = obj.missing | |
205 | |
206 for cs in map(binascii.hexlify, revs): | |
207 _cs = org_repo.get_changeset(cs) | |
208 changesets.append(_cs) | |
209 # in case we have revisions filter out the ones not in given range | |
210 if org_ref[0] == 'rev' and other_ref[0] == 'rev': | |
211 revs = [x.raw_id for x in changesets] | |
212 start = org_ref[1] | |
213 stop = other_ref[1] | |
214 changesets = changesets[revs.index(start):revs.index(stop) + 1] | |
215 | 198 |
216 #no remote compare do it on the same repository | 199 #no remote compare do it on the same repository |
217 else: | 200 else: |
201 hgrepo = org_repo._repo | |
218 revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" % | 202 revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" % |
219 (other_rev, org_rev)] | 203 (other_rev, org_rev)] |
220 | 204 |
221 out = scmutil.revrange(org_repo._repo, revs) | 205 out = scmutil.revrange(hgrepo, revs) |
222 for cs in (out): | 206 for cs in (out): |
223 changesets.append(org_repo.get_changeset(cs)) | 207 changesets.append(org_repo.get_changeset(cs)) |
224 | 208 |
225 elif alias == 'git': | 209 elif alias == 'git': |
226 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 |
227 so, se = org_repo.run_git_command( | 211 so, se = org_repo.run_git_command( |
228 'log --reverse --pretty="format: %%H" -s -p %s..%s' % (org_ref[1], | 212 'log --reverse --pretty="format: %%H" -s -p %s..%s' % (org_ref[1], |