Mercurial > kallithea
annotate rhodecode/model/pull_request.py @ 2501:044c31d67ccc beta
make get_action always return action
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 21 Jun 2012 17:51:01 +0200 |
parents | 3bf057a7f7e8 |
children | 17893d61792a |
rev | line source |
---|---|
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 """ |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 rhodecode.model.pull_reuquest |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 pull request model for RhodeCode |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 :created_on: Jun 6, 2012 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :author: marcink |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 :copyright: (C) 2012-2012 Marcin Kuzminski <marcin@python-works.com> |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 """ |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 # (at your option) any later version. |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 # |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 import logging |
2442
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
27 import binascii |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 from pylons.i18n.translation import _ |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 from rhodecode.lib import helpers as h |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 from rhodecode.model import BaseModel |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 from rhodecode.model.db import PullRequest, PullRequestReviewers, Notification |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 from rhodecode.model.notification import NotificationModel |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 from rhodecode.lib.utils2 import safe_unicode |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 |
2442
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
36 from rhodecode.lib.vcs.utils.hgcompat import discovery |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
37 |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 log = logging.getLogger(__name__) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 class PullRequestModel(BaseModel): |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
43 def get_all(self, repo): |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
44 repo = self._get_repo(repo) |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
45 return PullRequest.query().filter(PullRequest.other_repo == repo).all() |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
46 |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 def create(self, created_by, org_repo, org_ref, other_repo, |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 other_ref, revisions, reviewers, title, description=None): |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
49 created_by_user = self._get_user(created_by) |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 new = PullRequest() |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 new.org_repo = self._get_repo(org_repo) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 new.org_ref = org_ref |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 new.other_repo = self._get_repo(other_repo) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 new.other_ref = other_ref |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 new.revisions = revisions |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 new.title = title |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 new.description = description |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
59 new.author = created_by_user |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 self.sa.add(new) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 #members |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 for member in reviewers: |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 _usr = self._get_user(member) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 reviewer = PullRequestReviewers(_usr, new) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 self.sa.add(reviewer) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 #notification to reviewers |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 notif = NotificationModel() |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
70 |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 subject = safe_unicode( |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 h.link_to( |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 _('%(user)s wants you to review pull request #%(pr_id)s') % \ |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 {'user': created_by_user.username, |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 'pr_id': new.pull_request_id}, |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
76 h.url('pullrequest_show', repo_name=other_repo, |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
77 pull_request_id=new.pull_request_id, |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
78 qualified=True, |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
79 ) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
80 ) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
81 ) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
82 body = description |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
83 notif.create(created_by=created_by, subject=subject, body=body, |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 recipients=reviewers, |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
85 type_=Notification.TYPE_PULL_REQUEST,) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
86 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
87 return new |
2442
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
88 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
89 def _get_changesets(self, org_repo, org_ref, other_repo, other_ref, |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
90 discovery_data): |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
91 """ |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
92 Returns a list of changesets that are incoming from org_repo@org_ref |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
93 to other_repo@other_ref |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
94 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
95 :param org_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
96 :type org_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
97 :param org_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
98 :type org_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
99 :param other_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
100 :type other_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
101 :param other_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
102 :type other_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
103 :param tmp: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
104 :type tmp: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
105 """ |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
106 changesets = [] |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
107 #case two independent repos |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
108 if org_repo != other_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
109 common, incoming, rheads = discovery_data |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
110 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
111 if not incoming: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
112 revs = [] |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
113 else: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
114 revs = org_repo._repo.changelog.findmissing(common, rheads) |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
115 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
116 for cs in reversed(map(binascii.hexlify, revs)): |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
117 changesets.append(org_repo.get_changeset(cs)) |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
118 else: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
119 revs = ['ancestors(%s) and not ancestors(%s)' % (org_ref[1], |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
120 other_ref[1])] |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
121 from mercurial import scmutil |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
122 out = scmutil.revrange(org_repo._repo, revs) |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
123 for cs in reversed(out): |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
124 changesets.append(org_repo.get_changeset(cs)) |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
125 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
126 return changesets |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
127 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
128 def _get_discovery(self, org_repo, org_ref, other_repo, other_ref): |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
129 """ |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
130 Get's mercurial discovery data used to calculate difference between |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
131 repos and refs |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
132 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
133 :param org_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
134 :type org_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
135 :param org_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
136 :type org_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
137 :param other_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
138 :type other_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
139 :param other_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
140 :type other_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
141 """ |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
142 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
143 other = org_repo._repo |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
144 repo = other_repo._repo |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
145 tip = other[org_ref[1]] |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
146 log.debug('Doing discovery for %s@%s vs %s@%s' % ( |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
147 org_repo, org_ref, other_repo, other_ref) |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
148 ) |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
149 log.debug('Filter heads are %s[%s]' % (tip, org_ref[1])) |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
150 tmp = discovery.findcommonincoming( |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
151 repo=repo, # other_repo we check for incoming |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
152 remote=other, # org_repo source for incoming |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
153 heads=[tip.node()], |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
154 force=False |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
155 ) |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
156 return tmp |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
157 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
158 def get_compare_data(self, org_repo, org_ref, other_repo, other_ref): |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
159 """ |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
160 Returns a tuple of incomming changesets, and discoverydata cache |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
161 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
162 :param org_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
163 :type org_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
164 :param org_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
165 :type org_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
166 :param other_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
167 :type other_repo: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
168 :param other_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
169 :type other_ref: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
170 """ |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
171 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
172 if len(org_ref) != 2 or not isinstance(org_ref, (list, tuple)): |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
173 raise Exception('org_ref must be a two element list/tuple') |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
174 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
175 if len(other_ref) != 2 or not isinstance(org_ref, (list, tuple)): |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
176 raise Exception('other_ref must be a two element list/tuple') |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
177 |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
178 discovery_data = self._get_discovery(org_repo.scm_instance, |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
179 org_ref, |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
180 other_repo.scm_instance, |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
181 other_ref) |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
182 cs_ranges = self._get_changesets(org_repo.scm_instance, |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
183 org_ref, |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
184 other_repo.scm_instance, |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
185 other_ref, |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
186 discovery_data) |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
187 return cs_ranges, discovery_data |