annotate kallithea/controllers/changeset.py @ 8687:5e46f73f0d1c

model: always import the whole db module - drop "from" imports
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 12 Oct 2020 11:12:37 +0200
parents b095e2fbba44
children 410934dd09f4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
1 # -*- coding: utf-8 -*-
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
2 # This program is free software: you can redistribute it and/or modify
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
3 # it under the terms of the GNU General Public License as published by
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
4 # the Free Software Foundation, either version 3 of the License, or
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
5 # (at your option) any later version.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1131
diff changeset
6 #
252
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
7 # This program is distributed in the hope that it will be useful,
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
10 # GNU General Public License for more details.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1131
diff changeset
11 #
252
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
12 # You should have received a copy of the GNU General Public License
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
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: 4077
diff changeset
14 """
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
15 kallithea.controllers.changeset
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
17
6215
5eec79420ce3 Turbogears2 migration: remove some references to Pylons in comments
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 6195
diff changeset
18 changeset controller showing changes between revisions
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
19
4211
1948ede028ef RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4208
diff changeset
20 This file was forked by the Kallithea project in July 2014.
1948ede028ef RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4208
diff changeset
21 Original author and date, and relevant copyright and licensing information is below:
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
22 :created_on: Apr 25, 2010
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
23 :author: marcink
4211
1948ede028ef RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4208
diff changeset
24 :copyright: (c) 2013 RhodeCode GmbH, and others.
4208
ad38f9f93b3b Correct licensing information in individual files.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4197
diff changeset
25 :license: GPLv3, see LICENSE.md for more details.
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
26 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
27
8002
42d1f33f2b87 changeset: store hexified source hash in context so it is readily available in template
Mads Kiilerich <mads@kiilerich.com>
parents: 7826
diff changeset
28 import binascii
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
29 import logging
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
30 import traceback
8582
35af0bd45bf3 diff: drop per file ignore-whitespace and context - it didn't work and had conceptual issue (Issue #344)
Mads Kiilerich <mads@kiilerich.com>
parents: 8581
diff changeset
31 from collections import OrderedDict
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
32
7811
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
33 from tg import request, response
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
34 from tg import tmpl_context as c
6553
e9ac5698281d tg: minimize future diff by some mocking and replacing some pylons imports with tg
Mads Kiilerich <mads@kiilerich.com>
parents: 6532
diff changeset
35 from tg.i18n import ugettext as _
8238
27c4ad3e584f cleanup: trivial fixes for some pyflakes warnings
Mads Kiilerich <mads@kiilerich.com>
parents: 8229
diff changeset
36 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPNotFound
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
37
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
38 import kallithea.lib.helpers as h
7811
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
39 from kallithea.lib import diffs
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
40 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
41 from kallithea.lib.base import BaseRepoController, jsonify, render
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
42 from kallithea.lib.graphmod import graph_data
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
43 from kallithea.lib.utils import action_logger
8198
08eec03c9485 py3: rename all existing safe_unicode to safe_str
Mads Kiilerich <mads@kiilerich.com>
parents: 8195
diff changeset
44 from kallithea.lib.utils2 import ascii_str, safe_str
7811
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
45 from kallithea.lib.vcs.backends.base import EmptyChangeset
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
46 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError
8687
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8686
diff changeset
47 from kallithea.model import db, meta
7811
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
48 from kallithea.model.changeset_status import ChangesetStatusModel
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
49 from kallithea.model.comment import ChangesetCommentsModel
7609
56233b874eba pull-request: fix missing imports for delete and close
Mads Kiilerich <mads@kiilerich.com>
parents: 7468
diff changeset
50 from kallithea.model.pull_request import PullRequestModel
7811
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7789
diff changeset
51
193
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
52
103
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 log = logging.getLogger(__name__)
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54
1212
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
55
7432
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
56 def create_cs_pr_comment(repo_name, revision=None, pull_request=None, allowed_to_change_status=True):
7435
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
57 """
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
58 Add a comment to the specified changeset or pull request, using POST values
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
59 from the request.
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
60
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
61 Comments can be inline (when a file path and line number is specified in
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
62 POST) or general comments.
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
63 A comment can be accompanied by a review status change (accepted, rejected,
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
64 etc.). Pull requests can be closed or deleted.
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
65
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
66 Parameter 'allowed_to_change_status' is used for both status changes and
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
67 closing of pull requests. For deleting of pull requests, more specific
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
68 checks are done.
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
69 """
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
70
7432
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
71 assert request.environ.get('HTTP_X_PARTIAL_XHR')
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
72 if pull_request:
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
73 pull_request_id = pull_request.pull_request_id
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
74 else:
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
75 pull_request_id = None
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
76
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
77 status = request.POST.get('changeset_status')
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
78 close_pr = request.POST.get('save_close')
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
79 delete = request.POST.get('save_delete')
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
80 f_path = request.POST.get('f_path')
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
81 line_no = request.POST.get('line')
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
82
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
83 if (status or close_pr or delete) and (f_path or line_no):
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
84 # status votes and closing is only possible in general comments
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
85 raise HTTPBadRequest()
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
86
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
87 if not allowed_to_change_status:
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
88 if status or close_pr:
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
89 h.flash(_('No permission to change status'), 'error')
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
90 raise HTTPForbidden()
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
91
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
92 if pull_request and delete == "delete":
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
93 if (pull_request.owner_id == request.authuser.user_id or
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
94 h.HasPermissionAny('hg.admin')() or
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
95 h.HasRepoPermissionLevel('admin')(pull_request.org_repo.repo_name) or
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
96 h.HasRepoPermissionLevel('admin')(pull_request.other_repo.repo_name)
7826
f73a1103ccdc flake8: fix E125 continuation line with same indent as next logical line
Mads Kiilerich <mads@kiilerich.com>
parents: 7812
diff changeset
97 ) and not pull_request.is_closed():
7432
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
98 PullRequestModel().delete(pull_request)
8686
b095e2fbba44 model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents: 8582
diff changeset
99 meta.Session().commit()
7432
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
100 h.flash(_('Successfully deleted pull request %s') % pull_request_id,
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
101 category='success')
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
102 return {
7609
56233b874eba pull-request: fix missing imports for delete and close
Mads Kiilerich <mads@kiilerich.com>
parents: 7468
diff changeset
103 'location': h.url('my_pullrequests'), # or repo pr list?
7432
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
104 }
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
105 raise HTTPForbidden()
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
106
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
107 text = request.POST.get('text', '').strip()
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
108
7433
68f2eb1bec8c controllers: inline changeset.create_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7432
diff changeset
109 comment = ChangesetCommentsModel().create(
68f2eb1bec8c controllers: inline changeset.create_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7432
diff changeset
110 text=text,
68f2eb1bec8c controllers: inline changeset.create_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7432
diff changeset
111 repo=c.db_repo.repo_id,
68f2eb1bec8c controllers: inline changeset.create_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7432
diff changeset
112 author=request.authuser.user_id,
7432
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
113 revision=revision,
7433
68f2eb1bec8c controllers: inline changeset.create_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7432
diff changeset
114 pull_request=pull_request_id,
68f2eb1bec8c controllers: inline changeset.create_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7432
diff changeset
115 f_path=f_path or None,
68f2eb1bec8c controllers: inline changeset.create_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7432
diff changeset
116 line_no=line_no or None,
8687
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8686
diff changeset
117 status_change=db.ChangesetStatus.get_status_lbl(status) if status else None,
7432
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
118 closing_pr=close_pr,
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
119 )
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
120
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
121 if status:
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
122 ChangesetStatusModel().set_status(
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
123 c.db_repo.repo_id,
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
124 status,
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
125 request.authuser.user_id,
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
126 comment,
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
127 revision=revision,
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
128 pull_request=pull_request_id,
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
129 )
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
130
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
131 if pull_request:
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
132 action = 'user_commented_pull_request:%s' % pull_request_id
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
133 else:
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
134 action = 'user_commented_revision:%s' % revision
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
135 action_logger(request.authuser, action, c.db_repo, request.ip_addr)
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
136
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
137 if pull_request and close_pr:
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
138 PullRequestModel().close_pull_request(pull_request_id)
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
139 action_logger(request.authuser,
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
140 'user_closed_pull_request:%s' % pull_request_id,
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
141 c.db_repo, request.ip_addr)
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
142
8686
b095e2fbba44 model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents: 8582
diff changeset
143 meta.Session().commit()
7432
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
144
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
145 data = {
8195
e35373106528 py3: remove safe_unicode in places where it no longer is needed because all strings (except bytes) already *are* unicode strings
Mads Kiilerich <mads@kiilerich.com>
parents: 8128
diff changeset
146 'target_id': h.safeid(request.POST.get('f_path')),
7432
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
147 }
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
148 if comment is not None:
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
149 c.comment = comment
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
150 data.update(comment.get_dict())
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
151 data.update({'rendered_text':
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
152 render('changeset/changeset_comment_block.html')})
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
153
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
154 return data
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
155
7434
901a5f2f3530 controllers: remove pr_comment flag in delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7433
diff changeset
156 def delete_cs_pr_comment(repo_name, comment_id):
7435
2c54a82aeaed controllers: add docstring to create_cs_pr_comment and delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7434
diff changeset
157 """Delete a comment from a changeset or pull request"""
8687
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8686
diff changeset
158 co = db.ChangesetComment.get_or_404(comment_id)
7425
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
159 if co.repo.repo_name != repo_name:
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
160 raise HTTPNotFound()
7434
901a5f2f3530 controllers: remove pr_comment flag in delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7433
diff changeset
161 if co.pull_request and co.pull_request.is_closed():
7425
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
162 # don't allow deleting comments on closed pull request
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
163 raise HTTPForbidden()
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
164
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
165 owner = co.author_id == request.authuser.user_id
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
166 repo_admin = h.HasRepoPermissionLevel('admin')(repo_name)
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
167 if h.HasPermissionAny('hg.admin')() or repo_admin or owner:
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
168 ChangesetCommentsModel().delete(comment=co)
8686
b095e2fbba44 model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents: 8582
diff changeset
169 meta.Session().commit()
7425
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
170 return True
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
171 else:
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
172 raise HTTPForbidden()
5666
b3ddd87f214f comments: extract common comment creation functionality for changesets and pullrequests
Mads Kiilerich <madski@unity3d.com>
parents: 5664
diff changeset
173
1045
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1038
diff changeset
174 class ChangesetController(BaseRepoController):
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
175
6558
4517e212f09a controllers: rename __before__ to _before in preparation of TurboGears2
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 6553
diff changeset
176 def _before(self, *args, **kwargs):
4517e212f09a controllers: rename __before__ to _before in preparation of TurboGears2
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 6553
diff changeset
177 super(ChangesetController, self)._before(*args, **kwargs)
1130
1cecc7db3106 fixed some limits in changesets and changelogs
Marcin Kuzminski <marcin@python-works.com>
parents: 1125
diff changeset
178 c.affected_files_cut_off = 60
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
179
3750
244f184f5fc3 moved around some code in changeset controllers to properly log which function was decorated.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
180 def _index(self, revision, method):
5667
7834f845505a comments: use inline comment infrastructure for general comments too
Mads Kiilerich <madski@unity3d.com>
parents: 5666
diff changeset
181 c.pull_request = None
6906
b343a4599178 diffs: cleanup of variable naming around cut_off_limit
Mads Kiilerich <mads@kiilerich.com>
parents: 6864
diff changeset
182 c.fulldiff = request.GET.get('fulldiff') # for reporting number of changed files
6864
7691290837d2 codingstyle: trivial whitespace fixes
Lars Kruse <devel@sumpfralle.de>
parents: 6558
diff changeset
183 # get ranges of revisions if preset
977
28524453bb76 started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
184 rev_range = revision.split('...')[:2]
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
185 enable_comments = True
4368
3136811db1af compare: introduce .cs_repo as the repo for .cs_changes - sometimes it is org, sometimes other
Mads Kiilerich <madski@unity3d.com>
parents: 4367
diff changeset
186 c.cs_repo = c.db_repo
543
a99e23e6c1e8 fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents: 512
diff changeset
187 try:
977
28524453bb76 started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
188 if len(rev_range) == 2:
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
189 enable_comments = False
977
28524453bb76 started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
190 rev_start = rev_range[0]
28524453bb76 started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
191 rev_end = rev_range[1]
4196
06e49be38d78 Rename rhodecode_repo to db_repo_scm_instance
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4195
diff changeset
192 rev_ranges = c.db_repo_scm_instance.get_changesets(start=rev_start,
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 2996
diff changeset
193 end=rev_end)
977
28524453bb76 started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
194 else:
4196
06e49be38d78 Rename rhodecode_repo to db_repo_scm_instance
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4195
diff changeset
195 rev_ranges = [c.db_repo_scm_instance.get_changeset(revision)]
983
57a2b792a3a1 fixed error for single changeset
Marcin Kuzminski <marcin@python-works.com>
parents: 978
diff changeset
196
57a2b792a3a1 fixed error for single changeset
Marcin Kuzminski <marcin@python-works.com>
parents: 978
diff changeset
197 c.cs_ranges = list(rev_ranges)
1656
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
198 if not c.cs_ranges:
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
199 raise RepositoryError('Changeset range returned empty result')
983
57a2b792a3a1 fixed error for single changeset
Marcin Kuzminski <marcin@python-works.com>
parents: 978
diff changeset
200
6041
0bac887ea148 changeset: don't crash with unhandled EmptyRepositoryError when visiting (non-existing) changeset in an empty repo
Mads Kiilerich <madski@unity3d.com>
parents: 5815
diff changeset
201 except (ChangesetDoesNotExistError, EmptyRepositoryError):
5186
5fb4e6f884ce changeset: reduce log level of stack trace on innocent exceptions
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5148
diff changeset
202 log.debug(traceback.format_exc())
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
203 msg = _('Such revision does not exist for this repository')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
204 h.flash(msg, category='error')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
205 raise HTTPNotFound()
977
28524453bb76 started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
206
28524453bb76 started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
207 c.changes = OrderedDict()
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
208
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
209 c.lines_added = 0 # count of lines added
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
210 c.lines_deleted = 0 # count of lines removes
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
211
8687
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8686
diff changeset
212 c.changeset_statuses = db.ChangesetStatus.STATUSES
4330
773980a93cdd changesets: simplify calculation of PR comments on changesets
Mads Kiilerich <madski@unity3d.com>
parents: 4301
diff changeset
213 comments = dict()
2215
2c2bdaeca912 code-review initial
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
214 c.statuses = []
1677
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
215 c.inline_comments = []
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
216 c.inline_cnt = 0
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
217
1274
7a0004efde12 Added extra check for very large diffs in changesets, sometimes for very large diffs the diff parser could kill CPU.
Marcin Kuzminski <marcin@python-works.com>
parents: 1259
diff changeset
218 # Iterate over ranges (default changeset view is always one changeset)
977
28524453bb76 started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
219 for changeset in c.cs_ranges:
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
220 if method == 'show':
3176
7ec5f9c1df45 show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3141
diff changeset
221 c.statuses.extend([ChangesetStatusModel().get_status(
4195
9581233e9275 Rename rhodecode_db_repo to db_repo - it stores db repo abstractions
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4187
diff changeset
222 c.db_repo.repo_id, changeset.raw_id)])
2215
2c2bdaeca912 code-review initial
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
223
4330
773980a93cdd changesets: simplify calculation of PR comments on changesets
Mads Kiilerich <madski@unity3d.com>
parents: 4301
diff changeset
224 # Changeset comments
773980a93cdd changesets: simplify calculation of PR comments on changesets
Mads Kiilerich <madski@unity3d.com>
parents: 4301
diff changeset
225 comments.update((com.comment_id, com)
773980a93cdd changesets: simplify calculation of PR comments on changesets
Mads Kiilerich <madski@unity3d.com>
parents: 4301
diff changeset
226 for com in ChangesetCommentsModel()
773980a93cdd changesets: simplify calculation of PR comments on changesets
Mads Kiilerich <madski@unity3d.com>
parents: 4301
diff changeset
227 .get_comments(c.db_repo.repo_id,
773980a93cdd changesets: simplify calculation of PR comments on changesets
Mads Kiilerich <madski@unity3d.com>
parents: 4301
diff changeset
228 revision=changeset.raw_id))
3176
7ec5f9c1df45 show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3141
diff changeset
229
4330
773980a93cdd changesets: simplify calculation of PR comments on changesets
Mads Kiilerich <madski@unity3d.com>
parents: 4301
diff changeset
230 # Status change comments - mostly from pull requests
6319
f4059fe16118 db: rename ChangesetStatus.changeset_comment_id to comment_id
Søren Løvborg <sorenl@unity3d.com>
parents: 6303
diff changeset
231 comments.update((st.comment_id, st.comment)
4330
773980a93cdd changesets: simplify calculation of PR comments on changesets
Mads Kiilerich <madski@unity3d.com>
parents: 4301
diff changeset
232 for st in ChangesetStatusModel()
773980a93cdd changesets: simplify calculation of PR comments on changesets
Mads Kiilerich <madski@unity3d.com>
parents: 4301
diff changeset
233 .get_statuses(c.db_repo.repo_id,
5278
1ae14a2ceba0 changeset: make code more stable against unexpected comments
Mads Kiilerich <madski@unity3d.com>
parents: 5186
diff changeset
234 changeset.raw_id, with_revisions=True)
6319
f4059fe16118 db: rename ChangesetStatus.changeset_comment_id to comment_id
Søren Løvborg <sorenl@unity3d.com>
parents: 6303
diff changeset
235 if st.comment_id is not None)
3176
7ec5f9c1df45 show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3141
diff changeset
236
5598
edb24bc0f71a cleanup: consistent space before line continuation backslash
Mads Kiilerich <madski@unity3d.com>
parents: 5571
diff changeset
237 inlines = ChangesetCommentsModel() \
4195
9581233e9275 Rename rhodecode_db_repo to db_repo - it stores db repo abstractions
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4187
diff changeset
238 .get_inline_comments(c.db_repo.repo_id,
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
239 revision=changeset.raw_id)
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
240 c.inline_comments.extend(inlines)
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
241
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
242 cs2 = changeset.raw_id
4044
af733fa965b0 fixed diffs vs Empty changeset
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
243 cs1 = changeset.parents[0].raw_id if changeset.parents else EmptyChangeset().raw_id
8582
35af0bd45bf3 diff: drop per file ignore-whitespace and context - it didn't work and had conceptual issue (Issue #344)
Mads Kiilerich <mads@kiilerich.com>
parents: 8581
diff changeset
244 ignore_whitespace_diff = h.get_ignore_whitespace_diff(request.GET)
35af0bd45bf3 diff: drop per file ignore-whitespace and context - it didn't work and had conceptual issue (Issue #344)
Mads Kiilerich <mads@kiilerich.com>
parents: 8581
diff changeset
245 diff_context_size = h.get_diff_context_size(request.GET)
6938
6fde53180c50 diffs: wrap vcs repo get_diff
Mads Kiilerich <mads@kiilerich.com>
parents: 6916
diff changeset
246 raw_diff = diffs.get_diff(c.db_repo_scm_instance, cs1, cs2,
8581
5463f4b13fc3 diff: name context size and whitespace ignore flag variable names consistently
Mads Kiilerich <mads@kiilerich.com>
parents: 8580
diff changeset
247 ignore_whitespace=ignore_whitespace_diff, context=diff_context_size)
6906
b343a4599178 diffs: cleanup of variable naming around cut_off_limit
Mads Kiilerich <mads@kiilerich.com>
parents: 6864
diff changeset
248 diff_limit = None if c.fulldiff else self.cut_off_limit
6303
1cf51cd05e36 diff: use list instead of OrderedDict - keep it simple
Mads Kiilerich <madski@unity3d.com>
parents: 6234
diff changeset
249 file_diff_data = []
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
250 if method == 'show':
6909
54199f3aab93 diffs: drop the noop as_raw method - just use the raw diff directly and with proper variable naming
Mads Kiilerich <mads@kiilerich.com>
parents: 6908
diff changeset
251 diff_processor = diffs.DiffProcessor(raw_diff,
54199f3aab93 diffs: drop the noop as_raw method - just use the raw diff directly and with proper variable naming
Mads Kiilerich <mads@kiilerich.com>
parents: 6908
diff changeset
252 vcs=c.db_repo_scm_instance.alias,
54199f3aab93 diffs: drop the noop as_raw method - just use the raw diff directly and with proper variable naming
Mads Kiilerich <mads@kiilerich.com>
parents: 6908
diff changeset
253 diff_limit=diff_limit)
6914
e85f08375dc6 diffs: drop the DiffLimitExceeded container - just make it a flag available as property
Mads Kiilerich <mads@kiilerich.com>
parents: 6913
diff changeset
254 c.limited_diff = diff_processor.limited_diff
6913
24a9bec8138c diffs: inline prepare() into __init__ and make the result available as .parsed
Mads Kiilerich <mads@kiilerich.com>
parents: 6909
diff changeset
255 for f in diff_processor.parsed:
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
256 st = f['stats']
3821
ce4b7023a492 diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3750
diff changeset
257 c.lines_added += st['added']
ce4b7023a492 diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents: 3750
diff changeset
258 c.lines_deleted += st['deleted']
6192
72acb38da217 diff: minor cleanups
Mads Kiilerich <madski@unity3d.com>
parents: 6041
diff changeset
259 filename = f['filename']
72acb38da217 diff: minor cleanups
Mads Kiilerich <madski@unity3d.com>
parents: 6041
diff changeset
260 fid = h.FID(changeset.raw_id, filename)
6193
dc4cb1d4e084 diff: rework data structure used by diff_block.diff_block (used for changeset diffs)
Mads Kiilerich <madski@unity3d.com>
parents: 6192
diff changeset
261 url_fid = h.FID('', filename)
6916
182570502b6a diffs: move as_html and _safe_id from method to a pure function - avoid calling the method as function
Mads Kiilerich <mads@kiilerich.com>
parents: 6914
diff changeset
262 html_diff = diffs.as_html(enable_comments=enable_comments, parsed_lines=[f])
182570502b6a diffs: move as_html and _safe_id from method to a pure function - avoid calling the method as function
Mads Kiilerich <mads@kiilerich.com>
parents: 6914
diff changeset
263 file_diff_data.append((fid, url_fid, f['operation'], f['old_filename'], filename, html_diff, st))
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
264 else:
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
265 # downloads/raw we only need RAW diff nothing else
6909
54199f3aab93 diffs: drop the noop as_raw method - just use the raw diff directly and with proper variable naming
Mads Kiilerich <mads@kiilerich.com>
parents: 6908
diff changeset
266 file_diff_data.append(('', None, None, None, raw_diff, None))
6193
dc4cb1d4e084 diff: rework data structure used by diff_block.diff_block (used for changeset diffs)
Mads Kiilerich <madski@unity3d.com>
parents: 6192
diff changeset
267 c.changes[changeset.raw_id] = (cs1, cs2, file_diff_data)
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
268
6864
7691290837d2 codingstyle: trivial whitespace fixes
Lars Kruse <devel@sumpfralle.de>
parents: 6558
diff changeset
269 # sort comments in creation order
4330
773980a93cdd changesets: simplify calculation of PR comments on changesets
Mads Kiilerich <madski@unity3d.com>
parents: 4301
diff changeset
270 c.comments = [com for com_id, com in sorted(comments.items())]
3176
7ec5f9c1df45 show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3141
diff changeset
271
1677
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
272 # count inline comments
2440
1bc579bcd67a - pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents: 2439
diff changeset
273 for __, lines in c.inline_comments:
1677
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
274 for comments in lines.values():
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
275 c.inline_cnt += len(comments)
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
276
977
28524453bb76 started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
277 if len(c.cs_ranges) == 1:
28524453bb76 started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
278 c.changeset = c.cs_ranges[0]
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
279 c.parent_tmpl = ''.join(['# Parent %s\n' % x.raw_id
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
280 for x in c.changeset.parents])
8128
f537a6e23e2c py3: add missing ascii_str for display of hg changeset graft/transplant source revision
Mads Kiilerich <mads@kiilerich.com>
parents: 8013
diff changeset
281 c.changeset_graft_source_hash = ascii_str(c.changeset.extra.get(b'source', b''))
f537a6e23e2c py3: add missing ascii_str for display of hg changeset graft/transplant source revision
Mads Kiilerich <mads@kiilerich.com>
parents: 8013
diff changeset
282 c.changeset_transplant_source_hash = ascii_str(binascii.hexlify(c.changeset.extra.get(b'transplant_source', b'')))
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
283 if method == 'download':
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
284 response.content_type = 'text/plain'
2996
ebe3e388bbb3 new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
285 response.content_disposition = 'attachment; filename=%s.diff' \
ebe3e388bbb3 new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
286 % revision[:12]
6909
54199f3aab93 diffs: drop the noop as_raw method - just use the raw diff directly and with proper variable naming
Mads Kiilerich <mads@kiilerich.com>
parents: 6908
diff changeset
287 return raw_diff
2996
ebe3e388bbb3 new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
288 elif method == 'patch':
ebe3e388bbb3 new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
289 response.content_type = 'text/plain'
8198
08eec03c9485 py3: rename all existing safe_unicode to safe_str
Mads Kiilerich <mads@kiilerich.com>
parents: 8195
diff changeset
290 c.diff = safe_str(raw_diff)
2996
ebe3e388bbb3 new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
291 return render('changeset/patch_changeset.html')
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
292 elif method == 'raw':
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
293 response.content_type = 'text/plain'
6909
54199f3aab93 diffs: drop the noop as_raw method - just use the raw diff directly and with proper variable naming
Mads Kiilerich <mads@kiilerich.com>
parents: 6908
diff changeset
294 return raw_diff
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
295 elif method == 'show':
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
296 if len(c.cs_ranges) == 1:
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
297 return render('changeset/changeset.html')
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
298 else:
4297
7a5977429125 compare: show how many changesets the compared repo is behind
Mads Kiilerich <madski@unity3d.com>
parents: 4211
diff changeset
299 c.cs_ranges_org = None
4367
7879d8d88672 pull requests: show changeset comment and status flags in the changelog for PRs
Mads Kiilerich <madski@unity3d.com>
parents: 4364
diff changeset
300 c.cs_comments = {}
4352
c733124b6262 pull requests: show graph when displaying PR
Mads Kiilerich <madski@unity3d.com>
parents: 4330
diff changeset
301 revs = [ctx.revision for ctx in reversed(c.cs_ranges)]
6532
33b71a130b16 templates: properly escape inline JavaScript values
Søren Løvborg <sorenl@unity3d.com>
parents: 6520
diff changeset
302 c.jsdata = graph_data(c.db_repo_scm_instance, revs)
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2978
diff changeset
303 return render('changeset/changeset_range.html')
543
a99e23e6c1e8 fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents: 512
diff changeset
304
7110
9f976d75b04c auth: restore anonymous repository access
Mads Kiilerich <mads@kiilerich.com>
parents: 7092
diff changeset
305 @LoginRequired(allow_default_user=True)
6511
a17c8e5f6712 auth: simplify repository permission checks
Søren Løvborg <sorenl@unity3d.com>
parents: 6452
diff changeset
306 @HasRepoPermissionLevelDecorator('read')
3750
244f184f5fc3 moved around some code in changeset controllers to properly log which function was decorated.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
307 def index(self, revision, method='show'):
244f184f5fc3 moved around some code in changeset controllers to properly log which function was decorated.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
308 return self._index(revision, method=method)
244f184f5fc3 moved around some code in changeset controllers to properly log which function was decorated.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
309
7110
9f976d75b04c auth: restore anonymous repository access
Mads Kiilerich <mads@kiilerich.com>
parents: 7092
diff changeset
310 @LoginRequired(allow_default_user=True)
6511
a17c8e5f6712 auth: simplify repository permission checks
Søren Løvborg <sorenl@unity3d.com>
parents: 6452
diff changeset
311 @HasRepoPermissionLevelDecorator('read')
2996
ebe3e388bbb3 new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
312 def changeset_raw(self, revision):
3750
244f184f5fc3 moved around some code in changeset controllers to properly log which function was decorated.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
313 return self._index(revision, method='raw')
2996
ebe3e388bbb3 new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
314
7110
9f976d75b04c auth: restore anonymous repository access
Mads Kiilerich <mads@kiilerich.com>
parents: 7092
diff changeset
315 @LoginRequired(allow_default_user=True)
6511
a17c8e5f6712 auth: simplify repository permission checks
Søren Løvborg <sorenl@unity3d.com>
parents: 6452
diff changeset
316 @HasRepoPermissionLevelDecorator('read')
2996
ebe3e388bbb3 new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
317 def changeset_patch(self, revision):
3750
244f184f5fc3 moved around some code in changeset controllers to properly log which function was decorated.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
318 return self._index(revision, method='patch')
2996
ebe3e388bbb3 new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
319
7110
9f976d75b04c auth: restore anonymous repository access
Mads Kiilerich <mads@kiilerich.com>
parents: 7092
diff changeset
320 @LoginRequired(allow_default_user=True)
6511
a17c8e5f6712 auth: simplify repository permission checks
Søren Løvborg <sorenl@unity3d.com>
parents: 6452
diff changeset
321 @HasRepoPermissionLevelDecorator('read')
2996
ebe3e388bbb3 new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
322 def changeset_download(self, revision):
3750
244f184f5fc3 moved around some code in changeset controllers to properly log which function was decorated.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
323 return self._index(revision, method='download')
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
324
3749
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
325 @LoginRequired()
6511
a17c8e5f6712 auth: simplify repository permission checks
Søren Løvborg <sorenl@unity3d.com>
parents: 6452
diff changeset
326 @HasRepoPermissionLevelDecorator('read')
2187
b61e540122f2 #415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents: 2161
diff changeset
327 @jsonify
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
328 def comment(self, repo_name, revision):
7432
8d2af331205a controllers: forward pullrequests.comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7431
diff changeset
329 return create_cs_pr_comment(repo_name, revision=revision)
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
330
3749
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
331 @LoginRequired()
6511
a17c8e5f6712 auth: simplify repository permission checks
Søren Løvborg <sorenl@unity3d.com>
parents: 6452
diff changeset
332 @HasRepoPermissionLevelDecorator('read')
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
333 @jsonify
7425
c6207df9841f controllers: forward pullrequests.delete_comment to changeset
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7424
diff changeset
334 def delete_comment(self, repo_name, comment_id):
7434
901a5f2f3530 controllers: remove pr_comment flag in delete_cs_pr_comment
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents: 7433
diff changeset
335 return delete_cs_pr_comment(repo_name, comment_id)
2971
2bfcec6a3985 new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 2815
diff changeset
336
7110
9f976d75b04c auth: restore anonymous repository access
Mads Kiilerich <mads@kiilerich.com>
parents: 7092
diff changeset
337 @LoginRequired(allow_default_user=True)
6511
a17c8e5f6712 auth: simplify repository permission checks
Søren Løvborg <sorenl@unity3d.com>
parents: 6452
diff changeset
338 @HasRepoPermissionLevelDecorator('read')
2971
2bfcec6a3985 new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 2815
diff changeset
339 @jsonify
2bfcec6a3985 new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 2815
diff changeset
340 def changeset_info(self, repo_name, revision):
2978
b84a4ec93ab6 hanlde stripped or removed changesets on changeset info function
Marcin Kuzminski <marcin@python-works.com>
parents: 2971
diff changeset
341 if request.is_xhr:
b84a4ec93ab6 hanlde stripped or removed changesets on changeset info function
Marcin Kuzminski <marcin@python-works.com>
parents: 2971
diff changeset
342 try:
4196
06e49be38d78 Rename rhodecode_repo to db_repo_scm_instance
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4195
diff changeset
343 return c.db_repo_scm_instance.get_changeset(revision)
5374
d69aa464f373 cleanup: consistently use 'except ... as ...:'
Mads Kiilerich <madski@unity3d.com>
parents: 5306
diff changeset
344 except ChangesetDoesNotExistError as e:
2978
b84a4ec93ab6 hanlde stripped or removed changesets on changeset info function
Marcin Kuzminski <marcin@python-works.com>
parents: 2971
diff changeset
345 return EmptyChangeset(message=str(e))
2971
2bfcec6a3985 new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 2815
diff changeset
346 else:
2bfcec6a3985 new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 2815
diff changeset
347 raise HTTPBadRequest()
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
348
7110
9f976d75b04c auth: restore anonymous repository access
Mads Kiilerich <mads@kiilerich.com>
parents: 7092
diff changeset
349 @LoginRequired(allow_default_user=True)
6511
a17c8e5f6712 auth: simplify repository permission checks
Søren Løvborg <sorenl@unity3d.com>
parents: 6452
diff changeset
350 @HasRepoPermissionLevelDecorator('read')
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
351 @jsonify
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
352 def changeset_children(self, repo_name, revision):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
353 if request.is_xhr:
4196
06e49be38d78 Rename rhodecode_repo to db_repo_scm_instance
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4195
diff changeset
354 changeset = c.db_repo_scm_instance.get_changeset(revision)
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
355 result = {"results": []}
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
356 if changeset.children:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
357 result = {"results": changeset.children}
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
358 return result
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
359 else:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
360 raise HTTPBadRequest()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
361
7110
9f976d75b04c auth: restore anonymous repository access
Mads Kiilerich <mads@kiilerich.com>
parents: 7092
diff changeset
362 @LoginRequired(allow_default_user=True)
6511
a17c8e5f6712 auth: simplify repository permission checks
Søren Løvborg <sorenl@unity3d.com>
parents: 6452
diff changeset
363 @HasRepoPermissionLevelDecorator('read')
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
364 @jsonify
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
365 def changeset_parents(self, repo_name, revision):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
366 if request.is_xhr:
4196
06e49be38d78 Rename rhodecode_repo to db_repo_scm_instance
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4195
diff changeset
367 changeset = c.db_repo_scm_instance.get_changeset(revision)
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
368 result = {"results": []}
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
369 if changeset.parents:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
370 result = {"results": changeset.parents}
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
371 return result
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
372 else:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
373 raise HTTPBadRequest()