##// END OF EJS Templates
set the status of changesets initially on pull request, and make sure we care of version collisions....
marcink -
r3175:5d1d25c1 beta
parent child Browse files
Show More
@@ -224,6 +224,7 b' class PullrequestsController(BaseRepoCon'
224 h.flash(_('Successfully opened new pull request'),
224 h.flash(_('Successfully opened new pull request'),
225 category='success')
225 category='success')
226 except Exception:
226 except Exception:
227 raise
227 h.flash(_('Error occurred during sending pull request'),
228 h.flash(_('Error occurred during sending pull request'),
228 category='error')
229 category='error')
229 log.error(traceback.format_exc())
230 log.error(traceback.format_exc())
@@ -111,22 +111,17 b' class ChangesetStatusModel(BaseModel):'
111 st = status or ChangesetStatus.DEFAULT
111 st = status or ChangesetStatus.DEFAULT
112 return str(st)
112 return str(st)
113
113
114 def set_status(self, repo, status, user, comment, revision=None,
114 def set_status(self, repo, status, user, comment=None, revision=None,
115 pull_request=None, dont_allow_on_closed_pull_request=False):
115 pull_request=None, dont_allow_on_closed_pull_request=False):
116 """
116 """
117 Creates new status for changeset or updates the old ones bumping their
117 Creates new status for changeset or updates the old ones bumping their
118 version, leaving the current status at
118 version, leaving the current status at
119
119
120 :param repo:
120 :param repo:
121 :type repo:
122 :param revision:
121 :param revision:
123 :type revision:
124 :param status:
122 :param status:
125 :type status:
126 :param user:
123 :param user:
127 :type user:
128 :param comment:
124 :param comment:
129 :type comment:
130 :param dont_allow_on_closed_pull_request: don't allow a status change
125 :param dont_allow_on_closed_pull_request: don't allow a status change
131 if last status was for pull request and it's closed. We shouldn't
126 if last status was for pull request and it's closed. We shouldn't
132 mess around this manually
127 mess around this manually
@@ -134,14 +129,21 b' class ChangesetStatusModel(BaseModel):'
134 repo = self._get_repo(repo)
129 repo = self._get_repo(repo)
135
130
136 q = ChangesetStatus.query()
131 q = ChangesetStatus.query()
137
132 if not comment:
133 from rhodecode.model.comment import ChangesetCommentsModel
134 comment = ChangesetCommentsModel().create(
135 text='Auto status change',
136 repo=repo,
137 user=user,
138 pull_request=pull_request,
139 )
138 if revision:
140 if revision:
139 q = q.filter(ChangesetStatus.repo == repo)
141 q = q.filter(ChangesetStatus.repo == repo)
140 q = q.filter(ChangesetStatus.revision == revision)
142 q = q.filter(ChangesetStatus.revision == revision)
141 elif pull_request:
143 elif pull_request:
142 pull_request = self.__get_pull_request(pull_request)
144 pull_request = self.__get_pull_request(pull_request)
143 q = q.filter(ChangesetStatus.repo == pull_request.org_repo)
145 q = q.filter(ChangesetStatus.repo == pull_request.org_repo)
144 q = q.filter(ChangesetStatus.pull_request == pull_request)
146 q = q.filter(ChangesetStatus.revision.in_(pull_request.revisions))
145 cur_statuses = q.all()
147 cur_statuses = q.all()
146
148
147 #if statuses exists and last is associated with a closed pull request
149 #if statuses exists and last is associated with a closed pull request
@@ -153,6 +155,7 b' class ChangesetStatusModel(BaseModel):'
153 'Changing status on closed pull request is not allowed'
155 'Changing status on closed pull request is not allowed'
154 )
156 )
155
157
158 #update all current statuses with older version
156 if cur_statuses:
159 if cur_statuses:
157 for st in cur_statuses:
160 for st in cur_statuses:
158 st.version += 1
161 st.version += 1
@@ -365,7 +365,8 b' def PullRequestForm(repo_id):'
365 org_ref = v.UnicodeString(strip=True, required=True)
365 org_ref = v.UnicodeString(strip=True, required=True)
366 other_repo = v.UnicodeString(strip=True, required=True)
366 other_repo = v.UnicodeString(strip=True, required=True)
367 other_ref = v.UnicodeString(strip=True, required=True)
367 other_ref = v.UnicodeString(strip=True, required=True)
368 revisions = All(v.NotReviewedRevisions(repo_id)(), v.UniqueList(not_empty=True))
368 revisions = All(#v.NotReviewedRevisions(repo_id)(),
369 v.UniqueList(not_empty=True))
369 review_members = v.UniqueList(not_empty=True)
370 review_members = v.UniqueList(not_empty=True)
370
371
371 pullrequest_title = v.UnicodeString(strip=True, required=True, min=3)
372 pullrequest_title = v.UnicodeString(strip=True, required=True, min=3)
@@ -33,7 +33,8 b' from pylons.i18n.translation import _'
33 from rhodecode.model.meta import Session
33 from rhodecode.model.meta import Session
34 from rhodecode.lib import helpers as h
34 from rhodecode.lib import helpers as h
35 from rhodecode.model import BaseModel
35 from rhodecode.model import BaseModel
36 from rhodecode.model.db import PullRequest, PullRequestReviewers, Notification
36 from rhodecode.model.db import PullRequest, PullRequestReviewers, Notification,\
37 ChangesetStatus
37 from rhodecode.model.notification import NotificationModel
38 from rhodecode.model.notification import NotificationModel
38 from rhodecode.lib.utils2 import safe_unicode
39 from rhodecode.lib.utils2 import safe_unicode
39
40
@@ -54,8 +55,9 b' class PullRequestModel(BaseModel):'
54 repo = self._get_repo(repo)
55 repo = self._get_repo(repo)
55 return PullRequest.query().filter(PullRequest.other_repo == repo).all()
56 return PullRequest.query().filter(PullRequest.other_repo == repo).all()
56
57
57 def create(self, created_by, org_repo, org_ref, other_repo,
58 def create(self, created_by, org_repo, org_ref, other_repo, other_ref,
58 other_ref, revisions, reviewers, title, description=None):
59 revisions, reviewers, title, description=None):
60 from rhodecode.model.changeset_status import ChangesetStatusModel
59
61
60 created_by_user = self._get_user(created_by)
62 created_by_user = self._get_user(created_by)
61 org_repo = self._get_repo(org_repo)
63 org_repo = self._get_repo(org_repo)
@@ -78,6 +80,14 b' class PullRequestModel(BaseModel):'
78 reviewer = PullRequestReviewers(_usr, new)
80 reviewer = PullRequestReviewers(_usr, new)
79 self.sa.add(reviewer)
81 self.sa.add(reviewer)
80
82
83 #reset state to under-review
84 ChangesetStatusModel().set_status(
85 repo=org_repo,
86 status=ChangesetStatus.STATUS_UNDER_REVIEW,
87 user=created_by_user,
88 pull_request=new
89 )
90
81 #notification to reviewers
91 #notification to reviewers
82 notif = NotificationModel()
92 notif = NotificationModel()
83
93
@@ -65,7 +65,7 b''
65 <span class="spantag">${c.pull_request.org_ref_parts[0]}</span>
65 <span class="spantag">${c.pull_request.org_ref_parts[0]}</span>
66 :
66 :
67 <span class="spantag">${c.pull_request.org_ref_parts[1]}</span>
67 <span class="spantag">${c.pull_request.org_ref_parts[1]}</span>
68 <span>${c.pull_request.org_repo.clone_url()}</span>
68 <span><a href="${h.url('summary_home', repo_name=c.pull_request.org_repo.repo_name)}">${c.pull_request.org_repo.clone_url()}</a></span>
69 </div>
69 </div>
70 </div>
70 </div>
71 </div>
71 </div>
General Comments 0
You need to be logged in to leave comments. Login now