Mercurial > kallithea
annotate rhodecode/controllers/pullrequests.py @ 3015:16af24982e30 beta
Multiple changes for compare system
- count number of changed lines and files
- add combined compare button into the old per changeset compare
- fixed some logic for remote & bundle compare system
- added few tests for git compare
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 18 Nov 2012 23:17:02 +0100 |
parents | 32471bd1f4ee |
children | c2a206162062 |
rev | line source |
---|---|
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 """ |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 rhodecode.controllers.pullrequests |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 pull requests controller for rhodecode for initializing pull requests |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 :created_on: May 7, 2012 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :author: marcink |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 """ |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 # (at your option) any later version. |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 # |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 import logging |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 import traceback |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
27 import formencode |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
28 |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
29 from webob.exc import HTTPNotFound, HTTPForbidden |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
30 from collections import defaultdict |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
31 from itertools import groupby |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 from pylons import request, response, session, tmpl_context as c, url |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 from pylons.controllers.util import abort, redirect |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 from pylons.i18n.translation import _ |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
36 from pylons.decorators import jsonify |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
38 from rhodecode.lib.compat import json |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 from rhodecode.lib.base import BaseRepoController, render |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
40 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator,\ |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
41 NotAnonymous |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
42 from rhodecode.lib import helpers as h |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
43 from rhodecode.lib import diffs |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
44 from rhodecode.lib.utils import action_logger |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
45 from rhodecode.model.db import User, PullRequest, ChangesetStatus,\ |
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
46 ChangesetComment |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
47 from rhodecode.model.pull_request import PullRequestModel |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
48 from rhodecode.model.meta import Session |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
49 from rhodecode.model.repo import RepoModel |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
50 from rhodecode.model.comment import ChangesetCommentsModel |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
51 from rhodecode.model.changeset_status import ChangesetStatusModel |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
52 from rhodecode.model.forms import PullRequestForm |
2874
95923493de9a
protect agains pull requests on empty repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2849
diff
changeset
|
53 from rhodecode.lib.vcs.exceptions import EmptyRepositoryError |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
54 from rhodecode.lib.vcs.backends.base import EmptyChangeset |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 log = logging.getLogger(__name__) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 class PullrequestsController(BaseRepoController): |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 @LoginRequired() |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 'repository.admin') |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 def __before__(self): |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 super(PullrequestsController, self).__before__() |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
66 repo_model = RepoModel() |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
67 c.users_array = repo_model.get_users_js() |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
68 c.users_groups_array = repo_model.get_users_groups_js() |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 |
2395
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
70 def _get_repo_refs(self, repo): |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 hist_l = [] |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
73 branches_group = ([('branch:%s:%s' % (k, v), k) for |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
74 k, v in repo.branches.iteritems()], _("Branches")) |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
75 bookmarks_group = ([('book:%s:%s' % (k, v), k) for |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
76 k, v in repo.bookmarks.iteritems()], _("Bookmarks")) |
2478
8eab81115660
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2444
diff
changeset
|
77 tags_group = ([('tag:%s:%s' % (k, v), k) for |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
78 k, v in repo.tags.iteritems()], _("Tags")) |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
79 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
80 hist_l.append(bookmarks_group) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
81 hist_l.append(branches_group) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
82 hist_l.append(tags_group) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
83 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 return hist_l |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
85 |
2849
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
86 def _get_default_rev(self, repo): |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
87 """ |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
88 Get's default revision to do compare on pull request |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
89 |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
90 :param repo: |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
91 """ |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
92 repo = repo.scm_instance |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
93 if 'default' in repo.branches: |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
94 return 'default' |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
95 else: |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
96 #if repo doesn't have default branch return first found |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
97 return repo.branches.keys()[0] |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
98 |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
99 def show_all(self, repo_name): |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
100 c.pull_requests = PullRequestModel().get_all(repo_name) |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
101 c.repo_name = repo_name |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
102 return render('/pullrequests/pullrequest_show_all.html') |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
103 |
2627
6bd62617b99f
Opening pull request shouldn't be accessible by anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
2614
diff
changeset
|
104 @NotAnonymous() |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
105 def index(self): |
2395
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
106 org_repo = c.rhodecode_db_repo |
2444 | 107 |
108 if org_repo.scm_instance.alias != 'hg': | |
109 log.error('Review not available for GIT REPOS') | |
110 raise HTTPNotFound | |
111 | |
2874
95923493de9a
protect agains pull requests on empty repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2849
diff
changeset
|
112 try: |
95923493de9a
protect agains pull requests on empty repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2849
diff
changeset
|
113 org_repo.scm_instance.get_changeset() |
95923493de9a
protect agains pull requests on empty repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2849
diff
changeset
|
114 except EmptyRepositoryError, e: |
95923493de9a
protect agains pull requests on empty repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2849
diff
changeset
|
115 h.flash(h.literal(_('There are no changesets yet')), |
95923493de9a
protect agains pull requests on empty repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2849
diff
changeset
|
116 category='warning') |
95923493de9a
protect agains pull requests on empty repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2849
diff
changeset
|
117 redirect(url('summary_home', repo_name=org_repo.repo_name)) |
95923493de9a
protect agains pull requests on empty repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2849
diff
changeset
|
118 |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
119 other_repos_info = {} |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
120 |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
121 c.org_refs = self._get_repo_refs(c.rhodecode_repo) |
2395
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
122 c.org_repos = [] |
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
123 c.other_repos = [] |
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
124 c.org_repos.append((org_repo.repo_name, '%s/%s' % ( |
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
125 org_repo.user.username, c.repo_name)) |
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
126 ) |
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
127 |
2720
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
128 # add org repo to other so we can open pull request agains itself |
2395
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
129 c.other_repos.extend(c.org_repos) |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
130 |
2849
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
131 c.default_pull_request = org_repo.repo_name # repo name pre-selected |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
132 c.default_pull_request_rev = self._get_default_rev(org_repo) # revision pre-selected |
2720
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
133 c.default_revs = self._get_repo_refs(org_repo.scm_instance) |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
134 #add orginal repo |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
135 other_repos_info[org_repo.repo_name] = { |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
136 'gravatar': h.gravatar_url(org_repo.user.email, 24), |
2720
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
137 'description': org_repo.description, |
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
138 'revs': h.select('other_ref', '', c.default_revs, class_='refs') |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
139 } |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
140 |
2395
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
141 #gather forks and add to this list |
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
142 for fork in org_repo.forks: |
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
143 c.other_repos.append((fork.repo_name, '%s/%s' % ( |
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
144 fork.user.username, fork.repo_name)) |
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
145 ) |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
146 other_repos_info[fork.repo_name] = { |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
147 'gravatar': h.gravatar_url(fork.user.email, 24), |
2720
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
148 'description': fork.description, |
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
149 'revs': h.select('other_ref', '', |
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
150 self._get_repo_refs(fork.scm_instance), |
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
151 class_='refs') |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
152 } |
2933
07d620f6db2e
pull requests throw an error if parent of fork didn't have any changesets yet. Now it's filter out from list of available sources
Marcin Kuzminski <marcin@python-works.com>
parents:
2893
diff
changeset
|
153 #add parents of this fork also, but only if it's not empty |
07d620f6db2e
pull requests throw an error if parent of fork didn't have any changesets yet. Now it's filter out from list of available sources
Marcin Kuzminski <marcin@python-works.com>
parents:
2893
diff
changeset
|
154 if org_repo.parent and org_repo.parent.scm_instance.revisions: |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
155 c.default_pull_request = org_repo.parent.repo_name |
2849
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
156 c.default_pull_request_rev = self._get_default_rev(org_repo.parent) |
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
157 c.default_revs = self._get_repo_refs(org_repo.parent.scm_instance) |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
158 c.other_repos.append((org_repo.parent.repo_name, '%s/%s' % ( |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
159 org_repo.parent.user.username, |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
160 org_repo.parent.repo_name)) |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
161 ) |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
162 other_repos_info[org_repo.parent.repo_name] = { |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
163 'gravatar': h.gravatar_url(org_repo.parent.user.email, 24), |
2720
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
164 'description': org_repo.parent.description, |
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
165 'revs': h.select('other_ref', '', |
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
166 self._get_repo_refs(org_repo.parent.scm_instance), |
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
167 class_='refs') |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
168 } |
2395
b262e349a7a5
created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2244
diff
changeset
|
169 |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
170 c.other_repos_info = json.dumps(other_repos_info) |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
171 c.review_members = [org_repo.user] |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
172 return render('/pullrequests/pullrequest.html') |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
173 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
174 @NotAnonymous() |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
175 def create(self, repo_name): |
2893
eb180eb16c18
Fixed #585, checks for status of revision where to strict, and made opening pull request with those revision impossible due to previosly set status.
Marcin Kuzminski <marcin@python-works.com>
parents:
2892
diff
changeset
|
176 repo = RepoModel()._get_repo(repo_name) |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
177 try: |
2893
eb180eb16c18
Fixed #585, checks for status of revision where to strict, and made opening pull request with those revision impossible due to previosly set status.
Marcin Kuzminski <marcin@python-works.com>
parents:
2892
diff
changeset
|
178 _form = PullRequestForm(repo.repo_id)().to_python(request.POST) |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
179 except formencode.Invalid, errors: |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
180 log.error(traceback.format_exc()) |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
181 if errors.error_dict.get('revisions'): |
2720
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
182 msg = 'Revisions: %s' % errors.error_dict['revisions'] |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
183 elif errors.error_dict.get('pullrequest_title'): |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
184 msg = _('Pull request requires a title with min. 3 chars') |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
185 else: |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
186 msg = _('error during creation of pull request') |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
187 |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
188 h.flash(msg, 'error') |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
189 return redirect(url('pullrequest_home', repo_name=repo_name)) |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
190 |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
191 org_repo = _form['org_repo'] |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
192 org_ref = _form['org_ref'] |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
193 other_repo = _form['other_repo'] |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
194 other_ref = _form['other_ref'] |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
195 revisions = _form['revisions'] |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
196 reviewers = _form['review_members'] |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
197 |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
198 title = _form['pullrequest_title'] |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
199 description = _form['pullrequest_desc'] |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
200 |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
201 try: |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
202 pull_request = PullRequestModel().create( |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
203 self.rhodecode_user.user_id, org_repo, org_ref, other_repo, |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
204 other_ref, revisions, reviewers, title, description |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
205 ) |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
206 Session().commit() |
2533
5a826060251f
redirect to pull-request overview after creation
Marcin Kuzminski <marcin@python-works.com>
parents:
2496
diff
changeset
|
207 h.flash(_('Successfully opened new pull request'), |
5a826060251f
redirect to pull-request overview after creation
Marcin Kuzminski <marcin@python-works.com>
parents:
2496
diff
changeset
|
208 category='success') |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
209 except Exception: |
2533
5a826060251f
redirect to pull-request overview after creation
Marcin Kuzminski <marcin@python-works.com>
parents:
2496
diff
changeset
|
210 h.flash(_('Error occurred during sending pull request'), |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
211 category='error') |
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
212 log.error(traceback.format_exc()) |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
213 return redirect(url('pullrequest_home', repo_name=repo_name)) |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
214 |
2533
5a826060251f
redirect to pull-request overview after creation
Marcin Kuzminski <marcin@python-works.com>
parents:
2496
diff
changeset
|
215 return redirect(url('pullrequest_show', repo_name=other_repo, |
5a826060251f
redirect to pull-request overview after creation
Marcin Kuzminski <marcin@python-works.com>
parents:
2496
diff
changeset
|
216 pull_request_id=pull_request.pull_request_id)) |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
217 |
2614
3f50a5e8fc4d
Added editing of pull-request reviewers.
Marcin Kuzminski <marcin@python-works.com>
parents:
2612
diff
changeset
|
218 @NotAnonymous() |
3f50a5e8fc4d
Added editing of pull-request reviewers.
Marcin Kuzminski <marcin@python-works.com>
parents:
2612
diff
changeset
|
219 @jsonify |
3f50a5e8fc4d
Added editing of pull-request reviewers.
Marcin Kuzminski <marcin@python-works.com>
parents:
2612
diff
changeset
|
220 def update(self, repo_name, pull_request_id): |
3f50a5e8fc4d
Added editing of pull-request reviewers.
Marcin Kuzminski <marcin@python-works.com>
parents:
2612
diff
changeset
|
221 pull_request = PullRequest.get_or_404(pull_request_id) |
3f50a5e8fc4d
Added editing of pull-request reviewers.
Marcin Kuzminski <marcin@python-works.com>
parents:
2612
diff
changeset
|
222 if pull_request.is_closed(): |
3f50a5e8fc4d
Added editing of pull-request reviewers.
Marcin Kuzminski <marcin@python-works.com>
parents:
2612
diff
changeset
|
223 raise HTTPForbidden() |
2769 | 224 #only owner or admin can update it |
225 owner = pull_request.author.user_id == c.rhodecode_user.user_id | |
226 if h.HasPermissionAny('hg.admin', 'repository.admin')() or owner: | |
227 reviewers_ids = map(int, filter(lambda v: v not in [None, ''], | |
228 request.POST.get('reviewers_ids', '').split(','))) | |
2712
7224882c4059
new summary for opened pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2711
diff
changeset
|
229 |
2769 | 230 PullRequestModel().update_reviewers(pull_request_id, reviewers_ids) |
231 Session.commit() | |
232 return True | |
233 raise HTTPForbidden() | |
2614
3f50a5e8fc4d
Added editing of pull-request reviewers.
Marcin Kuzminski <marcin@python-works.com>
parents:
2612
diff
changeset
|
234 |
2746
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
235 @NotAnonymous() |
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
236 @jsonify |
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
237 def delete(self, repo_name, pull_request_id): |
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
238 pull_request = PullRequest.get_or_404(pull_request_id) |
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
239 #only owner can delete it ! |
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
240 if pull_request.author.user_id == c.rhodecode_user.user_id: |
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
241 PullRequestModel().delete(pull_request) |
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
242 Session().commit() |
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
243 h.flash(_('Successfully deleted pull request'), |
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
244 category='success') |
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
245 return redirect(url('admin_settings_my_account')) |
2769 | 246 raise HTTPForbidden() |
2746
49a4864b11c1
Authors of pull-requests can now delete them
Marcin Kuzminski <marcin@python-works.com>
parents:
2720
diff
changeset
|
247 |
2608
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
248 def _load_compare_data(self, pull_request, enable_comments=True): |
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
|
249 """ |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
250 Load context data needed for generating compare diff |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
251 |
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
|
252 :param pull_request: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
253 :type pull_request: |
3bf057a7f7e8
small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents:
2440
diff
changeset
|
254 """ |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
255 |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
256 org_repo = pull_request.org_repo |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
257 (org_ref_type, |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
258 org_ref_name, |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
259 org_ref_rev) = pull_request.org_ref.split(':') |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
260 |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
261 other_repo = pull_request.other_repo |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
262 (other_ref_type, |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
263 other_ref_name, |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
264 other_ref_rev) = pull_request.other_ref.split(':') |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
265 |
2720
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
266 # despite opening revisions for bookmarks/branches/tags, we always |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
267 # convert this to rev to prevent changes after book or branch change |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
268 org_ref = ('rev', org_ref_rev) |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
269 other_ref = ('rev', other_ref_rev) |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
270 |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
271 c.org_repo = org_repo |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
272 c.other_repo = other_repo |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
273 |
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
|
274 c.cs_ranges, discovery_data = PullRequestModel().get_compare_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
|
275 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
|
276 ) |
2892
5fba3778431c
#590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents:
2874
diff
changeset
|
277 if c.cs_ranges: |
5fba3778431c
#590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents:
2874
diff
changeset
|
278 # case we want a simple diff without incoming changesets, just |
5fba3778431c
#590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents:
2874
diff
changeset
|
279 # for review purposes. Make the diff on the forked repo, with |
5fba3778431c
#590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents:
2874
diff
changeset
|
280 # revision that is common ancestor |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
281 other_ref = ('rev', getattr(c.cs_ranges[-1].parents[0] |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
282 if c.cs_ranges[-1].parents |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
283 else EmptyChangeset(), 'raw_id')) |
2892
5fba3778431c
#590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents:
2874
diff
changeset
|
284 other_repo = org_repo |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
285 |
2803
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
286 c.statuses = org_repo.statuses([x.raw_id for x in c.cs_ranges]) |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
287 # defines that we need hidden inputs with changesets |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
288 c.as_form = request.GET.get('as_form', False) |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
289 |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
290 c.org_ref = org_ref[1] |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
291 c.other_ref = other_ref[1] |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
292 _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref, |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
293 discovery_data) |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
294 |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
295 diff_processor = diffs.DiffProcessor(_diff, format='gitdiff') |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
296 _parsed = diff_processor.prepare() |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
297 |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
298 c.files = [] |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
299 c.changes = {} |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
300 |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
301 for f in _parsed: |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
302 fid = h.FID('', f['filename']) |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
303 c.files.append([fid, f['operation'], f['filename'], f['stats']]) |
2608
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
304 diff = diff_processor.as_html(enable_comments=enable_comments, |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2933
diff
changeset
|
305 parsed_lines=[f]) |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
306 c.changes[fid] = [f['operation'], f['filename'], diff] |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
307 |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
308 def show(self, repo_name, pull_request_id): |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
309 repo_model = RepoModel() |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
310 c.users_array = repo_model.get_users_js() |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
311 c.users_groups_array = repo_model.get_users_groups_js() |
2496
fddd8e3fc157
use get_or_404 where possible
Marcin Kuzminski <marcin@python-works.com>
parents:
2489
diff
changeset
|
312 c.pull_request = PullRequest.get_or_404(pull_request_id) |
2803
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
313 c.target_repo = c.pull_request.org_repo.repo_name |
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
|
314 |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
315 cc_model = ChangesetCommentsModel() |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
316 cs_model = ChangesetStatusModel() |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
317 _cs_statuses = cs_model.get_statuses(c.pull_request.org_repo, |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
318 pull_request=c.pull_request, |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
319 with_revisions=True) |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
320 |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
321 cs_statuses = defaultdict(list) |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
322 for st in _cs_statuses: |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
323 cs_statuses[st.author.username] += [st] |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
324 |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
325 c.pull_request_reviewers = [] |
2712
7224882c4059
new summary for opened pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2711
diff
changeset
|
326 c.pull_request_pending_reviewers = [] |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
327 for o in c.pull_request.reviewers: |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
328 st = cs_statuses.get(o.user.username, None) |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
329 if st: |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
330 sorter = lambda k: k.version |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
331 st = [(x, list(y)[0]) |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
332 for x, y in (groupby(sorted(st, key=sorter), sorter))] |
2712
7224882c4059
new summary for opened pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2711
diff
changeset
|
333 else: |
7224882c4059
new summary for opened pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2711
diff
changeset
|
334 c.pull_request_pending_reviewers.append(o.user) |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
335 c.pull_request_reviewers.append([o.user, st]) |
2444 | 336 |
337 # pull_requests repo_name we opened it against | |
338 # ie. other_repo must match | |
339 if repo_name != c.pull_request.other_repo.repo_name: | |
340 raise HTTPNotFound | |
341 | |
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
|
342 # load compare data into template context |
2608
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
343 enable_comments = not c.pull_request.is_closed() |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
344 self._load_compare_data(c.pull_request, enable_comments=enable_comments) |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
345 |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
346 # inline comments |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
347 c.inline_cnt = 0 |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
348 c.inline_comments = cc_model.get_inline_comments( |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
349 c.rhodecode_db_repo.repo_id, |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
350 pull_request=pull_request_id) |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
351 # count inline comments |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
352 for __, lines in c.inline_comments: |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
353 for comments in lines.values(): |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
354 c.inline_cnt += len(comments) |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
355 # comments |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
356 c.comments = cc_model.get_comments(c.rhodecode_db_repo.repo_id, |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
357 pull_request=pull_request_id) |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
358 |
2803
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
359 try: |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
360 cur_status = c.statuses[c.pull_request.revisions[0]][0] |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
361 except: |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
362 log.error(traceback.format_exc()) |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
363 cur_status = 'undefined' |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
364 if c.pull_request.is_closed() and 0: |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
365 c.current_changeset_status = cur_status |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
366 else: |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
367 # changeset(pull-request) status calulation based on reviewers |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
368 c.current_changeset_status = cs_model.calculate_status( |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
369 c.pull_request_reviewers, |
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
370 ) |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
371 c.changeset_statuses = ChangesetStatus.STATUSES |
2803
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
372 |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
373 return render('/pullrequests/pullrequest_show.html') |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
374 |
2627
6bd62617b99f
Opening pull request shouldn't be accessible by anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
2614
diff
changeset
|
375 @NotAnonymous() |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
376 @jsonify |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
377 def comment(self, repo_name, pull_request_id): |
2608
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
378 pull_request = PullRequest.get_or_404(pull_request_id) |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
379 if pull_request.is_closed(): |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
380 raise HTTPForbidden() |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
381 |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
382 status = request.POST.get('changeset_status') |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
383 change_status = request.POST.get('change_changeset_status') |
2796
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2769
diff
changeset
|
384 text = request.POST.get('text') |
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2769
diff
changeset
|
385 if status and change_status: |
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2769
diff
changeset
|
386 text = text or (_('Status change -> %s') |
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2769
diff
changeset
|
387 % ChangesetStatus.get_status_lbl(status)) |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
388 comm = ChangesetCommentsModel().create( |
2796
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2769
diff
changeset
|
389 text=text, |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
390 repo=c.rhodecode_db_repo.repo_id, |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
391 user=c.rhodecode_user.user_id, |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
392 pull_request=pull_request_id, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
393 f_path=request.POST.get('f_path'), |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
394 line_no=request.POST.get('line'), |
2478
8eab81115660
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2444
diff
changeset
|
395 status_change=(ChangesetStatus.get_status_lbl(status) |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
396 if status and change_status else None) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
397 ) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
398 |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
399 # get status if set ! |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
400 if status and change_status: |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
401 ChangesetStatusModel().set_status( |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
402 c.rhodecode_db_repo.repo_id, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
403 status, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
404 c.rhodecode_user.user_id, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
405 comm, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
406 pull_request=pull_request_id |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
407 ) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
408 action_logger(self.rhodecode_user, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
409 'user_commented_pull_request:%s' % pull_request_id, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
410 c.rhodecode_db_repo, self.ip_addr, self.sa) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
411 |
2608
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
412 if request.POST.get('save_close'): |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
413 PullRequestModel().close_pull_request(pull_request_id) |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
414 action_logger(self.rhodecode_user, |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
415 'user_closed_pull_request:%s' % pull_request_id, |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
416 c.rhodecode_db_repo, self.ip_addr, self.sa) |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
417 |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
418 Session().commit() |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
419 |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
420 if not request.environ.get('HTTP_X_PARTIAL_XHR'): |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
421 return redirect(h.url('pullrequest_show', repo_name=repo_name, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
422 pull_request_id=pull_request_id)) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
423 |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
424 data = { |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
425 'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))), |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
426 } |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
427 if comm: |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
428 c.co = comm |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
429 data.update(comm.get_dict()) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
430 data.update({'rendered_text': |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
431 render('changeset/changeset_comment_block.html')}) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
432 |
2444 | 433 return data |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
434 |
2627
6bd62617b99f
Opening pull request shouldn't be accessible by anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
2614
diff
changeset
|
435 @NotAnonymous() |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
436 @jsonify |
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
437 def delete_comment(self, repo_name, comment_id): |
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
438 co = ChangesetComment.get(comment_id) |
2608
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
439 if co.pull_request.is_closed(): |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
440 #don't allow deleting comments on closed pull request |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
441 raise HTTPForbidden() |
58c529332e7e
Added option to close pull requests, in future that will be close & merge
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
442 |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
443 owner = lambda: co.author.user_id == c.rhodecode_user.user_id |
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
444 if h.HasPermissionAny('hg.admin', 'repository.admin')() or owner: |
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
445 ChangesetCommentsModel().delete(comment=co) |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
446 Session().commit() |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
447 return True |
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
448 else: |
2614
3f50a5e8fc4d
Added editing of pull-request reviewers.
Marcin Kuzminski <marcin@python-works.com>
parents:
2612
diff
changeset
|
449 raise HTTPForbidden() |