Mercurial > kallithea
annotate rhodecode/controllers/pullrequests.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
This imports changes between changesets 21af6c4eab3d and 6177597791c2 in
RhodeCode's original repository, including only changes to Python files and HTML.
RhodeCode clearly licensed its changes to these files under GPLv3
in their /LICENSE file, which states the following:
The Python code and integrated HTML are licensed under the GPLv3 license.
(See:
https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE
or
http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE
for an online copy of that LICENSE file)
Conservancy reviewed these changes and confirmed that they can be licensed as
a whole to the Kallithea project under GPLv3-only.
While some of the contents committed herein are clearly licensed
GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the
statement above from RhodeCode indicates that they intend GPLv3-only as their
license, per GPLv3ยง14 and other relevant sections of GPLv3.
author | Bradley M. Kuhn <bkuhn@sfconservancy.org> |
---|---|
date | Wed, 02 Jul 2014 19:03:13 -0400 |
parents | b622e6849b67 |
children | 7e5f8c12a3fc |
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 # 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
|
3 # 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
|
4 # 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
|
5 # (at your option) any later version. |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 # |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 # 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
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 # GNU General Public License for more details. |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 # |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 # 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
|
13 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
14 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
15 rhodecode.controllers.pullrequests |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
17 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
18 pull requests controller for rhodecode for initializing pull requests |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
19 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
20 :created_on: May 7, 2012 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
21 :author: marcink |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
22 :copyright: (c) 2013 RhodeCode GmbH. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
23 :license: GPLv3, see LICENSE for more details. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
24 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
25 |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 import logging |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 import traceback |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
28 import formencode |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
29 |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
30 from webob.exc import HTTPNotFound, HTTPForbidden |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
31 from collections import defaultdict |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
32 from itertools import groupby |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 |
3941
3208aaefc9ca
Moved all Mercurial imports into hgcompat from vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
34 from pylons import request, tmpl_context as c, url |
3208aaefc9ca
Moved all Mercurial imports into hgcompat from vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
35 from pylons.controllers.util import redirect |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 from pylons.i18n.translation import _ |
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 |
3676
9d2db665ef31
pagination in pull-requests page + UI
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
42 from rhodecode.lib.helpers import Page |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
43 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
|
44 from rhodecode.lib import diffs |
3061
7727faad5baf
fixed issue #671 commenting on pull requests sometimes used old JSON encoder and broke. This changeset replaces it's with RhodeCode json encoder to ensure all data is properly serializable
Marcin Kuzminski <marcin@python-works.com>
parents:
3023
diff
changeset
|
45 from rhodecode.lib.utils import action_logger, jsonify |
3718
b2575bdb847c
diffs: drop diffs.differ
Mads Kiilerich <madski@unity3d.com>
parents:
3676
diff
changeset
|
46 from rhodecode.lib.vcs.utils import safe_str |
3061
7727faad5baf
fixed issue #671 commenting on pull requests sometimes used old JSON encoder and broke. This changeset replaces it's with RhodeCode json encoder to ensure all data is properly serializable
Marcin Kuzminski <marcin@python-works.com>
parents:
3023
diff
changeset
|
47 from rhodecode.lib.vcs.exceptions import EmptyRepositoryError |
7727faad5baf
fixed issue #671 commenting on pull requests sometimes used old JSON encoder and broke. This changeset replaces it's with RhodeCode json encoder to ensure all data is properly serializable
Marcin Kuzminski <marcin@python-works.com>
parents:
3023
diff
changeset
|
48 from rhodecode.lib.diffs import LimitedDiffContainer |
3941
3208aaefc9ca
Moved all Mercurial imports into hgcompat from vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
49 from rhodecode.model.db import PullRequest, ChangesetStatus, ChangesetComment |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 from rhodecode.model.forms import PullRequestForm |
3676
9d2db665ef31
pagination in pull-requests page + UI
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
56 from rhodecode.lib.utils2 import safe_int |
2244
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 log = logging.getLogger(__name__) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 |
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 class PullrequestsController(BaseRepoController): |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 def __before__(self): |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 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
|
65 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
|
66 c.users_array = repo_model.get_users_js() |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
67 c.user_groups_array = repo_model.get_user_groups_js() |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 |
3813
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
69 def _get_repo_refs(self, repo, rev=None, branch=None, branch_rev=None): |
3444
c12603d5ee13
pullrequests: refactor changeset selectors, tip is special and not a real tag
Mads Kiilerich <madski@unity3d.com>
parents:
3442
diff
changeset
|
70 """return a structure with repo's interesting changesets, suitable for |
3811
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
71 the selectors in pullrequest.html |
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
72 |
3813
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
73 rev: a revision that must be in the list somehow and selected by default |
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
74 branch: a branch that must be in the list and selected by default - even if closed |
3811
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
75 branch_rev: a revision of which peers should be preferred and available.""" |
3515
5b3313a5c6fc
pullrequest selection list: emphasize named branches that are neighbours
Mads Kiilerich <madski@unity3d.com>
parents:
3486
diff
changeset
|
76 # list named branches that has been merged to this named branch - it should probably merge back |
3598
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
77 peers = [] |
3719
3534e75b2d5b
pullrequests: don't pass unicode strings to Mercurial
Mads Kiilerich <madski@unity3d.com>
parents:
3718
diff
changeset
|
78 |
3534e75b2d5b
pullrequests: don't pass unicode strings to Mercurial
Mads Kiilerich <madski@unity3d.com>
parents:
3718
diff
changeset
|
79 if rev: |
3534e75b2d5b
pullrequests: don't pass unicode strings to Mercurial
Mads Kiilerich <madski@unity3d.com>
parents:
3718
diff
changeset
|
80 rev = safe_str(rev) |
3534e75b2d5b
pullrequests: don't pass unicode strings to Mercurial
Mads Kiilerich <madski@unity3d.com>
parents:
3718
diff
changeset
|
81 |
3813
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
82 if branch: |
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
83 branch = safe_str(branch) |
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
84 |
3515
5b3313a5c6fc
pullrequest selection list: emphasize named branches that are neighbours
Mads Kiilerich <madski@unity3d.com>
parents:
3486
diff
changeset
|
85 if branch_rev: |
3719
3534e75b2d5b
pullrequests: don't pass unicode strings to Mercurial
Mads Kiilerich <madski@unity3d.com>
parents:
3718
diff
changeset
|
86 branch_rev = safe_str(branch_rev) |
3515
5b3313a5c6fc
pullrequest selection list: emphasize named branches that are neighbours
Mads Kiilerich <madski@unity3d.com>
parents:
3486
diff
changeset
|
87 # not restricting to merge() would also get branch point and be better |
5b3313a5c6fc
pullrequest selection list: emphasize named branches that are neighbours
Mads Kiilerich <madski@unity3d.com>
parents:
3486
diff
changeset
|
88 # (especially because it would get the branch point) ... but is currently too expensive |
5b3313a5c6fc
pullrequest selection list: emphasize named branches that are neighbours
Mads Kiilerich <madski@unity3d.com>
parents:
3486
diff
changeset
|
89 otherbranches = {} |
3811
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
90 for i in repo._repo.revs( |
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
91 "sort(parents(branch(id(%s)) and merge()) - branch(id(%s)))", |
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
92 branch_rev, branch_rev): |
3515
5b3313a5c6fc
pullrequest selection list: emphasize named branches that are neighbours
Mads Kiilerich <madski@unity3d.com>
parents:
3486
diff
changeset
|
93 cs = repo.get_changeset(i) |
5b3313a5c6fc
pullrequest selection list: emphasize named branches that are neighbours
Mads Kiilerich <madski@unity3d.com>
parents:
3486
diff
changeset
|
94 otherbranches[cs.branch] = cs.raw_id |
3811
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
95 for abranch, node in otherbranches.iteritems(): |
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
96 selected = 'branch:%s:%s' % (abranch, node) |
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
97 peers.append((selected, abranch)) |
3598
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
98 |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
99 selected = None |
3811
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
100 |
3598
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
101 branches = [] |
3811
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
102 for abranch, branchrev in repo.branches.iteritems(): |
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
103 n = 'branch:%s:%s' % (abranch, branchrev) |
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
104 branches.append((n, abranch)) |
3598
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
105 if rev == branchrev: |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
106 selected = n |
3813
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
107 if branch == abranch: |
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
108 selected = n |
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
109 branch = None |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
110 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
111 if branch: # branch not in list - it is probably closed |
3813
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
112 revs = repo._repo.revs('max(branch(%s))', branch) |
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
113 if revs: |
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
114 cs = repo.get_changeset(revs[0]) |
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
115 selected = 'branch:%s:%s' % (branch, cs.raw_id) |
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
116 branches.append((selected, branch)) |
3811
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
117 |
3598
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
118 bookmarks = [] |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
119 for bookmark, bookmarkrev in repo.bookmarks.iteritems(): |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
120 n = 'book:%s:%s' % (bookmark, bookmarkrev) |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
121 bookmarks.append((n, bookmark)) |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
122 if rev == bookmarkrev: |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
123 selected = n |
3811
3591b33e0c94
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich <madski@unity3d.com>
parents:
3785
diff
changeset
|
124 |
3598
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
125 tags = [] |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
126 for tag, tagrev in repo.tags.iteritems(): |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
127 n = 'tag:%s:%s' % (tag, tagrev) |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
128 tags.append((n, tag)) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
129 if rev == tagrev and tag != 'tip': # tip is not a real tag - and its branch is better |
3598
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
130 selected = n |
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
131 |
3598
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
132 # prio 1: rev was selected as existing entry above |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
133 |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
134 # prio 2: create special entry for rev; rev _must_ be used |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
135 specials = [] |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
136 if rev and selected is None: |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
137 selected = 'rev:%s:%s' % (rev, rev) |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
138 specials = [(selected, '%s: %s' % (_("Changeset"), rev[:12]))] |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
139 |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
140 # prio 3: most recent peer branch |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
141 if peers and not selected: |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
142 selected = peers[0][0][0] |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
143 |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
144 # prio 4: tip revision |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
145 if not selected: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
146 if h.is_hg(repo): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
147 selected = 'tag:tip:%s' % repo.tags['tip'] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
148 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
149 if 'master' in repo.branches: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
150 selected = 'branch:master:%s' % repo.branches['master'] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
151 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
152 k, v = repo.branches.items()[0] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
153 selected = 'branch:%s:%s' % (k, v) |
3598
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
154 |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
155 groups = [(specials, _("Special")), |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
156 (peers, _("Peer branches")), |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
157 (bookmarks, _("Bookmarks")), |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
158 (branches, _("Branches")), |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
159 (tags, _("Tags")), |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
160 ] |
7d774f09dba5
pullrequests: only create special select entry for a changeset if it has no symbolic name
Mads Kiilerich <madski@unity3d.com>
parents:
3597
diff
changeset
|
161 return [g for g in groups if g[0]], selected |
2849
2b672f04bfd9
fixed few issues with autoselection of revisions on pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2803
diff
changeset
|
162 |
3104
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
163 def _get_is_allowed_change_status(self, pull_request): |
3149
68f9c216377d
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
164 owner = self.rhodecode_user.user_id == pull_request.user_id |
3104
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
165 reviewer = self.rhodecode_user.user_id in [x.user_id for x in |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
166 pull_request.reviewers] |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
167 return self.rhodecode_user.admin or owner or reviewer |
3104
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
168 |
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
|
169 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
|
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 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
|
172 |
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
|
173 :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
|
174 """ |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
175 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
|
176 (org_ref_type, |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
177 org_ref_name, |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
178 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
|
179 |
3023
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
180 other_repo = org_repo |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
181 (other_ref_type, |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
182 other_ref_name, |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
183 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
|
184 |
2720
0f7355d3c196
Load generated revs while switching to other sources of pull-requests.
Marcin Kuzminski <marcin@python-works.com>
parents:
2712
diff
changeset
|
185 # despite opening revisions for bookmarks/branches/tags, we always |
3484
75e563531350
compare: drop unused rev_start and rev_end
Mads Kiilerich <madski@unity3d.com>
parents:
3447
diff
changeset
|
186 # convert this to rev to prevent changes after bookmark or branch change |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
187 org_ref = ('rev', org_ref_rev) |
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2627
diff
changeset
|
188 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
|
189 |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
190 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
|
191 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
|
192 |
3023
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
193 c.fulldiff = fulldiff = request.GET.get('fulldiff') |
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
194 |
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
195 c.cs_ranges = [org_repo.get_changeset(x) for x in pull_request.revisions] |
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
196 |
2803
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
197 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
|
198 |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
199 c.org_ref = org_ref[1] |
3357
674a8fad3abc
show links to files on compare data at other and org refs
Marcin Kuzminski <marcin@python-works.com>
parents:
3330
diff
changeset
|
200 c.org_ref_type = org_ref[0] |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
201 c.other_ref = other_ref[1] |
3357
674a8fad3abc
show links to files on compare data at other and org refs
Marcin Kuzminski <marcin@python-works.com>
parents:
3330
diff
changeset
|
202 c.other_ref_type = other_ref[0] |
3023
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
203 |
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
204 diff_limit = self.cut_off_limit if not fulldiff else None |
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
205 |
3739
41b0e2b92283
pullrequests: fix reversed diff
Mads Kiilerich <madski@unity3d.com>
parents:
3720
diff
changeset
|
206 # we swap org/other ref since we run a simple diff on one repo |
3812
4324d6899e55
diff: cleanup of variables and logging in compare and pullrequests
Mads Kiilerich <madski@unity3d.com>
parents:
3811
diff
changeset
|
207 log.debug('running diff between %s and %s in %s' |
4324d6899e55
diff: cleanup of variables and logging in compare and pullrequests
Mads Kiilerich <madski@unity3d.com>
parents:
3811
diff
changeset
|
208 % (other_ref, org_ref, org_repo.scm_instance.path)) |
4324d6899e55
diff: cleanup of variables and logging in compare and pullrequests
Mads Kiilerich <madski@unity3d.com>
parents:
3811
diff
changeset
|
209 txtdiff = org_repo.scm_instance.get_diff(rev1=safe_str(other_ref[1]), rev2=safe_str(org_ref[1])) |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
210 |
3812
4324d6899e55
diff: cleanup of variables and logging in compare and pullrequests
Mads Kiilerich <madski@unity3d.com>
parents:
3811
diff
changeset
|
211 diff_processor = diffs.DiffProcessor(txtdiff or '', format='gitdiff', |
3023
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
212 diff_limit=diff_limit) |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
213 _parsed = diff_processor.prepare() |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
214 |
3023
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
215 c.limited_diff = False |
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
216 if isinstance(_parsed, LimitedDiffContainer): |
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
217 c.limited_diff = True |
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
218 |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
219 c.files = [] |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
220 c.changes = {} |
3825
3306bdd95f11
bring back accidentally deleted context variables with lines added
Marcin Kuzminski <marcin@python-works.com>
parents:
3821
diff
changeset
|
221 c.lines_added = 0 |
3306bdd95f11
bring back accidentally deleted context variables with lines added
Marcin Kuzminski <marcin@python-works.com>
parents:
3821
diff
changeset
|
222 c.lines_deleted = 0 |
3306bdd95f11
bring back accidentally deleted context variables with lines added
Marcin Kuzminski <marcin@python-works.com>
parents:
3821
diff
changeset
|
223 |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
224 for f in _parsed: |
3023
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
225 st = f['stats'] |
3821
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3813
diff
changeset
|
226 c.lines_added += st['added'] |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3813
diff
changeset
|
227 c.lines_deleted += st['deleted'] |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
228 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
|
229 c.files.append([fid, f['operation'], f['filename'], f['stats']]) |
3812
4324d6899e55
diff: cleanup of variables and logging in compare and pullrequests
Mads Kiilerich <madski@unity3d.com>
parents:
3811
diff
changeset
|
230 htmldiff = diff_processor.as_html(enable_comments=enable_comments, |
4324d6899e55
diff: cleanup of variables and logging in compare and pullrequests
Mads Kiilerich <madski@unity3d.com>
parents:
3811
diff
changeset
|
231 parsed_lines=[f]) |
4324d6899e55
diff: cleanup of variables and logging in compare and pullrequests
Mads Kiilerich <madski@unity3d.com>
parents:
3811
diff
changeset
|
232 c.changes[fid] = [f['operation'], f['filename'], htmldiff] |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
233 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
234 @LoginRequired() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
235 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
236 'repository.admin') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
237 def show_all(self, repo_name): |
4024
73ef2a5d3042
pull requests: make it possible control display of closed PRs and whether it is PRs to or from repo
Mads Kiilerich <madski@unity3d.com>
parents:
3978
diff
changeset
|
238 c.from_ = request.GET.get('from_') or '' |
73ef2a5d3042
pull requests: make it possible control display of closed PRs and whether it is PRs to or from repo
Mads Kiilerich <madski@unity3d.com>
parents:
3978
diff
changeset
|
239 c.closed = request.GET.get('closed') or '' |
73ef2a5d3042
pull requests: make it possible control display of closed PRs and whether it is PRs to or from repo
Mads Kiilerich <madski@unity3d.com>
parents:
3978
diff
changeset
|
240 c.pull_requests = PullRequestModel().get_all(repo_name, from_=c.from_, closed=c.closed) |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
241 c.repo_name = repo_name |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
242 p = safe_int(request.GET.get('page', 1), 1) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
243 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
244 c.pullrequests_pager = Page(c.pull_requests, page=p, items_per_page=10) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
245 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
246 c.pullrequest_data = render('/pullrequests/pullrequest_data.html') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
247 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
248 if request.environ.get('HTTP_X_PARTIAL_XHR'): |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
249 return c.pullrequest_data |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
250 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
251 return render('/pullrequests/pullrequest_show_all.html') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
252 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
253 @LoginRequired() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
254 @NotAnonymous() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
255 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
256 'repository.admin') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
257 def index(self): |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
258 org_repo = c.rhodecode_db_repo |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
259 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
260 try: |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
261 org_repo.scm_instance.get_changeset() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
262 except EmptyRepositoryError, e: |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
263 h.flash(h.literal(_('There are no changesets yet')), |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
264 category='warning') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
265 redirect(url('summary_home', repo_name=org_repo.repo_name)) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
266 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
267 org_rev = request.GET.get('rev_end') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
268 # rev_start is not directly useful - its parent could however be used |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
269 # as default for other and thus give a simple compare view |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
270 #other_rev = request.POST.get('rev_start') |
3813
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
271 branch = request.GET.get('branch') |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
272 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
273 c.org_repos = [] |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
274 c.org_repos.append((org_repo.repo_name, org_repo.repo_name)) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
275 c.default_org_repo = org_repo.repo_name |
3813
dca89d578c70
pull requests: use branch name when creating PRs from a changelog with branch filter
Mads Kiilerich <madski@unity3d.com>
parents:
3812
diff
changeset
|
276 c.org_refs, c.default_org_ref = self._get_repo_refs(org_repo.scm_instance, rev=org_rev, branch=branch) |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
277 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
278 c.other_repos = [] |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
279 other_repos_info = {} |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
280 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
281 def add_other_repo(repo, branch_rev=None): |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
282 if repo.repo_name in other_repos_info: # shouldn't happen |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
283 return |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
284 c.other_repos.append((repo.repo_name, repo.repo_name)) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
285 other_refs, selected_other_ref = self._get_repo_refs(repo.scm_instance, branch_rev=branch_rev) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
286 other_repos_info[repo.repo_name] = { |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
287 'user': dict(user_id=repo.user.user_id, |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
288 username=repo.user.username, |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
289 firstname=repo.user.firstname, |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
290 lastname=repo.user.lastname, |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
291 gravatar_link=h.gravatar_url(repo.user.email, 14)), |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
292 'description': repo.description.split('\n', 1)[0], |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
293 'revs': h.select('other_ref', selected_other_ref, other_refs, class_='refs') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
294 } |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
295 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
296 # add org repo to other so we can open pull request against peer branches on itself |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
297 add_other_repo(org_repo, branch_rev=org_rev) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
298 c.default_other_repo = org_repo.repo_name |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
299 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
300 # gather forks and add to this list ... even though it is rare to |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
301 # request forks to pull from their parent |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
302 for fork in org_repo.forks: |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
303 add_other_repo(fork) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
304 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
305 # add parents of this fork also, but only if it's not empty |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
306 if org_repo.parent and org_repo.parent.scm_instance.revisions: |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
307 add_other_repo(org_repo.parent) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
308 c.default_other_repo = org_repo.parent.repo_name |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
309 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
310 c.default_other_repo_info = other_repos_info[c.default_other_repo] |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
311 c.other_repos_info = json.dumps(other_repos_info) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
312 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
313 return render('/pullrequests/pullrequest.html') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
314 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
315 @LoginRequired() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
316 @NotAnonymous() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
317 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
318 'repository.admin') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
319 def create(self, repo_name): |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
320 repo = RepoModel()._get_repo(repo_name) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
321 try: |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
322 _form = PullRequestForm(repo.repo_id)().to_python(request.POST) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
323 except formencode.Invalid, errors: |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
324 log.error(traceback.format_exc()) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
325 if errors.error_dict.get('revisions'): |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
326 msg = 'Revisions: %s' % errors.error_dict['revisions'] |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
327 elif errors.error_dict.get('pullrequest_title'): |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
328 msg = _('Pull request requires a title with min. 3 chars') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
329 else: |
4080
b622e6849b67
pull requests: give slightly more useful error messages on failing form validation
Mads Kiilerich <madski@unity3d.com>
parents:
4058
diff
changeset
|
330 msg = _('Error creating pull request: %s') % errors.msg |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
331 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
332 h.flash(msg, 'error') |
4080
b622e6849b67
pull requests: give slightly more useful error messages on failing form validation
Mads Kiilerich <madski@unity3d.com>
parents:
4058
diff
changeset
|
333 return redirect(url('pullrequest_home', repo_name=repo_name)) ## would rather just go back to form ... |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
334 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
335 org_repo = _form['org_repo'] |
3978
4f31439c90d3
pull requests: use org_ref with correct symbolic name instead of fake one
Mads Kiilerich <madski@unity3d.com>
parents:
3960
diff
changeset
|
336 org_ref = _form['org_ref'] # will end with merge_rev but have symbolic name |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
337 other_repo = _form['other_repo'] |
3978
4f31439c90d3
pull requests: use org_ref with correct symbolic name instead of fake one
Mads Kiilerich <madski@unity3d.com>
parents:
3960
diff
changeset
|
338 other_ref = 'rev:ancestor:%s' % _form['ancestor_rev'] # could be calculated from other_ref ... |
3785
7d8154837174
create a list out of generator.
Marcin Kuzminski <marcin@python-works.com>
parents:
3749
diff
changeset
|
339 revisions = [x for x in reversed(_form['revisions'])] |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
340 reviewers = _form['review_members'] |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
341 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
342 title = _form['pullrequest_title'] |
4058
a2218bdbf45d
pull requests: make title optional - generate one automatically
Mads Kiilerich <madski@unity3d.com>
parents:
4053
diff
changeset
|
343 if not title: |
a2218bdbf45d
pull requests: make title optional - generate one automatically
Mads Kiilerich <madski@unity3d.com>
parents:
4053
diff
changeset
|
344 title = '%s#%s to %s' % (org_repo, org_ref.split(':', 2)[1], other_repo) |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
345 description = _form['pullrequest_desc'] |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
346 try: |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
347 pull_request = PullRequestModel().create( |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
348 self.rhodecode_user.user_id, org_repo, org_ref, other_repo, |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
349 other_ref, revisions, reviewers, title, description |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
350 ) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
351 Session().commit() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
352 h.flash(_('Successfully opened new pull request'), |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
353 category='success') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
354 except Exception: |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
355 h.flash(_('Error occurred during sending pull request'), |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
356 category='error') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
357 log.error(traceback.format_exc()) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
358 return redirect(url('pullrequest_home', repo_name=repo_name)) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
359 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
360 return redirect(url('pullrequest_show', repo_name=other_repo, |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
361 pull_request_id=pull_request.pull_request_id)) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
362 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
363 @LoginRequired() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
364 @NotAnonymous() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
365 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
366 'repository.admin') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
367 @jsonify |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
368 def update(self, repo_name, pull_request_id): |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
369 pull_request = PullRequest.get_or_404(pull_request_id) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
370 if pull_request.is_closed(): |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
371 raise HTTPForbidden() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
372 #only owner or admin can update it |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
373 owner = pull_request.author.user_id == c.rhodecode_user.user_id |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
374 repo_admin = h.HasRepoPermissionAny('repository.admin')(c.repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
375 if h.HasPermissionAny('hg.admin') or repo_admin or owner: |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
376 reviewers_ids = map(int, filter(lambda v: v not in [None, ''], |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
377 request.POST.get('reviewers_ids', '').split(','))) |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
378 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
379 PullRequestModel().update_reviewers(pull_request_id, reviewers_ids) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
380 Session().commit() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
381 return True |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
382 raise HTTPForbidden() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
383 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
384 @LoginRequired() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
385 @NotAnonymous() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
386 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
387 'repository.admin') |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
388 @jsonify |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
389 def delete(self, repo_name, pull_request_id): |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
390 pull_request = PullRequest.get_or_404(pull_request_id) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
391 #only owner can delete it ! |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
392 if pull_request.author.user_id == c.rhodecode_user.user_id: |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
393 PullRequestModel().delete(pull_request) |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
394 Session().commit() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
395 h.flash(_('Successfully deleted pull request'), |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
396 category='success') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
397 return redirect(url('my_account_pullrequests')) |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
398 raise HTTPForbidden() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
399 |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
400 @LoginRequired() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
401 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
402 'repository.admin') |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
403 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
|
404 repo_model = RepoModel() |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
405 c.users_array = repo_model.get_users_js() |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
406 c.user_groups_array = repo_model.get_user_groups_js() |
2496
fddd8e3fc157
use get_or_404 where possible
Marcin Kuzminski <marcin@python-works.com>
parents:
2489
diff
changeset
|
407 c.pull_request = PullRequest.get_or_404(pull_request_id) |
3104
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
408 c.allowed_to_change_status = self._get_is_allowed_change_status(c.pull_request) |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
409 cc_model = ChangesetCommentsModel() |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
410 cs_model = ChangesetStatusModel() |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
411 _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
|
412 pull_request=c.pull_request, |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
413 with_revisions=True) |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
414 |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
415 cs_statuses = defaultdict(list) |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
416 for st in _cs_statuses: |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
417 cs_statuses[st.author.username] += [st] |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
418 |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
419 c.pull_request_reviewers = [] |
2712
7224882c4059
new summary for opened pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2711
diff
changeset
|
420 c.pull_request_pending_reviewers = [] |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
421 for o in c.pull_request.reviewers: |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
422 st = cs_statuses.get(o.user.username, None) |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
423 if st: |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
424 sorter = lambda k: k.version |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
425 st = [(x, list(y)[0]) |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
426 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
|
427 else: |
7224882c4059
new summary for opened pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2711
diff
changeset
|
428 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
|
429 c.pull_request_reviewers.append([o.user, st]) |
2444 | 430 |
431 # pull_requests repo_name we opened it against | |
432 # ie. other_repo must match | |
433 if repo_name != c.pull_request.other_repo.repo_name: | |
434 raise HTTPNotFound | |
435 | |
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
|
436 # 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
|
437 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
|
438 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
|
439 |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
440 # inline comments |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
441 c.inline_cnt = 0 |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
442 c.inline_comments = cc_model.get_inline_comments( |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
443 c.rhodecode_db_repo.repo_id, |
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
444 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
|
445 # count inline comments |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
446 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
|
447 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
|
448 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
|
449 # comments |
2481
4d3032431d4f
Adde pull request voting recalculation
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
450 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
|
451 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
|
452 |
4053
3625fd19b201
pull requests: add a 'Calculated' comment on current_changeset_status
Mads Kiilerich <madski@unity3d.com>
parents:
4052
diff
changeset
|
453 # (badly named) pull-request status calculation based on reviewer votes |
4052
a7b7526c7f7c
pullrequests: drop unused status calculation introduced in 0b2214604c74
Mads Kiilerich <madski@unity3d.com>
parents:
4024
diff
changeset
|
454 c.current_changeset_status = cs_model.calculate_status( |
a7b7526c7f7c
pullrequests: drop unused status calculation introduced in 0b2214604c74
Mads Kiilerich <madski@unity3d.com>
parents:
4024
diff
changeset
|
455 c.pull_request_reviewers, |
2803
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
456 ) |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2434
diff
changeset
|
457 c.changeset_statuses = ChangesetStatus.STATUSES |
2803
0b2214604c74
Fixed status of changesets in preview windows
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
458 |
3442
b3680a200f75
compare: cleanup of as_form handling
Mads Kiilerich <madski@unity3d.com>
parents:
3430
diff
changeset
|
459 c.as_form = False |
3486
2053053e0882
compare/pullrequest: introduce merge parameter
Mads Kiilerich <madski@unity3d.com>
parents:
3485
diff
changeset
|
460 c.ancestor = None # there is one - but right here we don't know which |
2434
f29469677319
Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2395
diff
changeset
|
461 return render('/pullrequests/pullrequest_show.html') |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
462 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
463 @LoginRequired() |
2627
6bd62617b99f
Opening pull request shouldn't be accessible by anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
2614
diff
changeset
|
464 @NotAnonymous() |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
465 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
466 'repository.admin') |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
467 @jsonify |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
468 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
|
469 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
|
470 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
|
471 raise HTTPForbidden() |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
472 |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
473 status = request.POST.get('changeset_status') |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
474 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
|
475 text = request.POST.get('text') |
3430
bbe21df7ad48
notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3394
diff
changeset
|
476 close_pr = request.POST.get('save_close') |
3104
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
477 |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
478 allowed_to_change_status = self._get_is_allowed_change_status(pull_request) |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
479 if status and change_status and allowed_to_change_status: |
3654
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
480 _def = (_('Status change -> %s') |
2796
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2769
diff
changeset
|
481 % ChangesetStatus.get_status_lbl(status)) |
3430
bbe21df7ad48
notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3394
diff
changeset
|
482 if close_pr: |
bbe21df7ad48
notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3394
diff
changeset
|
483 _def = _('Closing with') + ' ' + _def |
bbe21df7ad48
notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3394
diff
changeset
|
484 text = text or _def |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
485 comm = ChangesetCommentsModel().create( |
2796
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2769
diff
changeset
|
486 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
|
487 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
|
488 user=c.rhodecode_user.user_id, |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
489 pull_request=pull_request_id, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
490 f_path=request.POST.get('f_path'), |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
491 line_no=request.POST.get('line'), |
2478
8eab81115660
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2444
diff
changeset
|
492 status_change=(ChangesetStatus.get_status_lbl(status) |
3430
bbe21df7ad48
notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3394
diff
changeset
|
493 if status and change_status |
bbe21df7ad48
notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3394
diff
changeset
|
494 and allowed_to_change_status else None), |
bbe21df7ad48
notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3394
diff
changeset
|
495 closing_pr=close_pr |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
496 ) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
497 |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
498 action_logger(self.rhodecode_user, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
499 'user_commented_pull_request:%s' % pull_request_id, |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
500 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
|
501 |
3104
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
502 if allowed_to_change_status: |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
503 # get status if set ! |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
504 if status and change_status: |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
505 ChangesetStatusModel().set_status( |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
506 c.rhodecode_db_repo.repo_id, |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
507 status, |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
508 c.rhodecode_user.user_id, |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
509 comm, |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
510 pull_request=pull_request_id |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
511 ) |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
512 |
3430
bbe21df7ad48
notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3394
diff
changeset
|
513 if close_pr: |
3104
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
514 if status in ['rejected', 'approved']: |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
515 PullRequestModel().close_pull_request(pull_request_id) |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
516 action_logger(self.rhodecode_user, |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
517 'user_closed_pull_request:%s' % pull_request_id, |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
518 c.rhodecode_db_repo, self.ip_addr, self.sa) |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
519 else: |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
520 h.flash(_('Closing pull request on other statuses than ' |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
521 'rejected or approved forbidden'), |
c77d5c6358eb
Implemented #670 Implementation of Roles in Pull Request
Marcin Kuzminski <marcin@python-works.com>
parents:
3103
diff
changeset
|
522 category='warning') |
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
|
523 |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2533
diff
changeset
|
524 Session().commit() |
2443
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
525 |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
526 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
|
527 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
|
528 pull_request_id=pull_request_id)) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
529 |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
530 data = { |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
531 '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
|
532 } |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
533 if comm: |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
534 c.co = comm |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
535 data.update(comm.get_dict()) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
536 data.update({'rendered_text': |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
537 render('changeset/changeset_comment_block.html')}) |
fd0a822481ec
- added commenting to pull requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2442
diff
changeset
|
538 |
2444 | 539 return data |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
540 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
541 @LoginRequired() |
2627
6bd62617b99f
Opening pull request shouldn't be accessible by anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
2614
diff
changeset
|
542 @NotAnonymous() |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
543 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
544 'repository.admin') |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
545 @jsonify |
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
546 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
|
547 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
|
548 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
|
549 #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
|
550 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
|
551 |
3141
a45191e7c7bb
access control: fix owner checks - they were always true
Mads Kiilerich <madski@unity3d.com>
parents:
3123
diff
changeset
|
552 owner = co.author.user_id == c.rhodecode_user.user_id |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
553 repo_admin = h.HasRepoPermissionAny('repository.admin')(c.repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4080
diff
changeset
|
554 if h.HasPermissionAny('hg.admin') or repo_admin or owner: |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
555 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
|
556 Session().commit() |
2489
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
557 return True |
a0adf8db1416
Enabled inline comments in pull-requests
Marcin Kuzminski <marcin@python-works.com>
parents:
2487
diff
changeset
|
558 else: |
2614
3f50a5e8fc4d
Added editing of pull-request reviewers.
Marcin Kuzminski <marcin@python-works.com>
parents:
2612
diff
changeset
|
559 raise HTTPForbidden() |