Mercurial > kallithea
annotate rhodecode/controllers/changeset.py @ 4186:7e5f8c12a3fc kallithea-2.2.5-rebrand
First step in two-part process to rename directories to kallithea.
This first step is to change all references in the files where they refer
to the old directory name.
author | Bradley M. Kuhn <bkuhn@sfconservancy.org> |
---|---|
date | Wed, 02 Jul 2014 19:04:28 -0400 |
parents | ffd45b185016 |
children |
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 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
18 changeset controller for pylons showoing changes beetween |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
19 revisions |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
20 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
21 :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
|
22 :author: marcink |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
23 :copyright: (c) 2013 RhodeCode GmbH. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
24 :license: GPLv3, see LICENSE for more details. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
25 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
26 |
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
27 import logging |
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
28 import traceback |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
29 from collections import defaultdict |
3619
03028bf372d7
missing changesets should return 404 not redirect + flash.
Marcin Kuzminski <marcin@python-works.com>
parents:
3573
diff
changeset
|
30 from webob.exc import HTTPForbidden, HTTPBadRequest, HTTPNotFound |
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
31 |
466
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
32 from pylons import tmpl_context as c, url, request, response |
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
|
33 from pylons.i18n.translation import _ |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
285
diff
changeset
|
34 from pylons.controllers.util import redirect |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
35 from kallithea.lib.utils import jsonify |
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
36 |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
37 from kallithea.lib.vcs.exceptions import RepositoryError, \ |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
38 ChangesetDoesNotExistError |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
39 |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
40 import kallithea.lib.helpers as h |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
41 from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator,\ |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
42 NotAnonymous |
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.base import BaseRepoController, render |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
44 from kallithea.lib.utils import action_logger |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
45 from kallithea.lib.compat import OrderedDict |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
46 from kallithea.lib import diffs |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
47 from kallithea.model.db import ChangesetComment, ChangesetStatus |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
48 from kallithea.model.comment import ChangesetCommentsModel |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
49 from kallithea.model.changeset_status import ChangesetStatusModel |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
50 from kallithea.model.meta import Session |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
51 from kallithea.model.repo import RepoModel |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
52 from kallithea.lib.diffs import LimitedDiffContainer |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
53 from kallithea.lib.exceptions import StatusChangeOnClosedPullRequestError |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
54 from kallithea.lib.vcs.backends.base import EmptyChangeset |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
55 from kallithea.lib.utils2 import safe_unicode, safe_str |
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
|
56 |
103
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 log = logging.getLogger(__name__) |
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 |
1212 | 59 |
2161
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
60 def _update_with_GET(params, GET): |
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
61 for k in ['diff1', 'diff2', 'diff']: |
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
62 params[k] += GET.getall(k) |
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
63 |
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
64 |
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
65 def anchor_url(revision, path, GET): |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
66 fid = h.FID(revision, path) |
2161
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
67 return h.url.current(anchor=fid, **dict(GET)) |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
68 |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
69 |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
70 def get_ignore_ws(fid, GET): |
2161
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
71 ig_ws_global = GET.get('ignorews') |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
72 ig_ws = filter(lambda k: k.startswith('WS'), GET.getall(fid)) |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
73 if ig_ws: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
74 try: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
75 return int(ig_ws[0].split(':')[-1]) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3619
diff
changeset
|
76 except Exception: |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
77 pass |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
78 return ig_ws_global |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
79 |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
80 |
2161
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
81 def _ignorews_url(GET, fileid=None): |
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
82 fileid = str(fileid) if fileid else None |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
83 params = defaultdict(list) |
2161
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
84 _update_with_GET(params, GET) |
3654
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
85 lbl = _('Show white space') |
2161
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
86 ig_ws = get_ignore_ws(fileid, GET) |
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
87 ln_ctx = get_line_ctx(fileid, GET) |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
88 # global option |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
89 if fileid is None: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
90 if ig_ws is None: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
91 params['ignorews'] += [1] |
3654
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
92 lbl = _('Ignore white space') |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
93 ctx_key = 'context' |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
94 ctx_val = ln_ctx |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
95 # per file options |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
96 else: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
97 if ig_ws is None: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
98 params[fileid] += ['WS:1'] |
3654
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
99 lbl = _('Ignore white space') |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
100 |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
101 ctx_key = fileid |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
102 ctx_val = 'C:%s' % ln_ctx |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
103 # if we have passed in ln_ctx pass it along to our params |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
104 if ln_ctx: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
105 params[ctx_key] += [ctx_val] |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
106 |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
107 params['anchor'] = fileid |
2073 | 108 img = h.image(h.url('/images/icons/text_strikethrough.png'), lbl, class_='icon') |
1902
2112bcbcb346
added tooltips into diff icons
Marcin Kuzminski <marcin@python-works.com>
parents:
1859
diff
changeset
|
109 return h.link_to(img, h.url.current(**params), title=lbl, class_='tooltip') |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
110 |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
111 |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
112 def get_line_ctx(fid, GET): |
2161
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
113 ln_ctx_global = GET.get('context') |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
114 if fid: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
115 ln_ctx = filter(lambda k: k.startswith('C'), GET.getall(fid)) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
116 else: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
117 _ln_ctx = filter(lambda k: k.startswith('C'), GET) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
118 ln_ctx = GET.get(_ln_ctx[0]) if _ln_ctx else ln_ctx_global |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
119 if ln_ctx: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
120 ln_ctx = [ln_ctx] |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
121 |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
122 if ln_ctx: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
123 retval = ln_ctx[0].split(':')[-1] |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
124 else: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
125 retval = ln_ctx_global |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
126 |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
127 try: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
128 return int(retval) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3619
diff
changeset
|
129 except Exception: |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
130 return 3 |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
131 |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
132 |
2161
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
133 def _context_url(GET, fileid=None): |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
134 """ |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
135 Generates url for context lines |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
136 |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
137 :param fileid: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
138 """ |
2161
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
139 |
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
140 fileid = str(fileid) if fileid else None |
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
141 ig_ws = get_ignore_ws(fileid, GET) |
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
142 ln_ctx = (get_line_ctx(fileid, GET) or 3) * 2 |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
143 |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
144 params = defaultdict(list) |
2161
e8c016815ab9
added hidden fulldiff GET param for disabling big diff cut off limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
2123
diff
changeset
|
145 _update_with_GET(params, GET) |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
146 |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
147 # global option |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
148 if fileid is None: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
149 if ln_ctx > 0: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
150 params['context'] += [ln_ctx] |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
151 |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
152 if ig_ws: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
153 ig_ws_key = 'ignorews' |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
154 ig_ws_val = 1 |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
155 |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
156 # per file option |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
157 else: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
158 params[fileid] += ['C:%s' % ln_ctx] |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
159 ig_ws_key = fileid |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
160 ig_ws_val = 'WS:%s' % 1 |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
161 |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
162 if ig_ws: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
163 params[ig_ws_key] += [ig_ws_val] |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
164 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
165 lbl = _('increase diff context to %(num)s lines') % {'num': ln_ctx} |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
166 |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
167 params['anchor'] = fileid |
2073 | 168 img = h.image(h.url('/images/icons/table_add.png'), lbl, class_='icon') |
1902
2112bcbcb346
added tooltips into diff icons
Marcin Kuzminski <marcin@python-works.com>
parents:
1859
diff
changeset
|
169 return h.link_to(img, h.url.current(**params), title=lbl, class_='tooltip') |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
170 |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
171 |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1038
diff
changeset
|
172 class ChangesetController(BaseRepoController): |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
173 |
103
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
174 def __before__(self): |
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
|
175 super(ChangesetController, self).__before__() |
1130
1cecc7db3106
fixed some limits in changesets and changelogs
Marcin Kuzminski <marcin@python-works.com>
parents:
1125
diff
changeset
|
176 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
|
177 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
178 def __load_data(self): |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
179 repo_model = RepoModel() |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
180 c.users_array = repo_model.get_users_js() |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
181 c.user_groups_array = repo_model.get_user_groups_js() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
182 |
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
|
183 def _index(self, revision, method): |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
184 c.anchor_url = anchor_url |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
185 c.ignorews_url = _ignorews_url |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1768
diff
changeset
|
186 c.context_url = _context_url |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
187 c.fulldiff = fulldiff = request.GET.get('fulldiff') |
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 #get ranges of revisions if preset |
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
|
189 rev_range = revision.split('...')[:2] |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
190 enable_comments = True |
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
|
191 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
|
192 if len(rev_range) == 2: |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
193 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
|
194 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
|
195 rev_end = rev_range[1] |
1107
7bb902022d86
small simplification in changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
196 rev_ranges = c.rhodecode_repo.get_changesets(start=rev_start, |
3023
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2996
diff
changeset
|
197 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
|
198 else: |
1108
899c19b0865c
reverted removed list casting
Marcin Kuzminski <marcin@python-works.com>
parents:
1107
diff
changeset
|
199 rev_ranges = [c.rhodecode_repo.get_changeset(revision)] |
983
57a2b792a3a1
fixed error for single changeset
Marcin Kuzminski <marcin@python-works.com>
parents:
978
diff
changeset
|
200 |
57a2b792a3a1
fixed error for single changeset
Marcin Kuzminski <marcin@python-works.com>
parents:
978
diff
changeset
|
201 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
|
202 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
|
203 raise RepositoryError('Changeset range returned empty result') |
983
57a2b792a3a1
fixed error for single changeset
Marcin Kuzminski <marcin@python-works.com>
parents:
978
diff
changeset
|
204 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
205 except(ChangesetDoesNotExistError,), e: |
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
|
206 log.error(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
|
207 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
|
208 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
|
209 raise HTTPNotFound() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
210 except (Exception,), e: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
211 log.error(traceback.format_exc()) |
3619
03028bf372d7
missing changesets should return 404 not redirect + flash.
Marcin Kuzminski <marcin@python-works.com>
parents:
3573
diff
changeset
|
212 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
|
213 |
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
|
214 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
|
215 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
216 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
|
217 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
|
218 |
2217
76947224bf27
Implemented initial code-review status of changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2216
diff
changeset
|
219 c.changeset_statuses = ChangesetStatus.STATUSES |
1670
d2de0c2f02cd
#77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
220 c.comments = [] |
2215
2c2bdaeca912
code-review initial
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
221 c.statuses = [] |
1677
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
222 c.inline_comments = [] |
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
223 c.inline_cnt = 0 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
224 |
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
|
225 # 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
|
226 for changeset in c.cs_ranges: |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
227 inlines = [] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
228 if method == 'show': |
3176
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
229 c.statuses.extend([ChangesetStatusModel().get_status( |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
230 c.rhodecode_db_repo.repo_id, changeset.raw_id)]) |
2215
2c2bdaeca912
code-review initial
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
231 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
232 c.comments.extend(ChangesetCommentsModel()\ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
233 .get_comments(c.rhodecode_db_repo.repo_id, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
234 revision=changeset.raw_id)) |
3176
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
235 |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
236 #comments from PR |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
237 st = ChangesetStatusModel().get_statuses( |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
238 c.rhodecode_db_repo.repo_id, changeset.raw_id, |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
239 with_revisions=True) |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
240 # from associated statuses, check the pull requests, and |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
241 # show comments from them |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
242 |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
243 prs = set([x.pull_request for x in |
3889
b84c83b651de
replace equality comparision to None
Marcin Kuzminski <marcin@python-works.com>
parents:
3821
diff
changeset
|
244 filter(lambda x: x.pull_request is not None, st)]) |
3176
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
245 |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
246 for pr in prs: |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
247 c.comments.extend(pr.comments) |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
248 inlines = ChangesetCommentsModel()\ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
249 .get_inline_comments(c.rhodecode_db_repo.repo_id, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
250 revision=changeset.raw_id) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
251 c.inline_comments.extend(inlines) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
252 |
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
|
253 c.changes[changeset.raw_id] = [] |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
254 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
255 cs2 = changeset.raw_id |
4044
af733fa965b0
fixed diffs vs Empty changeset
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
256 cs1 = changeset.parents[0].raw_id if changeset.parents else EmptyChangeset().raw_id |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
257 context_lcl = get_line_ctx('', request.GET) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
258 ign_whitespace_lcl = ign_whitespace_lcl = get_ignore_ws('', request.GET) |
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
|
259 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
260 _diff = c.rhodecode_repo.get_diff(cs1, cs2, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
261 ignore_whitespace=ign_whitespace_lcl, context=context_lcl) |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
262 diff_limit = self.cut_off_limit if not fulldiff else None |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
263 diff_processor = diffs.DiffProcessor(_diff, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
264 vcs=c.rhodecode_repo.alias, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
265 format='gitdiff', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
266 diff_limit=diff_limit) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
267 cs_changes = OrderedDict() |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
268 if method == 'show': |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
269 _parsed = diff_processor.prepare() |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
270 c.limited_diff = False |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
271 if isinstance(_parsed, LimitedDiffContainer): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
272 c.limited_diff = True |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
273 for f in _parsed: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
274 st = f['stats'] |
3821
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3750
diff
changeset
|
275 c.lines_added += st['added'] |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3750
diff
changeset
|
276 c.lines_deleted += st['deleted'] |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
277 fid = h.FID(changeset.raw_id, f['filename']) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
278 diff = diff_processor.as_html(enable_comments=enable_comments, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
279 parsed_lines=[f]) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
280 cs_changes[fid] = [cs1, cs2, f['operation'], f['filename'], |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
281 diff, st] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
282 else: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
283 # downloads/raw we only need RAW diff nothing else |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
284 diff = diff_processor.as_raw() |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
285 cs_changes[''] = [None, None, None, None, diff, None] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
286 c.changes[changeset.raw_id] = cs_changes |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
287 |
3176
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
288 #sort comments by how they were generated |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
289 c.comments = sorted(c.comments, key=lambda x: x.comment_id) |
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
290 |
1677
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
291 # count inline comments |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2439
diff
changeset
|
292 for __, lines in c.inline_comments: |
1677
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
293 for comments in lines.values(): |
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
294 c.inline_cnt += len(comments) |
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
295 |
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
|
296 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
|
297 c.changeset = c.cs_ranges[0] |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
298 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
|
299 for x in c.changeset.parents]) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
300 if method == 'download': |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
301 response.content_type = 'text/plain' |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
302 response.content_disposition = 'attachment; filename=%s.diff' \ |
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
303 % revision[:12] |
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
304 return diff |
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
305 elif method == 'patch': |
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
306 response.content_type = 'text/plain' |
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
307 c.diff = safe_unicode(diff) |
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
308 return render('changeset/patch_changeset.html') |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
309 elif method == 'raw': |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
310 response.content_type = 'text/plain' |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
311 return diff |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
312 elif method == 'show': |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
313 self.__load_data() |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
314 if len(c.cs_ranges) == 1: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
315 return render('changeset/changeset.html') |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
316 else: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2978
diff
changeset
|
317 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
|
318 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
319 @LoginRequired() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
320 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
321 'repository.admin') |
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
|
322 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
|
323 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
|
324 |
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
|
325 @LoginRequired() |
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
|
326 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
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
|
327 'repository.admin') |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
328 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
|
329 return self._index(revision, method='raw') |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
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() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
332 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
333 'repository.admin') |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
334 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
|
335 return self._index(revision, method='patch') |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
336 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
337 @LoginRequired() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
338 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
339 'repository.admin') |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
340 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
|
341 return self._index(revision, method='download') |
1670
d2de0c2f02cd
#77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
342 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
343 @LoginRequired() |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
344 @NotAnonymous() |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
345 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
346 'repository.admin') |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2161
diff
changeset
|
347 @jsonify |
1670
d2de0c2f02cd
#77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
348 def comment(self, repo_name, revision): |
2296
e5c0f201ca0b
Add changeset status change into emails
Marcin Kuzminski <marcin@python-works.com>
parents:
2286
diff
changeset
|
349 status = request.POST.get('changeset_status') |
e5c0f201ca0b
Add changeset status change into emails
Marcin Kuzminski <marcin@python-works.com>
parents:
2286
diff
changeset
|
350 change_status = request.POST.get('change_changeset_status') |
2796
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
351 text = request.POST.get('text') |
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
352 if status and change_status: |
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
353 text = text or (_('Status change -> %s') |
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
354 % ChangesetStatus.get_status_lbl(status)) |
2296
e5c0f201ca0b
Add changeset status change into emails
Marcin Kuzminski <marcin@python-works.com>
parents:
2286
diff
changeset
|
355 |
3430
bbe21df7ad48
notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3176
diff
changeset
|
356 c.co = comm = ChangesetCommentsModel().create( |
2796
bf3c976d02ec
always post text about status changes of code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
357 text=text, |
2541
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
358 repo=c.rhodecode_db_repo.repo_id, |
1c2ba03c42b4
Added dynamic data loading for other repo we open pull request against
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
359 user=c.rhodecode_user.user_id, |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2161
diff
changeset
|
360 revision=revision, |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2161
diff
changeset
|
361 f_path=request.POST.get('f_path'), |
2296
e5c0f201ca0b
Add changeset status change into emails
Marcin Kuzminski <marcin@python-works.com>
parents:
2286
diff
changeset
|
362 line_no=request.POST.get('line'), |
2478
8eab81115660
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2443
diff
changeset
|
363 status_change=(ChangesetStatus.get_status_lbl(status) |
2296
e5c0f201ca0b
Add changeset status change into emails
Marcin Kuzminski <marcin@python-works.com>
parents:
2286
diff
changeset
|
364 if status and change_status else None) |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2161
diff
changeset
|
365 ) |
2217
76947224bf27
Implemented initial code-review status of changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2216
diff
changeset
|
366 |
76947224bf27
Implemented initial code-review status of changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2216
diff
changeset
|
367 # get status if set ! |
2296
e5c0f201ca0b
Add changeset status change into emails
Marcin Kuzminski <marcin@python-works.com>
parents:
2286
diff
changeset
|
368 if status and change_status: |
2677
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
369 # if latest status was from pull request and it's closed |
2815
acc05c33cc0c
White space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2796
diff
changeset
|
370 # disallow changing status ! |
2677
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
371 # dont_allow_on_closed_pull_request = True ! |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
372 |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
373 try: |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
374 ChangesetStatusModel().set_status( |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
375 c.rhodecode_db_repo.repo_id, |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
376 status, |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
377 c.rhodecode_user.user_id, |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
378 comm, |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
379 revision=revision, |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
380 dont_allow_on_closed_pull_request=True |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
381 ) |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
382 except StatusChangeOnClosedPullRequestError: |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
383 log.error(traceback.format_exc()) |
3176
7ec5f9c1df45
show comments from pull requests into associated changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3141
diff
changeset
|
384 msg = _('Changing status on a changeset associated with ' |
2677
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
385 'a closed pull request is not allowed') |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
386 h.flash(msg, category='warning') |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
387 return redirect(h.url('changeset_home', repo_name=repo_name, |
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
388 revision=revision)) |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
389 action_logger(self.rhodecode_user, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
390 'user_commented_revision:%s' % revision, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
391 c.rhodecode_db_repo, self.ip_addr, self.sa) |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
392 |
2677
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
393 Session().commit() |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
394 |
2189
3052f90c568a
fixed main comments, prevent from sending inline comments if text is empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2188
diff
changeset
|
395 if not request.environ.get('HTTP_X_PARTIAL_XHR'): |
3052f90c568a
fixed main comments, prevent from sending inline comments if text is empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2188
diff
changeset
|
396 return redirect(h.url('changeset_home', repo_name=repo_name, |
3052f90c568a
fixed main comments, prevent from sending inline comments if text is empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2188
diff
changeset
|
397 revision=revision)) |
3430
bbe21df7ad48
notifications changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3176
diff
changeset
|
398 #only ajax below |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2161
diff
changeset
|
399 data = { |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2161
diff
changeset
|
400 'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))), |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2161
diff
changeset
|
401 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2161
diff
changeset
|
402 if comm: |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2161
diff
changeset
|
403 data.update(comm.get_dict()) |
2188
56e96d4e9f6e
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2187
diff
changeset
|
404 data.update({'rendered_text': |
56e96d4e9f6e
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2187
diff
changeset
|
405 render('changeset/changeset_comment_block.html')}) |
2189
3052f90c568a
fixed main comments, prevent from sending inline comments if text is empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2188
diff
changeset
|
406 |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2161
diff
changeset
|
407 return data |
1670
d2de0c2f02cd
#77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
408 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
409 @LoginRequired() |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
410 @NotAnonymous() |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
411 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
412 'repository.admin') |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
413 def preview_comment(self): |
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
414 if not request.environ.get('HTTP_X_PARTIAL_XHR'): |
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
415 raise HTTPBadRequest() |
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
416 text = request.POST.get('text') |
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
417 if text: |
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
418 return h.rst_w_mentions(text) |
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
419 return '' |
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
420 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
421 @LoginRequired() |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
422 @NotAnonymous() |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
423 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
424 'repository.admin') |
1670
d2de0c2f02cd
#77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
425 @jsonify |
1716
7d1fc253549e
notification to commit author + gardening
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
426 def delete_comment(self, repo_name, comment_id): |
1674
6f0143e5efe5
#71 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1670
diff
changeset
|
427 co = ChangesetComment.get(comment_id) |
3141
a45191e7c7bb
access control: fix owner checks - they were always true
Mads Kiilerich <madski@unity3d.com>
parents:
3061
diff
changeset
|
428 owner = co.author.user_id == c.rhodecode_user.user_id |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
429 repo_admin = h.HasRepoPermissionAny('repository.admin') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
430 if h.HasPermissionAny('hg.admin')() or repo_admin or owner: |
1713
54687aa00724
Tests updates, Session refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
431 ChangesetCommentsModel().delete(comment=co) |
2677
4fbbc65e8cd5
Forbid changing changset status when it is associated with a closed pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2541
diff
changeset
|
432 Session().commit() |
1674
6f0143e5efe5
#71 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1670
diff
changeset
|
433 return True |
6f0143e5efe5
#71 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1670
diff
changeset
|
434 else: |
6f0143e5efe5
#71 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1670
diff
changeset
|
435 raise HTTPForbidden() |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2815
diff
changeset
|
436 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
437 @LoginRequired() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
438 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
439 'repository.admin') |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2815
diff
changeset
|
440 @jsonify |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2815
diff
changeset
|
441 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
|
442 if request.is_xhr: |
b84a4ec93ab6
hanlde stripped or removed changesets on changeset info function
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
443 try: |
b84a4ec93ab6
hanlde stripped or removed changesets on changeset info function
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
444 return c.rhodecode_repo.get_changeset(revision) |
b84a4ec93ab6
hanlde stripped or removed changesets on changeset info function
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
445 except ChangesetDoesNotExistError, e: |
b84a4ec93ab6
hanlde stripped or removed changesets on changeset info function
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
446 return EmptyChangeset(message=str(e)) |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2815
diff
changeset
|
447 else: |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2815
diff
changeset
|
448 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
|
449 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
450 @LoginRequired() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
451 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
452 'repository.admin') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
453 @jsonify |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
454 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
|
455 if request.is_xhr: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
456 changeset = c.rhodecode_repo.get_changeset(revision) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
457 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
|
458 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
|
459 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
|
460 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
|
461 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
462 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
|
463 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
464 @LoginRequired() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
465 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
466 'repository.admin') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
467 @jsonify |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
468 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
|
469 if request.is_xhr: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
470 changeset = c.rhodecode_repo.get_changeset(revision) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
471 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
|
472 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
|
473 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
|
474 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
|
475 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4077
diff
changeset
|
476 raise HTTPBadRequest() |