Mercurial > kallithea
comparison rhodecode/model/pull_request.py @ 3301:3c91ec4419a6 beta
pull requeset: move stuff around, preparing for next change
- and make sure we don't pass unicode to Mercurial
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 31 Jan 2013 23:27:21 +0100 |
parents | 2c0208bd686b |
children | ae5ac36cdf83 |
comparison
equal
deleted
inserted
replaced
3300:2c0208bd686b | 3301:3c91ec4419a6 |
---|---|
38 from rhodecode.model.notification import NotificationModel | 38 from rhodecode.model.notification import NotificationModel |
39 from rhodecode.lib.utils2 import safe_unicode | 39 from rhodecode.lib.utils2 import safe_unicode |
40 | 40 |
41 from rhodecode.lib.vcs.utils.hgcompat import discovery, localrepo, scmutil, \ | 41 from rhodecode.lib.vcs.utils.hgcompat import discovery, localrepo, scmutil, \ |
42 findcommonoutgoing | 42 findcommonoutgoing |
43 from rhodecode.lib.vcs.utils import safe_str | |
43 | 44 |
44 log = logging.getLogger(__name__) | 45 log = logging.getLogger(__name__) |
45 | 46 |
46 | 47 |
47 class PullRequestModel(BaseModel): | 48 class PullRequestModel(BaseModel): |
172 """ | 173 """ |
173 | 174 |
174 changesets = [] | 175 changesets = [] |
175 | 176 |
176 if alias == 'hg': | 177 if alias == 'hg': |
178 # lookup up the exact node id | |
179 _revset_predicates = { | |
180 'branch': 'branch', | |
181 'book': 'bookmark', | |
182 'tag': 'tag', | |
183 'rev': 'id', | |
184 } | |
185 org_rev_spec = "%s('%s')" % (_revset_predicates[org_ref[0]], | |
186 safe_str(org_ref[1])) | |
187 org_rev = scmutil.revsingle(org_repo._repo, | |
188 org_rev_spec) | |
189 other_rev_spec = "%s('%s')" % (_revset_predicates[other_ref[0]], | |
190 safe_str(other_ref[1])) | |
191 other_rev = scmutil.revsingle(other_repo._repo, other_rev_spec) | |
177 | 192 |
178 #case two independent repos | 193 #case two independent repos |
179 if org_repo != other_repo: | 194 if org_repo != other_repo: |
180 revs = [ | 195 revs = [ |
181 org_repo._repo.lookup(org_ref[1]), | 196 org_repo._repo.lookup(org_ref[1]), |
182 org_repo._repo.lookup(other_ref[1]), | 197 org_repo._repo.lookup(other_ref[1]), # lookup up in the wrong repo! |
183 ] | 198 ] |
184 | 199 |
185 obj = findcommonoutgoing(org_repo._repo, | 200 obj = findcommonoutgoing(org_repo._repo, |
186 localrepo.locallegacypeer(other_repo._repo.local()), | 201 localrepo.locallegacypeer(other_repo._repo.local()), |
187 revs, | 202 revs, |
198 stop = other_ref[1] | 213 stop = other_ref[1] |
199 changesets = changesets[revs.index(start):revs.index(stop) + 1] | 214 changesets = changesets[revs.index(start):revs.index(stop) + 1] |
200 | 215 |
201 #no remote compare do it on the same repository | 216 #no remote compare do it on the same repository |
202 else: | 217 else: |
203 _revset_predicates = { | 218 revs = ["ancestors(id('%s')) and not ancestors(id('%s'))" % |
204 'branch': 'branch', | 219 (other_rev, org_rev)] |
205 'book': 'bookmark', | 220 |
206 'tag': 'tag', | |
207 'rev': 'id', | |
208 } | |
209 | |
210 revs = [ | |
211 "ancestors(%s('%s')) and not ancestors(%s('%s'))" % ( | |
212 _revset_predicates[other_ref[0]], other_ref[1], | |
213 _revset_predicates[org_ref[0]], org_ref[1], | |
214 ) | |
215 ] | |
216 | |
217 out = scmutil.revrange(org_repo._repo, revs) | 221 out = scmutil.revrange(org_repo._repo, revs) |
218 for cs in (out): | 222 for cs in (out): |
219 changesets.append(org_repo.get_changeset(cs)) | 223 changesets.append(org_repo.get_changeset(cs)) |
220 | 224 |
221 elif alias == 'git': | 225 elif alias == 'git': |
230 | 234 |
231 return changesets | 235 return changesets |
232 | 236 |
233 def get_compare_data(self, org_repo, org_ref, other_repo, other_ref): | 237 def get_compare_data(self, org_repo, org_ref, other_repo, other_ref): |
234 """ | 238 """ |
235 Returns incomming changesets for mercurial repositories | 239 Returns incoming changesets for mercurial repositories |
236 | 240 |
237 :param org_repo: | 241 :param org_repo: |
238 :type org_repo: | 242 :type org_repo: |
239 :param org_ref: | 243 :param org_ref: |
240 :type org_ref: | 244 :type org_ref: |