##// END OF EJS Templates
old style: show compare "Compare Revisions" inline ... and do the same with all other buttons
old style: show compare "Compare Revisions" inline ... and do the same with all other buttons

File last commit:

r4116:ffd45b18 rhodecode-2.2.5-gpl
r4151:8b8f4a93 rhodecode-2.2.5-gpl
Show More
pullrequests.py
559 lines | 22.7 KiB | text/x-python | PythonLexer
pull requests draft UI
r2244 # -*- coding: utf-8 -*-
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 """
rhodecode.controllers.pullrequests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pull requests controller for rhodecode for initializing pull requests
:created_on: May 7, 2012
:author: marcink
:copyright: (c) 2013 RhodeCode GmbH.
:license: GPLv3, see LICENSE for more details.
"""
pull requests draft UI
r2244 import logging
import traceback
added more validations when opening pull request...
r2711 import formencode
- pull request generates overview based on it's params...
r2440
Enabled inline comments in pull-requests
r2489 from webob.exc import HTTPNotFound, HTTPForbidden
Adde pull request voting recalculation
r2481 from collections import defaultdict
from itertools import groupby
pull requests draft UI
r2244
Moved all Mercurial imports into hgcompat from vcs
r3941 from pylons import request, tmpl_context as c, url
from pylons.controllers.util import redirect
pull requests draft UI
r2244 from pylons.i18n.translation import _
Added dynamic data loading for other repo we open pull request against...
r2541 from rhodecode.lib.compat import json
pull requests draft UI
r2244 from rhodecode.lib.base import BaseRepoController, render
Added autocomplete widget for pull request reviewers, in exchange of 90s style...
r2612 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator,\
NotAnonymous
pagination in pull-requests page + UI
r3676 from rhodecode.lib.helpers import Page
Added basic models for saving open pull requests...
r2434 from rhodecode.lib import helpers as h
- pull request generates overview based on it's params...
r2440 from rhodecode.lib import diffs
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
r3061 from rhodecode.lib.utils import action_logger, jsonify
Mads Kiilerich
diffs: drop diffs.differ...
r3718 from rhodecode.lib.vcs.utils import safe_str
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
r3061 from rhodecode.lib.vcs.exceptions import EmptyRepositoryError
from rhodecode.lib.diffs import LimitedDiffContainer
Moved all Mercurial imports into hgcompat from vcs
r3941 from rhodecode.model.db import PullRequest, ChangesetStatus, ChangesetComment
Added basic models for saving open pull requests...
r2434 from rhodecode.model.pull_request import PullRequestModel
from rhodecode.model.meta import Session
- pull request generates overview based on it's params...
r2440 from rhodecode.model.repo import RepoModel
from rhodecode.model.comment import ChangesetCommentsModel
from rhodecode.model.changeset_status import ChangesetStatusModel
added more validations when opening pull request...
r2711 from rhodecode.model.forms import PullRequestForm
pagination in pull-requests page + UI
r3676 from rhodecode.lib.utils2 import safe_int
pull requests draft UI
r2244
log = logging.getLogger(__name__)
class PullrequestsController(BaseRepoController):
def __before__(self):
super(PullrequestsController, self).__before__()
Added autocomplete widget for pull request reviewers, in exchange of 90s style...
r2612 repo_model = RepoModel()
c.users_array = repo_model.get_users_js()
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 c.user_groups_array = repo_model.get_user_groups_js()
pull requests draft UI
r2244
Mads Kiilerich
pull requests: use branch name when creating PRs from a changelog with branch filter
r3813 def _get_repo_refs(self, repo, rev=None, branch=None, branch_rev=None):
Mads Kiilerich
pullrequests: refactor changeset selectors, tip is special and not a real tag
r3444 """return a structure with repo's interesting changesets, suitable for
Mads Kiilerich
hg: use 'revset injection safe' repo.revs for revsets
r3811 the selectors in pullrequest.html
Mads Kiilerich
pull requests: use branch name when creating PRs from a changelog with branch filter
r3813 rev: a revision that must be in the list somehow and selected by default
branch: a branch that must be in the list and selected by default - even if closed
Mads Kiilerich
hg: use 'revset injection safe' repo.revs for revsets
r3811 branch_rev: a revision of which peers should be preferred and available."""
Mads Kiilerich
pullrequest selection list: emphasize named branches that are neighbours
r3515 # list named branches that has been merged to this named branch - it should probably merge back
Mads Kiilerich
pullrequests: only create special select entry for a changeset if it has no symbolic name
r3598 peers = []
Mads Kiilerich
pullrequests: don't pass unicode strings to Mercurial
r3719
if rev:
rev = safe_str(rev)
Mads Kiilerich
pull requests: use branch name when creating PRs from a changelog with branch filter
r3813 if branch:
branch = safe_str(branch)
Mads Kiilerich
pullrequest selection list: emphasize named branches that are neighbours
r3515 if branch_rev:
Mads Kiilerich
pullrequests: don't pass unicode strings to Mercurial
r3719 branch_rev = safe_str(branch_rev)
Mads Kiilerich
pullrequest selection list: emphasize named branches that are neighbours
r3515 # not restricting to merge() would also get branch point and be better
# (especially because it would get the branch point) ... but is currently too expensive
otherbranches = {}
Mads Kiilerich
hg: use 'revset injection safe' repo.revs for revsets
r3811 for i in repo._repo.revs(
"sort(parents(branch(id(%s)) and merge()) - branch(id(%s)))",
branch_rev, branch_rev):
Mads Kiilerich
pullrequest selection list: emphasize named branches that are neighbours
r3515 cs = repo.get_changeset(i)
otherbranches[cs.branch] = cs.raw_id
Mads Kiilerich
hg: use 'revset injection safe' repo.revs for revsets
r3811 for abranch, node in otherbranches.iteritems():
selected = 'branch:%s:%s' % (abranch, node)
peers.append((selected, abranch))
Mads Kiilerich
pullrequests: only create special select entry for a changeset if it has no symbolic name
r3598
selected = None
Mads Kiilerich
hg: use 'revset injection safe' repo.revs for revsets
r3811
Mads Kiilerich
pullrequests: only create special select entry for a changeset if it has no symbolic name
r3598 branches = []
Mads Kiilerich
hg: use 'revset injection safe' repo.revs for revsets
r3811 for abranch, branchrev in repo.branches.iteritems():
n = 'branch:%s:%s' % (abranch, branchrev)
branches.append((n, abranch))
Mads Kiilerich
pullrequests: only create special select entry for a changeset if it has no symbolic name
r3598 if rev == branchrev:
selected = n
Mads Kiilerich
pull requests: use branch name when creating PRs from a changelog with branch filter
r3813 if branch == abranch:
selected = n
branch = None
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116
if branch: # branch not in list - it is probably closed
Mads Kiilerich
pull requests: use branch name when creating PRs from a changelog with branch filter
r3813 revs = repo._repo.revs('max(branch(%s))', branch)
if revs:
cs = repo.get_changeset(revs[0])
selected = 'branch:%s:%s' % (branch, cs.raw_id)
branches.append((selected, branch))
Mads Kiilerich
hg: use 'revset injection safe' repo.revs for revsets
r3811
Mads Kiilerich
pullrequests: only create special select entry for a changeset if it has no symbolic name
r3598 bookmarks = []
for bookmark, bookmarkrev in repo.bookmarks.iteritems():
n = 'book:%s:%s' % (bookmark, bookmarkrev)
bookmarks.append((n, bookmark))
if rev == bookmarkrev:
selected = n
Mads Kiilerich
hg: use 'revset injection safe' repo.revs for revsets
r3811
Mads Kiilerich
pullrequests: only create special select entry for a changeset if it has no symbolic name
r3598 tags = []
for tag, tagrev in repo.tags.iteritems():
n = 'tag:%s:%s' % (tag, tagrev)
tags.append((n, tag))
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 if rev == tagrev and tag != 'tip': # tip is not a real tag - and its branch is better
Mads Kiilerich
pullrequests: only create special select entry for a changeset if it has no symbolic name
r3598 selected = n
pull requests draft UI
r2244
Mads Kiilerich
pullrequests: only create special select entry for a changeset if it has no symbolic name
r3598 # prio 1: rev was selected as existing entry above
# prio 2: create special entry for rev; rev _must_ be used
specials = []
if rev and selected is None:
selected = 'rev:%s:%s' % (rev, rev)
specials = [(selected, '%s: %s' % (_("Changeset"), rev[:12]))]
# prio 3: most recent peer branch
if peers and not selected:
selected = peers[0][0][0]
# prio 4: tip revision
if not selected:
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 if h.is_hg(repo):
selected = 'tag:tip:%s' % repo.tags['tip']
else:
if 'master' in repo.branches:
selected = 'branch:master:%s' % repo.branches['master']
else:
k, v = repo.branches.items()[0]
selected = 'branch:%s:%s' % (k, v)
Mads Kiilerich
pullrequests: only create special select entry for a changeset if it has no symbolic name
r3598
groups = [(specials, _("Special")),
(peers, _("Peer branches")),
(bookmarks, _("Bookmarks")),
(branches, _("Branches")),
(tags, _("Tags")),
]
return [g for g in groups if g[0]], selected
fixed few issues with autoselection of revisions on pull requests
r2849
Implemented #670 Implementation of Roles in Pull Request...
r3104 def _get_is_allowed_change_status(self, pull_request):
white space cleanup
r3149 owner = self.rhodecode_user.user_id == pull_request.user_id
Implemented #670 Implementation of Roles in Pull Request...
r3104 reviewer = self.rhodecode_user.user_id in [x.user_id for x in
pull_request.reviewers]
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 return self.rhodecode_user.admin or owner or reviewer
Implemented #670 Implementation of Roles in Pull Request...
r3104
Added option to close pull requests, in future that will be close & merge
r2608 def _load_compare_data(self, pull_request, enable_comments=True):
small refactoring, moved shared for diff generation of code into pull-request model
r2442 """
Load context data needed for generating compare diff
- pull request generates overview based on it's params...
r2440
small refactoring, moved shared for diff generation of code into pull-request model
r2442 :param pull_request:
"""
- pull request generates overview based on it's params...
r2440 org_repo = pull_request.org_repo
added more validations when opening pull request...
r2711 (org_ref_type,
org_ref_name,
org_ref_rev) = pull_request.org_ref.split(':')
Basic implementation of cherry picking changesets...
r3023 other_repo = org_repo
added more validations when opening pull request...
r2711 (other_ref_type,
other_ref_name,
other_ref_rev) = pull_request.other_ref.split(':')
- pull request generates overview based on it's params...
r2440
Load generated revs while switching to other sources of pull-requests....
r2720 # despite opening revisions for bookmarks/branches/tags, we always
Mads Kiilerich
compare: drop unused rev_start and rev_end
r3484 # convert this to rev to prevent changes after bookmark or branch change
added more validations when opening pull request...
r2711 org_ref = ('rev', org_ref_rev)
other_ref = ('rev', other_ref_rev)
- pull request generates overview based on it's params...
r2440
c.org_repo = org_repo
c.other_repo = other_repo
Basic implementation of cherry picking changesets...
r3023 c.fulldiff = fulldiff = request.GET.get('fulldiff')
c.cs_ranges = [org_repo.get_changeset(x) for x in pull_request.revisions]
Fixed status of changesets in preview windows...
r2803 c.statuses = org_repo.statuses([x.raw_id for x in c.cs_ranges])
- pull request generates overview based on it's params...
r2440
c.org_ref = org_ref[1]
show links to files on compare data at other and org refs
r3357 c.org_ref_type = org_ref[0]
- pull request generates overview based on it's params...
r2440 c.other_ref = other_ref[1]
show links to files on compare data at other and org refs
r3357 c.other_ref_type = other_ref[0]
Basic implementation of cherry picking changesets...
r3023
diff_limit = self.cut_off_limit if not fulldiff else None
Mads Kiilerich
pullrequests: fix reversed diff...
r3739 # we swap org/other ref since we run a simple diff on one repo
Mads Kiilerich
diff: cleanup of variables and logging in compare and pullrequests
r3812 log.debug('running diff between %s and %s in %s'
% (other_ref, org_ref, org_repo.scm_instance.path))
txtdiff = org_repo.scm_instance.get_diff(rev1=safe_str(other_ref[1]), rev2=safe_str(org_ref[1]))
Multiple changes for compare system...
r3015
Mads Kiilerich
diff: cleanup of variables and logging in compare and pullrequests
r3812 diff_processor = diffs.DiffProcessor(txtdiff or '', format='gitdiff',
Basic implementation of cherry picking changesets...
r3023 diff_limit=diff_limit)
- pull request generates overview based on it's params...
r2440 _parsed = diff_processor.prepare()
Basic implementation of cherry picking changesets...
r3023 c.limited_diff = False
if isinstance(_parsed, LimitedDiffContainer):
c.limited_diff = True
- pull request generates overview based on it's params...
r2440 c.files = []
c.changes = {}
bring back accidentally deleted context variables with lines added
r3825 c.lines_added = 0
c.lines_deleted = 0
- pull request generates overview based on it's params...
r2440 for f in _parsed:
Basic implementation of cherry picking changesets...
r3023 st = f['stats']
diff parser: redefined operations stats for changes...
r3821 c.lines_added += st['added']
c.lines_deleted += st['deleted']
- pull request generates overview based on it's params...
r2440 fid = h.FID('', f['filename'])
c.files.append([fid, f['operation'], f['filename'], f['stats']])
Mads Kiilerich
diff: cleanup of variables and logging in compare and pullrequests
r3812 htmldiff = diff_processor.as_html(enable_comments=enable_comments,
parsed_lines=[f])
c.changes[fid] = [f['operation'], f['filename'], htmldiff]
- pull request generates overview based on it's params...
r2440
auth decorators are not used anymore on __before__...
r3749 @LoginRequired()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
def show_all(self, repo_name):
Mads Kiilerich
pull requests: make it possible control display of closed PRs and whether it is PRs to or from repo
r4024 c.from_ = request.GET.get('from_') or ''
c.closed = request.GET.get('closed') or ''
c.pull_requests = PullRequestModel().get_all(repo_name, from_=c.from_, closed=c.closed)
auth decorators are not used anymore on __before__...
r3749 c.repo_name = repo_name
p = safe_int(request.GET.get('page', 1), 1)
c.pullrequests_pager = Page(c.pull_requests, page=p, items_per_page=10)
c.pullrequest_data = render('/pullrequests/pullrequest_data.html')
if request.environ.get('HTTP_X_PARTIAL_XHR'):
return c.pullrequest_data
return render('/pullrequests/pullrequest_show_all.html')
@LoginRequired()
@NotAnonymous()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
def index(self):
org_repo = c.rhodecode_db_repo
try:
org_repo.scm_instance.get_changeset()
except EmptyRepositoryError, e:
h.flash(h.literal(_('There are no changesets yet')),
category='warning')
redirect(url('summary_home', repo_name=org_repo.repo_name))
org_rev = request.GET.get('rev_end')
# rev_start is not directly useful - its parent could however be used
# as default for other and thus give a simple compare view
#other_rev = request.POST.get('rev_start')
Mads Kiilerich
pull requests: use branch name when creating PRs from a changelog with branch filter
r3813 branch = request.GET.get('branch')
auth decorators are not used anymore on __before__...
r3749
c.org_repos = []
c.org_repos.append((org_repo.repo_name, org_repo.repo_name))
c.default_org_repo = org_repo.repo_name
Mads Kiilerich
pull requests: use branch name when creating PRs from a changelog with branch filter
r3813 c.org_refs, c.default_org_ref = self._get_repo_refs(org_repo.scm_instance, rev=org_rev, branch=branch)
auth decorators are not used anymore on __before__...
r3749
c.other_repos = []
other_repos_info = {}
def add_other_repo(repo, branch_rev=None):
if repo.repo_name in other_repos_info: # shouldn't happen
return
c.other_repos.append((repo.repo_name, repo.repo_name))
other_refs, selected_other_ref = self._get_repo_refs(repo.scm_instance, branch_rev=branch_rev)
other_repos_info[repo.repo_name] = {
'user': dict(user_id=repo.user.user_id,
username=repo.user.username,
firstname=repo.user.firstname,
lastname=repo.user.lastname,
gravatar_link=h.gravatar_url(repo.user.email, 14)),
'description': repo.description.split('\n', 1)[0],
'revs': h.select('other_ref', selected_other_ref, other_refs, class_='refs')
}
# add org repo to other so we can open pull request against peer branches on itself
add_other_repo(org_repo, branch_rev=org_rev)
c.default_other_repo = org_repo.repo_name
# gather forks and add to this list ... even though it is rare to
# request forks to pull from their parent
for fork in org_repo.forks:
add_other_repo(fork)
# add parents of this fork also, but only if it's not empty
if org_repo.parent and org_repo.parent.scm_instance.revisions:
add_other_repo(org_repo.parent)
c.default_other_repo = org_repo.parent.repo_name
c.default_other_repo_info = other_repos_info[c.default_other_repo]
c.other_repos_info = json.dumps(other_repos_info)
return render('/pullrequests/pullrequest.html')
@LoginRequired()
@NotAnonymous()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
def create(self, repo_name):
repo = RepoModel()._get_repo(repo_name)
try:
_form = PullRequestForm(repo.repo_id)().to_python(request.POST)
except formencode.Invalid, errors:
log.error(traceback.format_exc())
if errors.error_dict.get('revisions'):
msg = 'Revisions: %s' % errors.error_dict['revisions']
elif errors.error_dict.get('pullrequest_title'):
msg = _('Pull request requires a title with min. 3 chars')
else:
Mads Kiilerich
pull requests: give slightly more useful error messages on failing form validation
r4080 msg = _('Error creating pull request: %s') % errors.msg
auth decorators are not used anymore on __before__...
r3749
h.flash(msg, 'error')
Mads Kiilerich
pull requests: give slightly more useful error messages on failing form validation
r4080 return redirect(url('pullrequest_home', repo_name=repo_name)) ## would rather just go back to form ...
auth decorators are not used anymore on __before__...
r3749
org_repo = _form['org_repo']
Mads Kiilerich
pull requests: use org_ref with correct symbolic name instead of fake one...
r3978 org_ref = _form['org_ref'] # will end with merge_rev but have symbolic name
auth decorators are not used anymore on __before__...
r3749 other_repo = _form['other_repo']
Mads Kiilerich
pull requests: use org_ref with correct symbolic name instead of fake one...
r3978 other_ref = 'rev:ancestor:%s' % _form['ancestor_rev'] # could be calculated from other_ref ...
create a list out of generator....
r3785 revisions = [x for x in reversed(_form['revisions'])]
auth decorators are not used anymore on __before__...
r3749 reviewers = _form['review_members']
title = _form['pullrequest_title']
Mads Kiilerich
pull requests: make title optional - generate one automatically
r4058 if not title:
title = '%s#%s to %s' % (org_repo, org_ref.split(':', 2)[1], other_repo)
auth decorators are not used anymore on __before__...
r3749 description = _form['pullrequest_desc']
try:
pull_request = PullRequestModel().create(
self.rhodecode_user.user_id, org_repo, org_ref, other_repo,
other_ref, revisions, reviewers, title, description
)
Session().commit()
h.flash(_('Successfully opened new pull request'),
category='success')
except Exception:
h.flash(_('Error occurred during sending pull request'),
category='error')
log.error(traceback.format_exc())
return redirect(url('pullrequest_home', repo_name=repo_name))
return redirect(url('pullrequest_show', repo_name=other_repo,
pull_request_id=pull_request.pull_request_id))
@LoginRequired()
@NotAnonymous()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
@jsonify
def update(self, repo_name, pull_request_id):
pull_request = PullRequest.get_or_404(pull_request_id)
if pull_request.is_closed():
raise HTTPForbidden()
#only owner or admin can update it
owner = pull_request.author.user_id == c.rhodecode_user.user_id
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 repo_admin = h.HasRepoPermissionAny('repository.admin')(c.repo_name)
if h.HasPermissionAny('hg.admin') or repo_admin or owner:
auth decorators are not used anymore on __before__...
r3749 reviewers_ids = map(int, filter(lambda v: v not in [None, ''],
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 request.POST.get('reviewers_ids', '').split(',')))
auth decorators are not used anymore on __before__...
r3749
PullRequestModel().update_reviewers(pull_request_id, reviewers_ids)
Session().commit()
return True
raise HTTPForbidden()
@LoginRequired()
@NotAnonymous()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
@jsonify
def delete(self, repo_name, pull_request_id):
pull_request = PullRequest.get_or_404(pull_request_id)
#only owner can delete it !
if pull_request.author.user_id == c.rhodecode_user.user_id:
PullRequestModel().delete(pull_request)
Session().commit()
h.flash(_('Successfully deleted pull request'),
category='success')
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 return redirect(url('my_account_pullrequests'))
auth decorators are not used anymore on __before__...
r3749 raise HTTPForbidden()
@LoginRequired()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
Added basic models for saving open pull requests...
r2434 def show(self, repo_name, pull_request_id):
- pull request generates overview based on it's params...
r2440 repo_model = RepoModel()
c.users_array = repo_model.get_users_js()
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 c.user_groups_array = repo_model.get_user_groups_js()
use get_or_404 where possible
r2496 c.pull_request = PullRequest.get_or_404(pull_request_id)
Implemented #670 Implementation of Roles in Pull Request...
r3104 c.allowed_to_change_status = self._get_is_allowed_change_status(c.pull_request)
Adde pull request voting recalculation
r2481 cc_model = ChangesetCommentsModel()
cs_model = ChangesetStatusModel()
_cs_statuses = cs_model.get_statuses(c.pull_request.org_repo,
pull_request=c.pull_request,
with_revisions=True)
cs_statuses = defaultdict(list)
for st in _cs_statuses:
cs_statuses[st.author.username] += [st]
c.pull_request_reviewers = []
new summary for opened pull requests...
r2712 c.pull_request_pending_reviewers = []
Adde pull request voting recalculation
r2481 for o in c.pull_request.reviewers:
st = cs_statuses.get(o.user.username, None)
if st:
sorter = lambda k: k.version
st = [(x, list(y)[0])
for x, y in (groupby(sorted(st, key=sorter), sorter))]
new summary for opened pull requests...
r2712 else:
c.pull_request_pending_reviewers.append(o.user)
Adde pull request voting recalculation
r2481 c.pull_request_reviewers.append([o.user, st])
data checks
r2444
# pull_requests repo_name we opened it against
# ie. other_repo must match
if repo_name != c.pull_request.other_repo.repo_name:
raise HTTPNotFound
small refactoring, moved shared for diff generation of code into pull-request model
r2442 # load compare data into template context
Added option to close pull requests, in future that will be close & merge
r2608 enable_comments = not c.pull_request.is_closed()
self._load_compare_data(c.pull_request, enable_comments=enable_comments)
- pull request generates overview based on it's params...
r2440
# inline comments
c.inline_cnt = 0
Adde pull request voting recalculation
r2481 c.inline_comments = cc_model.get_inline_comments(
c.rhodecode_db_repo.repo_id,
pull_request=pull_request_id)
- pull request generates overview based on it's params...
r2440 # count inline comments
for __, lines in c.inline_comments:
for comments in lines.values():
c.inline_cnt += len(comments)
# comments
Adde pull request voting recalculation
r2481 c.comments = cc_model.get_comments(c.rhodecode_db_repo.repo_id,
pull_request=pull_request_id)
- pull request generates overview based on it's params...
r2440
Mads Kiilerich
pull requests: add a 'Calculated' comment on current_changeset_status
r4053 # (badly named) pull-request status calculation based on reviewer votes
Mads Kiilerich
pullrequests: drop unused status calculation introduced in 0b2214604c74
r4052 c.current_changeset_status = cs_model.calculate_status(
c.pull_request_reviewers,
Fixed status of changesets in preview windows...
r2803 )
- pull request generates overview based on it's params...
r2440 c.changeset_statuses = ChangesetStatus.STATUSES
Fixed status of changesets in preview windows...
r2803
Mads Kiilerich
compare: cleanup of as_form handling...
r3442 c.as_form = False
Mads Kiilerich
compare/pullrequest: introduce merge parameter...
r3486 c.ancestor = None # there is one - but right here we don't know which
Added basic models for saving open pull requests...
r2434 return render('/pullrequests/pullrequest_show.html')
- added commenting to pull requests...
r2443
auth decorators are not used anymore on __before__...
r3749 @LoginRequired()
Opening pull request shouldn't be accessible by anonymous users
r2627 @NotAnonymous()
auth decorators are not used anymore on __before__...
r3749 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
- added commenting to pull requests...
r2443 @jsonify
def comment(self, repo_name, pull_request_id):
Added option to close pull requests, in future that will be close & merge
r2608 pull_request = PullRequest.get_or_404(pull_request_id)
if pull_request.is_closed():
raise HTTPForbidden()
- added commenting to pull requests...
r2443
status = request.POST.get('changeset_status')
change_status = request.POST.get('change_changeset_status')
always post text about status changes of code-review
r2796 text = request.POST.get('text')
notifications changes...
r3430 close_pr = request.POST.get('save_close')
Implemented #670 Implementation of Roles in Pull Request...
r3104
allowed_to_change_status = self._get_is_allowed_change_status(pull_request)
if status and change_status and allowed_to_change_status:
Mads Kiilerich
Fix a lot of casings - use standard casing in most places
r3654 _def = (_('Status change -> %s')
always post text about status changes of code-review
r2796 % ChangesetStatus.get_status_lbl(status))
notifications changes...
r3430 if close_pr:
_def = _('Closing with') + ' ' + _def
text = text or _def
- added commenting to pull requests...
r2443 comm = ChangesetCommentsModel().create(
always post text about status changes of code-review
r2796 text=text,
Added dynamic data loading for other repo we open pull request against...
r2541 repo=c.rhodecode_db_repo.repo_id,
user=c.rhodecode_user.user_id,
- added commenting to pull requests...
r2443 pull_request=pull_request_id,
f_path=request.POST.get('f_path'),
line_no=request.POST.get('line'),
white space cleanup
r2478 status_change=(ChangesetStatus.get_status_lbl(status)
notifications changes...
r3430 if status and change_status
and allowed_to_change_status else None),
closing_pr=close_pr
- added commenting to pull requests...
r2443 )
action_logger(self.rhodecode_user,
'user_commented_pull_request:%s' % pull_request_id,
c.rhodecode_db_repo, self.ip_addr, self.sa)
Implemented #670 Implementation of Roles in Pull Request...
r3104 if allowed_to_change_status:
# get status if set !
if status and change_status:
ChangesetStatusModel().set_status(
c.rhodecode_db_repo.repo_id,
status,
c.rhodecode_user.user_id,
comm,
pull_request=pull_request_id
)
notifications changes...
r3430 if close_pr:
Implemented #670 Implementation of Roles in Pull Request...
r3104 if status in ['rejected', 'approved']:
PullRequestModel().close_pull_request(pull_request_id)
action_logger(self.rhodecode_user,
'user_closed_pull_request:%s' % pull_request_id,
c.rhodecode_db_repo, self.ip_addr, self.sa)
else:
h.flash(_('Closing pull request on other statuses than '
'rejected or approved forbidden'),
category='warning')
Added option to close pull requests, in future that will be close & merge
r2608
Added dynamic data loading for other repo we open pull request against...
r2541 Session().commit()
- added commenting to pull requests...
r2443
if not request.environ.get('HTTP_X_PARTIAL_XHR'):
return redirect(h.url('pullrequest_show', repo_name=repo_name,
pull_request_id=pull_request_id))
data = {
'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))),
}
if comm:
c.co = comm
data.update(comm.get_dict())
data.update({'rendered_text':
render('changeset/changeset_comment_block.html')})
data checks
r2444 return data
Enabled inline comments in pull-requests
r2489
auth decorators are not used anymore on __before__...
r3749 @LoginRequired()
Opening pull request shouldn't be accessible by anonymous users
r2627 @NotAnonymous()
auth decorators are not used anymore on __before__...
r3749 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
Enabled inline comments in pull-requests
r2489 @jsonify
def delete_comment(self, repo_name, comment_id):
co = ChangesetComment.get(comment_id)
Added option to close pull requests, in future that will be close & merge
r2608 if co.pull_request.is_closed():
#don't allow deleting comments on closed pull request
raise HTTPForbidden()
Mads Kiilerich
access control: fix owner checks - they were always true...
r3141 owner = co.author.user_id == c.rhodecode_user.user_id
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 repo_admin = h.HasRepoPermissionAny('repository.admin')(c.repo_name)
if h.HasPermissionAny('hg.admin') or repo_admin or owner:
Enabled inline comments in pull-requests
r2489 ChangesetCommentsModel().delete(comment=co)
Added dynamic data loading for other repo we open pull request against...
r2541 Session().commit()
Enabled inline comments in pull-requests
r2489 return True
else:
Added editing of pull-request reviewers.
r2614 raise HTTPForbidden()