##// END OF EJS Templates
i18n: updated translation for Polish...
i18n: updated translation for Polish Currently translated at 56.5% (614 of 1087 strings)

File last commit:

r8078:08eec03c default
r8092:7fef5132 default
Show More
changeset.py
491 lines | 17.8 KiB | text/x-python | PythonLexer
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 # -*- 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/>.
"""
kallithea.controllers.changeset
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thomas De Schampheleire
Turbogears2 migration: remove some references to Pylons in comments...
r6178 changeset controller showing changes between revisions
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
Bradley M. Kuhn
RhodeCode GmbH is not the sole author of this work
r4211 This file was forked by the Kallithea project in July 2014.
Original author and date, and relevant copyright and licensing information is below:
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 :created_on: Apr 25, 2010
:author: marcink
Bradley M. Kuhn
RhodeCode GmbH is not the sole author of this work
r4211 :copyright: (c) 2013 RhodeCode GmbH, and others.
Bradley M. Kuhn
Correct licensing information in individual files....
r4208 :license: GPLv3, see LICENSE.md for more details.
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 """
Mads Kiilerich
changeset: store hexified source hash in context so it is readily available in template...
r7882 import binascii
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 import logging
import traceback
Mads Kiilerich
scripts: initial run of import cleanup using isort
r7718 from collections import OrderedDict, defaultdict
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
Mads Kiilerich
scripts: initial run of import cleanup using isort
r7718 from tg import request, response
from tg import tmpl_context as c
Mads Kiilerich
tg: minimize future diff by some mocking and replacing some pylons imports with tg...
r6508 from tg.i18n import ugettext as _
Mads Kiilerich
scripts: initial run of import cleanup using isort
r7718 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPNotFound
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
import kallithea.lib.helpers as h
Mads Kiilerich
scripts: initial run of import cleanup using isort
r7718 from kallithea.lib import diffs
from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
from kallithea.lib.base import BaseRepoController, jsonify, render
from kallithea.lib.graphmod import graph_data
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 from kallithea.lib.utils import action_logger
Mads Kiilerich
py3: rename all existing safe_unicode to safe_str
r8078 from kallithea.lib.utils2 import ascii_str, safe_str
Mads Kiilerich
scripts: initial run of import cleanup using isort
r7718 from kallithea.lib.vcs.backends.base import EmptyChangeset
from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError
from kallithea.model.changeset_status import ChangesetStatusModel
from kallithea.model.comment import ChangesetCommentsModel
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 from kallithea.model.db import ChangesetComment, ChangesetStatus
from kallithea.model.meta import Session
Mads Kiilerich
pull-request: fix missing imports for delete and close...
r7518 from kallithea.model.pull_request import PullRequestModel
Mads Kiilerich
scripts: initial run of import cleanup using isort
r7718
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
log = logging.getLogger(__name__)
def _update_with_GET(params, GET):
for k in ['diff1', 'diff2', 'diff']:
params[k] += GET.getall(k)
def anchor_url(revision, path, GET):
fid = h.FID(revision, path)
return h.url.current(anchor=fid, **dict(GET))
def get_ignore_ws(fid, GET):
ig_ws_global = GET.get('ignorews')
Mads Kiilerich
py3: use comprehensions and generators instead of filters - it is more explicit, and sometimes shorter...
r7893 ig_ws = [k for k in GET.getall(fid) if k.startswith('WS')]
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 if ig_ws:
Andrew Shadura
changeset: don't crash on malformed whitespace parameter - return 400 Bad Request
r4889 try:
return int(ig_ws[0].split(':')[-1])
except ValueError:
raise HTTPBadRequest()
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 return ig_ws_global
def _ignorews_url(GET, fileid=None):
fileid = str(fileid) if fileid else None
params = defaultdict(list)
_update_with_GET(params, GET)
Mads Kiilerich
spelling: let's call it 'whitespace' without space or hyphen
r4401 lbl = _('Show whitespace')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 ig_ws = get_ignore_ws(fileid, GET)
ln_ctx = get_line_ctx(fileid, GET)
# global option
if fileid is None:
if ig_ws is None:
params['ignorews'] += [1]
Mads Kiilerich
spelling: let's call it 'whitespace' without space or hyphen
r4401 lbl = _('Ignore whitespace')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 ctx_key = 'context'
ctx_val = ln_ctx
# per file options
else:
if ig_ws is None:
params[fileid] += ['WS:1']
Mads Kiilerich
spelling: let's call it 'whitespace' without space or hyphen
r4401 lbl = _('Ignore whitespace')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
ctx_key = fileid
ctx_val = 'C:%s' % ln_ctx
# if we have passed in ln_ctx pass it along to our params
if ln_ctx:
params[ctx_key] += [ctx_val]
params['anchor'] = fileid
Sean Farley
text_strikethrough.png: use new icon-strike font
r4628 icon = h.literal('<i class="icon-strike"></i>')
domruf
template: use Bootstrap tooltips and popover instead of handmade tooltips...
r6394 return h.link_to(icon, h.url.current(**params), title=lbl, **{'data-toggle': 'tooltip'})
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
def get_line_ctx(fid, GET):
ln_ctx_global = GET.get('context')
if fid:
Mads Kiilerich
py3: use comprehensions and generators instead of filters - it is more explicit, and sometimes shorter...
r7893 ln_ctx = [k for k in GET.getall(fid) if k.startswith('C')]
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 else:
Mads Kiilerich
py3: use comprehensions and generators instead of filters - it is more explicit, and sometimes shorter...
r7893 _ln_ctx = [k for k in GET if k.startswith('C')]
Lars Kruse
codingstyle: trivial whitespace fixes...
r6789 ln_ctx = GET.get(_ln_ctx[0]) if _ln_ctx else ln_ctx_global
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 if ln_ctx:
ln_ctx = [ln_ctx]
if ln_ctx:
retval = ln_ctx[0].split(':')[-1]
else:
retval = ln_ctx_global
try:
return int(retval)
except Exception:
return 3
def _context_url(GET, fileid=None):
"""
Generates url for context lines
:param fileid:
"""
fileid = str(fileid) if fileid else None
ig_ws = get_ignore_ws(fileid, GET)
ln_ctx = (get_line_ctx(fileid, GET) or 3) * 2
params = defaultdict(list)
_update_with_GET(params, GET)
# global option
if fileid is None:
if ln_ctx > 0:
params['context'] += [ln_ctx]
if ig_ws:
ig_ws_key = 'ignorews'
ig_ws_val = 1
# per file option
else:
params[fileid] += ['C:%s' % ln_ctx]
ig_ws_key = fileid
ig_ws_val = 'WS:%s' % 1
if ig_ws:
params[ig_ws_key] += [ig_ws_val]
Mads Kiilerich
spelling: fix title casing on various translated strings...
r5127 lbl = _('Increase diff context to %(num)s lines') % {'num': ln_ctx}
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
params['anchor'] = fileid
Sean Farley
table_add.png: use new icon-sort font
r4629 icon = h.literal('<i class="icon-sort"></i>')
domruf
template: use Bootstrap tooltips and popover instead of handmade tooltips...
r6394 return h.link_to(icon, h.url.current(**params), title=lbl, **{'data-toggle': 'tooltip'})
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
Thomas De Schampheleire
controllers: forward pullrequests.comment to changeset...
r7353 def create_cs_pr_comment(repo_name, revision=None, pull_request=None, allowed_to_change_status=True):
Thomas De Schampheleire
controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
r7356 """
Add a comment to the specified changeset or pull request, using POST values
from the request.
Comments can be inline (when a file path and line number is specified in
POST) or general comments.
A comment can be accompanied by a review status change (accepted, rejected,
etc.). Pull requests can be closed or deleted.
Parameter 'allowed_to_change_status' is used for both status changes and
closing of pull requests. For deleting of pull requests, more specific
checks are done.
"""
Thomas De Schampheleire
controllers: forward pullrequests.comment to changeset...
r7353 assert request.environ.get('HTTP_X_PARTIAL_XHR')
if pull_request:
pull_request_id = pull_request.pull_request_id
else:
pull_request_id = None
status = request.POST.get('changeset_status')
close_pr = request.POST.get('save_close')
delete = request.POST.get('save_delete')
f_path = request.POST.get('f_path')
line_no = request.POST.get('line')
if (status or close_pr or delete) and (f_path or line_no):
# status votes and closing is only possible in general comments
raise HTTPBadRequest()
if not allowed_to_change_status:
if status or close_pr:
h.flash(_('No permission to change status'), 'error')
raise HTTPForbidden()
if pull_request and delete == "delete":
if (pull_request.owner_id == request.authuser.user_id or
h.HasPermissionAny('hg.admin')() or
h.HasRepoPermissionLevel('admin')(pull_request.org_repo.repo_name) or
h.HasRepoPermissionLevel('admin')(pull_request.other_repo.repo_name)
Mads Kiilerich
flake8: fix E125 continuation line with same indent as next logical line
r7733 ) and not pull_request.is_closed():
Thomas De Schampheleire
controllers: forward pullrequests.comment to changeset...
r7353 PullRequestModel().delete(pull_request)
Session().commit()
h.flash(_('Successfully deleted pull request %s') % pull_request_id,
category='success')
return {
Mads Kiilerich
pull-request: fix missing imports for delete and close...
r7518 'location': h.url('my_pullrequests'), # or repo pr list?
Thomas De Schampheleire
controllers: forward pullrequests.comment to changeset...
r7353 }
Mads Kiilerich
pull-request: fix missing imports for delete and close...
r7518 raise HTTPFound(location=h.url('my_pullrequests')) # or repo pr list?
Thomas De Schampheleire
controllers: forward pullrequests.comment to changeset...
r7353 raise HTTPForbidden()
text = request.POST.get('text', '').strip()
Thomas De Schampheleire
controllers: inline changeset.create_comment...
r7354 comment = ChangesetCommentsModel().create(
text=text,
repo=c.db_repo.repo_id,
author=request.authuser.user_id,
Thomas De Schampheleire
controllers: forward pullrequests.comment to changeset...
r7353 revision=revision,
Thomas De Schampheleire
controllers: inline changeset.create_comment...
r7354 pull_request=pull_request_id,
f_path=f_path or None,
line_no=line_no or None,
status_change=ChangesetStatus.get_status_lbl(status) if status else None,
Thomas De Schampheleire
controllers: forward pullrequests.comment to changeset...
r7353 closing_pr=close_pr,
)
if status:
ChangesetStatusModel().set_status(
c.db_repo.repo_id,
status,
request.authuser.user_id,
comment,
revision=revision,
pull_request=pull_request_id,
)
if pull_request:
action = 'user_commented_pull_request:%s' % pull_request_id
else:
action = 'user_commented_revision:%s' % revision
action_logger(request.authuser, action, c.db_repo, request.ip_addr)
if pull_request and close_pr:
PullRequestModel().close_pull_request(pull_request_id)
action_logger(request.authuser,
'user_closed_pull_request:%s' % pull_request_id,
c.db_repo, request.ip_addr)
Session().commit()
data = {
Mads Kiilerich
py3: remove safe_unicode in places where it no longer is needed because all strings (except bytes) already *are* unicode strings...
r8075 'target_id': h.safeid(request.POST.get('f_path')),
Thomas De Schampheleire
controllers: forward pullrequests.comment to changeset...
r7353 }
if comment is not None:
c.comment = comment
data.update(comment.get_dict())
data.update({'rendered_text':
render('changeset/changeset_comment_block.html')})
return data
Thomas De Schampheleire
controllers: remove pr_comment flag in delete_cs_pr_comment...
r7355 def delete_cs_pr_comment(repo_name, comment_id):
Thomas De Schampheleire
controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
r7356 """Delete a comment from a changeset or pull request"""
Thomas De Schampheleire
controllers: forward pullrequests.delete_comment to changeset...
r7346 co = ChangesetComment.get_or_404(comment_id)
if co.repo.repo_name != repo_name:
raise HTTPNotFound()
Thomas De Schampheleire
controllers: remove pr_comment flag in delete_cs_pr_comment...
r7355 if co.pull_request and co.pull_request.is_closed():
Thomas De Schampheleire
controllers: forward pullrequests.delete_comment to changeset...
r7346 # don't allow deleting comments on closed pull request
raise HTTPForbidden()
owner = co.author_id == request.authuser.user_id
repo_admin = h.HasRepoPermissionLevel('admin')(repo_name)
if h.HasPermissionAny('hg.admin')() or repo_admin or owner:
ChangesetCommentsModel().delete(comment=co)
Session().commit()
return True
else:
raise HTTPForbidden()
Mads Kiilerich
comments: extract common comment creation functionality for changesets and pullrequests...
r5646
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 class ChangesetController(BaseRepoController):
Thomas De Schampheleire
controllers: rename __before__ to _before in preparation of TurboGears2...
r6513 def _before(self, *args, **kwargs):
super(ChangesetController, self)._before(*args, **kwargs)
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 c.affected_files_cut_off = 60
def _index(self, revision, method):
Mads Kiilerich
comments: use inline comment infrastructure for general comments too
r5647 c.pull_request = None
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 c.anchor_url = anchor_url
c.ignorews_url = _ignorews_url
c.context_url = _context_url
Mads Kiilerich
diffs: cleanup of variable naming around cut_off_limit...
r6831 c.fulldiff = request.GET.get('fulldiff') # for reporting number of changed files
Lars Kruse
codingstyle: trivial whitespace fixes...
r6789 # get ranges of revisions if preset
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 rev_range = revision.split('...')[:2]
enable_comments = True
Mads Kiilerich
compare: introduce .cs_repo as the repo for .cs_changes - sometimes it is org, sometimes other...
r4368 c.cs_repo = c.db_repo
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 try:
if len(rev_range) == 2:
enable_comments = False
rev_start = rev_range[0]
rev_end = rev_range[1]
Bradley M. Kuhn
Rename rhodecode_repo to db_repo_scm_instance
r4196 rev_ranges = c.db_repo_scm_instance.get_changesets(start=rev_start,
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 end=rev_end)
else:
Bradley M. Kuhn
Rename rhodecode_repo to db_repo_scm_instance
r4196 rev_ranges = [c.db_repo_scm_instance.get_changeset(revision)]
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
c.cs_ranges = list(rev_ranges)
if not c.cs_ranges:
raise RepositoryError('Changeset range returned empty result')
Mads Kiilerich
changeset: don't crash with unhandled EmptyRepositoryError when visiting (non-existing) changeset in an empty repo
r6004 except (ChangesetDoesNotExistError, EmptyRepositoryError):
Thomas De Schampheleire
changeset: reduce log level of stack trace on innocent exceptions...
r5186 log.debug(traceback.format_exc())
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 msg = _('Such revision does not exist for this repository')
h.flash(msg, category='error')
raise HTTPNotFound()
c.changes = OrderedDict()
c.lines_added = 0 # count of lines added
c.lines_deleted = 0 # count of lines removes
c.changeset_statuses = ChangesetStatus.STATUSES
Mads Kiilerich
changesets: simplify calculation of PR comments on changesets
r4330 comments = dict()
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 c.statuses = []
c.inline_comments = []
c.inline_cnt = 0
# Iterate over ranges (default changeset view is always one changeset)
for changeset in c.cs_ranges:
if method == 'show':
c.statuses.extend([ChangesetStatusModel().get_status(
Bradley M. Kuhn
Rename rhodecode_db_repo to db_repo - it stores db repo abstractions
r4195 c.db_repo.repo_id, changeset.raw_id)])
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
Mads Kiilerich
changesets: simplify calculation of PR comments on changesets
r4330 # Changeset comments
comments.update((com.comment_id, com)
for com in ChangesetCommentsModel()
.get_comments(c.db_repo.repo_id,
revision=changeset.raw_id))
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
Mads Kiilerich
changesets: simplify calculation of PR comments on changesets
r4330 # Status change comments - mostly from pull requests
Søren Løvborg
db: rename ChangesetStatus.changeset_comment_id to comment_id...
r6282 comments.update((st.comment_id, st.comment)
Mads Kiilerich
changesets: simplify calculation of PR comments on changesets
r4330 for st in ChangesetStatusModel()
.get_statuses(c.db_repo.repo_id,
Mads Kiilerich
changeset: make code more stable against unexpected comments...
r5278 changeset.raw_id, with_revisions=True)
Søren Løvborg
db: rename ChangesetStatus.changeset_comment_id to comment_id...
r6282 if st.comment_id is not None)
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
Mads Kiilerich
cleanup: consistent space before line continuation backslash
r5585 inlines = ChangesetCommentsModel() \
Bradley M. Kuhn
Rename rhodecode_db_repo to db_repo - it stores db repo abstractions
r4195 .get_inline_comments(c.db_repo.repo_id,
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 revision=changeset.raw_id)
c.inline_comments.extend(inlines)
cs2 = changeset.raw_id
cs1 = changeset.parents[0].raw_id if changeset.parents else EmptyChangeset().raw_id
context_lcl = get_line_ctx('', request.GET)
Jiří Suchan
changeset: drop unused variables
r5567 ign_whitespace_lcl = get_ignore_ws('', request.GET)
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
Mads Kiilerich
diffs: wrap vcs repo get_diff...
r6863 raw_diff = diffs.get_diff(c.db_repo_scm_instance, cs1, cs2,
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 ignore_whitespace=ign_whitespace_lcl, context=context_lcl)
Mads Kiilerich
diffs: cleanup of variable naming around cut_off_limit...
r6831 diff_limit = None if c.fulldiff else self.cut_off_limit
Mads Kiilerich
diff: use list instead of OrderedDict - keep it simple
r6266 file_diff_data = []
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 if method == 'show':
Mads Kiilerich
diffs: drop the noop as_raw method - just use the raw diff directly and with proper variable naming
r6834 diff_processor = diffs.DiffProcessor(raw_diff,
vcs=c.db_repo_scm_instance.alias,
diff_limit=diff_limit)
Mads Kiilerich
diffs: drop the DiffLimitExceeded container - just make it a flag available as property...
r6839 c.limited_diff = diff_processor.limited_diff
Mads Kiilerich
diffs: inline prepare() into __init__ and make the result available as .parsed...
r6838 for f in diff_processor.parsed:
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 st = f['stats']
c.lines_added += st['added']
c.lines_deleted += st['deleted']
Mads Kiilerich
diff: minor cleanups...
r6155 filename = f['filename']
fid = h.FID(changeset.raw_id, filename)
Mads Kiilerich
diff: rework data structure used by diff_block.diff_block (used for changeset diffs)...
r6156 url_fid = h.FID('', filename)
Mads Kiilerich
diffs: move as_html and _safe_id from method to a pure function - avoid calling the method as function...
r6841 html_diff = diffs.as_html(enable_comments=enable_comments, parsed_lines=[f])
file_diff_data.append((fid, url_fid, f['operation'], f['old_filename'], filename, html_diff, st))
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 else:
# downloads/raw we only need RAW diff nothing else
Mads Kiilerich
diffs: drop the noop as_raw method - just use the raw diff directly and with proper variable naming
r6834 file_diff_data.append(('', None, None, None, raw_diff, None))
Mads Kiilerich
diff: rework data structure used by diff_block.diff_block (used for changeset diffs)...
r6156 c.changes[changeset.raw_id] = (cs1, cs2, file_diff_data)
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
Lars Kruse
codingstyle: trivial whitespace fixes...
r6789 # sort comments in creation order
Mads Kiilerich
changesets: simplify calculation of PR comments on changesets
r4330 c.comments = [com for com_id, com in sorted(comments.items())]
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
# count inline comments
for __, lines in c.inline_comments:
for comments in lines.values():
c.inline_cnt += len(comments)
if len(c.cs_ranges) == 1:
c.changeset = c.cs_ranges[0]
c.parent_tmpl = ''.join(['# Parent %s\n' % x.raw_id
for x in c.changeset.parents])
Mads Kiilerich
py3: add missing ascii_str for display of hg changeset graft/transplant source revision
r7995 c.changeset_graft_source_hash = ascii_str(c.changeset.extra.get(b'source', b''))
c.changeset_transplant_source_hash = ascii_str(binascii.hexlify(c.changeset.extra.get(b'transplant_source', b'')))
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 if method == 'download':
response.content_type = 'text/plain'
response.content_disposition = 'attachment; filename=%s.diff' \
% revision[:12]
Mads Kiilerich
diffs: drop the noop as_raw method - just use the raw diff directly and with proper variable naming
r6834 return raw_diff
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 elif method == 'patch':
response.content_type = 'text/plain'
Mads Kiilerich
py3: rename all existing safe_unicode to safe_str
r8078 c.diff = safe_str(raw_diff)
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 return render('changeset/patch_changeset.html')
elif method == 'raw':
response.content_type = 'text/plain'
Mads Kiilerich
diffs: drop the noop as_raw method - just use the raw diff directly and with proper variable naming
r6834 return raw_diff
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 elif method == 'show':
if len(c.cs_ranges) == 1:
return render('changeset/changeset.html')
else:
Mads Kiilerich
compare: show how many changesets the compared repo is behind
r4297 c.cs_ranges_org = None
Mads Kiilerich
pull requests: show changeset comment and status flags in the changelog for PRs
r4367 c.cs_comments = {}
Mads Kiilerich
pull requests: show graph when displaying PR
r4352 revs = [ctx.revision for ctx in reversed(c.cs_ranges)]
Søren Løvborg
templates: properly escape inline JavaScript values...
r6492 c.jsdata = graph_data(c.db_repo_scm_instance, revs)
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 return render('changeset/changeset_range.html')
Mads Kiilerich
auth: restore anonymous repository access...
r7038 @LoginRequired(allow_default_user=True)
Søren Løvborg
auth: simplify repository permission checks...
r6471 @HasRepoPermissionLevelDecorator('read')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 def index(self, revision, method='show'):
return self._index(revision, method=method)
Mads Kiilerich
auth: restore anonymous repository access...
r7038 @LoginRequired(allow_default_user=True)
Søren Løvborg
auth: simplify repository permission checks...
r6471 @HasRepoPermissionLevelDecorator('read')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 def changeset_raw(self, revision):
return self._index(revision, method='raw')
Mads Kiilerich
auth: restore anonymous repository access...
r7038 @LoginRequired(allow_default_user=True)
Søren Løvborg
auth: simplify repository permission checks...
r6471 @HasRepoPermissionLevelDecorator('read')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 def changeset_patch(self, revision):
return self._index(revision, method='patch')
Mads Kiilerich
auth: restore anonymous repository access...
r7038 @LoginRequired(allow_default_user=True)
Søren Løvborg
auth: simplify repository permission checks...
r6471 @HasRepoPermissionLevelDecorator('read')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 def changeset_download(self, revision):
return self._index(revision, method='download')
@LoginRequired()
Søren Løvborg
auth: simplify repository permission checks...
r6471 @HasRepoPermissionLevelDecorator('read')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 @jsonify
def comment(self, repo_name, revision):
Thomas De Schampheleire
controllers: forward pullrequests.comment to changeset...
r7353 return create_cs_pr_comment(repo_name, revision=revision)
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
@LoginRequired()
Søren Løvborg
auth: simplify repository permission checks...
r6471 @HasRepoPermissionLevelDecorator('read')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 @jsonify
Thomas De Schampheleire
controllers: forward pullrequests.delete_comment to changeset...
r7346 def delete_comment(self, repo_name, comment_id):
Thomas De Schampheleire
controllers: remove pr_comment flag in delete_cs_pr_comment...
r7355 return delete_cs_pr_comment(repo_name, comment_id)
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187
Mads Kiilerich
auth: restore anonymous repository access...
r7038 @LoginRequired(allow_default_user=True)
Søren Løvborg
auth: simplify repository permission checks...
r6471 @HasRepoPermissionLevelDecorator('read')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 @jsonify
def changeset_info(self, repo_name, revision):
if request.is_xhr:
try:
Bradley M. Kuhn
Rename rhodecode_repo to db_repo_scm_instance
r4196 return c.db_repo_scm_instance.get_changeset(revision)
Mads Kiilerich
cleanup: consistently use 'except ... as ...:'...
r5374 except ChangesetDoesNotExistError as e:
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 return EmptyChangeset(message=str(e))
else:
raise HTTPBadRequest()
Mads Kiilerich
auth: restore anonymous repository access...
r7038 @LoginRequired(allow_default_user=True)
Søren Løvborg
auth: simplify repository permission checks...
r6471 @HasRepoPermissionLevelDecorator('read')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 @jsonify
def changeset_children(self, repo_name, revision):
if request.is_xhr:
Bradley M. Kuhn
Rename rhodecode_repo to db_repo_scm_instance
r4196 changeset = c.db_repo_scm_instance.get_changeset(revision)
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 result = {"results": []}
if changeset.children:
result = {"results": changeset.children}
return result
else:
raise HTTPBadRequest()
Mads Kiilerich
auth: restore anonymous repository access...
r7038 @LoginRequired(allow_default_user=True)
Søren Løvborg
auth: simplify repository permission checks...
r6471 @HasRepoPermissionLevelDecorator('read')
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 @jsonify
def changeset_parents(self, repo_name, revision):
if request.is_xhr:
Bradley M. Kuhn
Rename rhodecode_repo to db_repo_scm_instance
r4196 changeset = c.db_repo_scm_instance.get_changeset(revision)
Bradley M. Kuhn
Second step in two-part process to rename directories....
r4187 result = {"results": []}
if changeset.parents:
result = {"results": changeset.parents}
return result
else:
raise HTTPBadRequest()