annotate rhodecode/controllers/changeset.py @ 2031:82a88013a3fd

merge 1.3 into stable
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 26 Feb 2012 17:25:09 +0200
parents da8f1d1b22de 324ac367a4da
children c238df8ceb24
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 -*-
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
2 """
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
3 rhodecode.controllers.changeset
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
5
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1131
diff changeset
6 changeset controller for pylons showoing changes beetween
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
7 revisions
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1131
diff changeset
8
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
9 :created_on: Apr 25, 2010
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
10 :author: marcink
1824
89efedac4e6c 2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents: 1789
diff changeset
11 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
12 :license: GPLv3, see COPYING for more details.
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
13 """
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
14 # 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
15 # 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
16 # 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
17 # (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
18 #
252
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
19 # 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
20 # 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
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
22 # 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
23 #
252
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
24 # 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
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
26 import logging
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
27 import traceback
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
28 from collections import defaultdict
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
29 from webob.exc import HTTPForbidden
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
30
466
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
31 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
32 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
33 from pylons.controllers.util import redirect
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
34 from pylons.decorators 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
35
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents: 1902
diff changeset
36 from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetError, \
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
37 ChangesetDoesNotExistError
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents: 1902
diff changeset
38 from rhodecode.lib.vcs.nodes import FileNode
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
39
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
40 import rhodecode.lib.helpers as h
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1677
diff changeset
41 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
1045
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1038
diff changeset
42 from rhodecode.lib.base import BaseRepoController, render
649
3765f0f479a2 fixed raw diff as purly raw without html
Marcin Kuzminski <marcin@python-works.com>
parents: 648
diff changeset
43 from rhodecode.lib.utils import EmptyChangeset
1514
87ec80c280bb fixed issues with python2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 1402
diff changeset
44 from rhodecode.lib.compat import OrderedDict
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
45 from rhodecode.lib import diffs
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
46 from rhodecode.model.db import ChangesetComment
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
47 from rhodecode.model.comment import ChangesetCommentsModel
1713
54687aa00724 Tests updates, Session refactoring
Marcin Kuzminski <marcin@python-works.com>
parents: 1712
diff changeset
48 from rhodecode.model.meta import Session
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
49 from rhodecode.lib.diffs import wrapped_diff
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
50
103
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 log = logging.getLogger(__name__)
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52
1212
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
53
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
54 def anchor_url(revision, path):
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
55 fid = h.FID(revision, path)
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
56 return h.url.current(anchor=fid, **request.GET)
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
57
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
58
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
59 def get_ignore_ws(fid, GET):
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
60 ig_ws_global = request.GET.get('ignorews')
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
61 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
62 if ig_ws:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
63 try:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
64 return int(ig_ws[0].split(':')[-1])
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
65 except:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
66 pass
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
67 return ig_ws_global
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
68
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
69
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
70 def _ignorews_url(fileid=None):
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
71
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
72 params = defaultdict(list)
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
73 lbl = _('show white space')
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
74 ig_ws = get_ignore_ws(fileid, request.GET)
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
75 ln_ctx = get_line_ctx(fileid, request.GET)
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
76 # global option
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
77 if fileid is None:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
78 if ig_ws is None:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
79 params['ignorews'] += [1]
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
80 lbl = _('ignore white space')
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
81 ctx_key = 'context'
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
82 ctx_val = ln_ctx
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
83 # per file options
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
84 else:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
85 if ig_ws is None:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
86 params[fileid] += ['WS:1']
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
87 lbl = _('ignore white space')
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
88
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
89 ctx_key = fileid
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
90 ctx_val = 'C:%s' % ln_ctx
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
91 # 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
92 if ln_ctx:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
93 params[ctx_key] += [ctx_val]
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
94
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
95 params['anchor'] = fileid
1859
929fc8d926d5 changeset: replace diff/whitespace/context popup menu with icons
Aras Pranckevicius <aras@unity3d.com>
parents: 1824
diff changeset
96 img = h.image('/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
97 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
98
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
99
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
100 def get_line_ctx(fid, GET):
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
101 ln_ctx_global = request.GET.get('context')
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
102 ln_ctx = filter(lambda k: k.startswith('C'), GET.getall(fid))
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
103
1776
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 retval = ln_ctx[0].split(':')[-1]
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
106 else:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
107 retval = ln_ctx_global
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
108
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
109 try:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
110 return int(retval)
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
111 except:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
112 return
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
113
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
114
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
115 def _context_url(fileid=None):
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
116 """
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
117 Generates url for context lines
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
118
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
119 :param fileid:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
120 """
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
121 ig_ws = get_ignore_ws(fileid, request.GET)
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
122 ln_ctx = (get_line_ctx(fileid, request.GET) or 3) * 2
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
123
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
124 params = defaultdict(list)
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
125
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
126 # global option
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
127 if fileid is None:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
128 if ln_ctx > 0:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
129 params['context'] += [ln_ctx]
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
130
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
131 if ig_ws:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
132 ig_ws_key = 'ignorews'
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
133 ig_ws_val = 1
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 # per file option
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
136 else:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
137 params[fileid] += ['C:%s' % ln_ctx]
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
138 ig_ws_key = fileid
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
139 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
140
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
141 if ig_ws:
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
142 params[ig_ws_key] += [ig_ws_val]
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 lbl = _('%s line context') % ln_ctx
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
145
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
146 params['anchor'] = fileid
1859
929fc8d926d5 changeset: replace diff/whitespace/context popup menu with icons
Aras Pranckevicius <aras@unity3d.com>
parents: 1824
diff changeset
147 img = h.image('/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
148 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
149
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
150
1045
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1038
diff changeset
151 class ChangesetController(BaseRepoController):
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
152
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
153 @LoginRequired()
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
154 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
155 'repository.admin')
103
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
156 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
157 super(ChangesetController, self).__before__()
1130
1cecc7db3106 fixed some limits in changesets and changelogs
Marcin Kuzminski <marcin@python-works.com>
parents: 1125
diff changeset
158 c.affected_files_cut_off = 60
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
159
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
160 def index(self, revision):
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
161
1776
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
162 c.anchor_url = anchor_url
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
163 c.ignorews_url = _ignorews_url
22333ddd1a40 implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1768
diff changeset
164 c.context_url = _context_url
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
165
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
166 #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
167 rev_range = revision.split('...')[:2]
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
168 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
169 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
170 if len(rev_range) == 2:
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
171 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
172 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
173 rev_end = rev_range[1]
1107
7bb902022d86 small simplification in changelog
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
174 rev_ranges = c.rhodecode_repo.get_changesets(start=rev_start,
7bb902022d86 small simplification in changelog
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
175 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
176 else:
1108
899c19b0865c reverted removed list casting
Marcin Kuzminski <marcin@python-works.com>
parents: 1107
diff changeset
177 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
178
57a2b792a3a1 fixed error for single changeset
Marcin Kuzminski <marcin@python-works.com>
parents: 978
diff changeset
179 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
180 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
181 raise RepositoryError('Changeset range returned empty result')
983
57a2b792a3a1 fixed error for single changeset
Marcin Kuzminski <marcin@python-works.com>
parents: 978
diff changeset
182
978
6d2239363c81 #93 fixed errors on new revranges generation
Marcin Kuzminski <marcin@python-works.com>
parents: 977
diff changeset
183 except (RepositoryError, ChangesetDoesNotExistError, Exception), 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
184 log.error(traceback.format_exc())
644
c8bd0e6cc3da some changes for #45.
Marcin Kuzminski <marcin@python-works.com>
parents: 636
diff changeset
185 h.flash(str(e), category='warning')
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
186 return redirect(url('home'))
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
187
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 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
189
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
190 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
191 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
192
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
193 cumulative_diff = 0
1280
215a4801bb1e pep8ify + small fixes for followers page + added tooltips for followers
Marcin Kuzminski <marcin@python-works.com>
parents: 1274
diff changeset
194 c.cut_off = False # defines if cut off limit is reached
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
195
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
196 c.comments = []
1677
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
197 c.inline_comments = []
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
198 c.inline_cnt = 0
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
199 # 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
200 for changeset in c.cs_ranges:
1675
7c487d2678c7 code refactoring
Marcin Kuzminski <marcin@python-works.com>
parents: 1674
diff changeset
201 c.comments.extend(ChangesetCommentsModel()\
7c487d2678c7 code refactoring
Marcin Kuzminski <marcin@python-works.com>
parents: 1674
diff changeset
202 .get_comments(c.rhodecode_db_repo.repo_id,
7c487d2678c7 code refactoring
Marcin Kuzminski <marcin@python-works.com>
parents: 1674
diff changeset
203 changeset.raw_id))
1677
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
204 inlines = ChangesetCommentsModel()\
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
205 .get_inline_comments(c.rhodecode_db_repo.repo_id,
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
206 changeset.raw_id)
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
207 c.inline_comments.extend(inlines)
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
208 c.changes[changeset.raw_id] = []
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
209 try:
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
210 changeset_parent = changeset.parents[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
211 except IndexError:
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
212 changeset_parent = None
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 #==================================================================
544
d8778cde98f0 added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 543
diff changeset
215 # ADDED FILES
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
216 #==================================================================
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
217 for node in changeset.added:
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
218 fid = h.FID(revision, node.path)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
219 line_context_lcl = get_line_ctx(fid, request.GET)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
220 ign_whitespace_lcl = get_ignore_ws(fid, request.GET)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
221 lim = self.cut_off_limit
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
222 if cumulative_diff > self.cut_off_limit:
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
223 lim = -1
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
224 size, cs1, cs2, diff, st = wrapped_diff(filenode_old=None,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
225 filenode_new=node,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
226 cut_off_limit=lim,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
227 ignore_whitespace=ign_whitespace_lcl,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
228 line_context=line_context_lcl,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
229 enable_comments=enable_comments)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
230 cumulative_diff += size
1257
0a2a10a1912f Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents: 1212
diff changeset
231 c.lines_added += st[0]
0a2a10a1912f Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents: 1212
diff changeset
232 c.lines_deleted += st[1]
0a2a10a1912f Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents: 1212
diff changeset
233 c.changes[changeset.raw_id].append(('added', node, diff,
0a2a10a1912f Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents: 1212
diff changeset
234 cs1, cs2, st))
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
235
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
236 #==================================================================
544
d8778cde98f0 added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 543
diff changeset
237 # CHANGED FILES
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
238 #==================================================================
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
239 for node in changeset.changed:
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
240 try:
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
241 filenode_old = changeset_parent.get_node(node.path)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
242 except ChangesetError:
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
243 log.warning('Unable to fetch parent node for diff')
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
244 filenode_old = FileNode(node.path, '', EmptyChangeset())
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
245
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
246 fid = h.FID(revision, node.path)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
247 line_context_lcl = get_line_ctx(fid, request.GET)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
248 ign_whitespace_lcl = get_ignore_ws(fid, request.GET)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
249 lim = self.cut_off_limit
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
250 if cumulative_diff > self.cut_off_limit:
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
251 lim = -1
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
252 size, cs1, cs2, diff, st = wrapped_diff(filenode_old=filenode_old,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
253 filenode_new=node,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
254 cut_off_limit=lim,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
255 ignore_whitespace=ign_whitespace_lcl,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
256 line_context=line_context_lcl,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
257 enable_comments=enable_comments)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
258 cumulative_diff += size
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
259 c.lines_added += st[0]
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
260 c.lines_deleted += st[1]
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
261 c.changes[changeset.raw_id].append(('changed', node, diff,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
262 cs1, cs2, st))
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
263
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
264 #==================================================================
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1131
diff changeset
265 # REMOVED FILES
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
266 #==================================================================
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
267 for node in changeset.removed:
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
268 c.changes[changeset.raw_id].append(('removed', node, None,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
269 None, None, (0, 0)))
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
270
1677
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
271 # count inline comments
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
272 for path, lines in c.inline_comments:
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
273 for comments in lines.values():
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
274 c.inline_cnt += len(comments)
7276b170ce8b #71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents: 1676
diff changeset
275
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
276 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
277 c.changeset = c.cs_ranges[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
278 c.changes = c.changes[c.changeset.raw_id]
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
279
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
280 return render('changeset/changeset.html')
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
281 else:
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
282 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
283
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
284 def raw_changeset(self, revision):
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
285
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
286 method = request.GET.get('diff', 'show')
1752
f28dc032adf0 Added handling of ignore whitespace flag in changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
287 ignore_whitespace = request.GET.get('ignorews') == '1'
1768
5610fd9b6803 added line context control to diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1753
diff changeset
288 line_context = request.GET.get('context', 3)
285
42f5c36820ef few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 273
diff changeset
289 try:
1045
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1038
diff changeset
290 c.scm_type = c.rhodecode_repo.alias
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1038
diff changeset
291 c.changeset = c.rhodecode_repo.get_changeset(revision)
285
42f5c36820ef few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 273
diff changeset
292 except RepositoryError:
42f5c36820ef few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 273
diff changeset
293 log.error(traceback.format_exc())
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
294 return redirect(url('home'))
285
42f5c36820ef few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 273
diff changeset
295 else:
42f5c36820ef few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 273
diff changeset
296 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
297 c.changeset_parent = c.changeset.parents[0]
285
42f5c36820ef few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 273
diff changeset
298 except IndexError:
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
299 c.changeset_parent = None
285
42f5c36820ef few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 273
diff changeset
300 c.changes = []
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
301
285
42f5c36820ef few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 273
diff changeset
302 for node in c.changeset.added:
42f5c36820ef few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 273
diff changeset
303 filenode_old = FileNode(node.path, '')
42f5c36820ef few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 273
diff changeset
304 if filenode_old.is_binary or node.is_binary:
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
305 diff = _('binary file') + '\n'
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
306 else:
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
307 f_gitdiff = diffs.get_gitdiff(filenode_old, node,
1768
5610fd9b6803 added line context control to diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1753
diff changeset
308 ignore_whitespace=ignore_whitespace,
5610fd9b6803 added line context control to diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1753
diff changeset
309 context=line_context)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
310 diff = diffs.DiffProcessor(f_gitdiff,
1212
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
311 format='gitdiff').raw_diff()
466
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
312
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
313 cs1 = None
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
314 cs2 = node.last_changeset.raw_id
466
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
315 c.changes.append(('added', node, diff, cs1, cs2))
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
316
466
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
317 for node in c.changeset.changed:
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
318 filenode_old = c.changeset_parent.get_node(node.path)
466
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
319 if filenode_old.is_binary or node.is_binary:
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
320 diff = _('binary file')
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
321 else:
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
322 f_gitdiff = diffs.get_gitdiff(filenode_old, node,
1768
5610fd9b6803 added line context control to diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1753
diff changeset
323 ignore_whitespace=ignore_whitespace,
5610fd9b6803 added line context control to diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1753
diff changeset
324 context=line_context)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
325 diff = diffs.DiffProcessor(f_gitdiff,
1212
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
326 format='gitdiff').raw_diff()
466
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
327
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
328 cs1 = filenode_old.last_changeset.raw_id
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
329 cs2 = node.last_changeset.raw_id
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
330 c.changes.append(('changed', node, diff, cs1, cs2))
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
331
466
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
332 response.content_type = 'text/plain'
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
333
468
9dd372c7166c added menu for changeset raw diff and download diff
Marcin Kuzminski <marcin@python-works.com>
parents: 466
diff changeset
334 if method == 'download':
1212
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
335 response.content_disposition = 'attachment; filename=%s.patch' \
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
336 % revision
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
337
1402
edfbf3ee9965 fixes #217 Seperate Parents on Raw-changeset page
Marcin Kuzminski <marcin@python-works.com>
parents: 1337
diff changeset
338 c.parent_tmpl = ''.join(['# Parent %s\n' % x.raw_id for x in
edfbf3ee9965 fixes #217 Seperate Parents on Raw-changeset page
Marcin Kuzminski <marcin@python-works.com>
parents: 1337
diff changeset
339 c.changeset.parents])
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
340
466
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
341 c.diffs = ''
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
342 for x in c.changes:
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
343 c.diffs += x[2]
812
30ad41c76fae fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
344
466
183cee110578 first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents: 318
diff changeset
345 return render('changeset/raw_changeset.html')
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
346
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
347 def comment(self, repo_name, revision):
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1677
diff changeset
348 ChangesetCommentsModel().create(text=request.POST.get('text'),
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1677
diff changeset
349 repo_id=c.rhodecode_db_repo.repo_id,
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1677
diff changeset
350 user_id=c.rhodecode_user.user_id,
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1677
diff changeset
351 revision=revision,
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1677
diff changeset
352 f_path=request.POST.get('f_path'),
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1677
diff changeset
353 line_no=request.POST.get('line'))
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1716
diff changeset
354 Session.commit()
1670
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
355 return redirect(h.url('changeset_home', repo_name=repo_name,
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
356 revision=revision))
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
357
d2de0c2f02cd #77 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1656
diff changeset
358 @jsonify
1716
7d1fc253549e notification to commit author + gardening
Marcin Kuzminski <marcin@python-works.com>
parents: 1713
diff changeset
359 def delete_comment(self, repo_name, comment_id):
1674
6f0143e5efe5 #71 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1670
diff changeset
360 co = ChangesetComment.get(comment_id)
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1776
diff changeset
361 owner = lambda: co.author.user_id == c.rhodecode_user.user_id
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1677
diff changeset
362 if h.HasPermissionAny('hg.admin', 'repository.admin')() or owner:
1713
54687aa00724 Tests updates, Session refactoring
Marcin Kuzminski <marcin@python-works.com>
parents: 1712
diff changeset
363 ChangesetCommentsModel().delete(comment=co)
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1716
diff changeset
364 Session.commit()
1674
6f0143e5efe5 #71 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1670
diff changeset
365 return True
6f0143e5efe5 #71 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1670
diff changeset
366 else:
6f0143e5efe5 #71 code review
Marcin Kuzminski <marcin@python-works.com>
parents: 1670
diff changeset
367 raise HTTPForbidden()