annotate rhodecode/controllers/changelog.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl

Imported some of the GPLv3'd changes from RhodeCode v2.2.5. This imports changes between changesets 21af6c4eab3d and 6177597791c2 in RhodeCode's original repository, including only changes to Python files and HTML. RhodeCode clearly licensed its changes to these files under GPLv3 in their /LICENSE file, which states the following: The Python code and integrated HTML are licensed under the GPLv3 license. (See: https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE or http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE for an online copy of that LICENSE file) Conservancy reviewed these changes and confirmed that they can be licensed as a whole to the Kallithea project under GPLv3-only. While some of the contents committed herein are clearly licensed GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the statement above from RhodeCode indicates that they intend GPLv3-only as their license, per GPLv3ยง14 and other relevant sections of GPLv3.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:03:13 -0400
parents 0e1023147334
children 7e5f8c12a3fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
861
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 699
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: 1130
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: 1130
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 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
15 rhodecode.controllers.changelog
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 changelog controller for rhodecode
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
19
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
20 :created_on: Apr 21, 2010
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4077
diff changeset
21 :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
22 :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
23 :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
24 """
861
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 699
diff changeset
25
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 699
diff changeset
26 import logging
1656
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
27 import traceback
592
0a48c1ec04fc #37 fixed json imports for python2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
28
1656
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
29 from pylons import request, url, session, tmpl_context as c
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
30 from pylons.controllers.util import redirect
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
31 from pylons.i18n.translation import _
3996
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
32 from webob.exc import HTTPNotFound, HTTPBadRequest
861
fd2ea6ceadc8 updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents: 699
diff changeset
33
1656
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
34 import rhodecode.lib.helpers as h
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 361
diff changeset
35 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
1045
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1038
diff changeset
36 from rhodecode.lib.base import BaseRepoController, render
1098
91ddd4db4614 Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents: 1083
diff changeset
37 from rhodecode.lib.helpers import RepoPage
1514
87ec80c280bb fixed issues with python2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 1434
diff changeset
38 from rhodecode.lib.compat import json
2380
0c7dc3402efa Unified DAG generation for hg and git
Marcin Kuzminski <marcin@python-works.com>
parents: 2370
diff changeset
39 from rhodecode.lib.graphmod import _colored, _dagwalker
3760
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
40 from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError,\
3794
222e9432298e in case of empty directory don't redirect to changelog, it causes an redirection loop
Marcin Kuzminski <marcin@python-works.com>
parents: 3764
diff changeset
41 ChangesetError, NodeDoesNotExistError, EmptyRepositoryError
4077
0e1023147334 Use safe_str on flash messages.
Marcin Kuzminski <marcin@python-works.com>
parents: 4036
diff changeset
42 from rhodecode.lib.utils2 import safe_int, safe_str
3996
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
43
1656
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
44
318
fdf9f6ee5217 Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 291
diff changeset
45 log = logging.getLogger(__name__)
93
aec4c0071cb3 added empty controllers for branches tags files graph, routing and test for them
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46
1212
50e41777675d pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
47
3764
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
48 def _load_changelog_summary():
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
49 p = safe_int(request.GET.get('page'), 1)
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
50 size = safe_int(request.GET.get('size'), 10)
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
51
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
52 def url_generator(**kw):
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
53 return url('changelog_summary_home',
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
54 repo_name=c.rhodecode_db_repo.repo_name, size=size, **kw)
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
55
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
56 collection = c.rhodecode_repo
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
57
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
58 c.repo_changesets = RepoPage(collection, page=p,
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
59 items_per_page=size,
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
60 url=url_generator)
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
61 page_revisions = [x.raw_id for x in list(c.repo_changesets)]
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
62 c.comments = c.rhodecode_db_repo.get_comments(page_revisions)
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
63 c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
64
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
65
1045
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1038
diff changeset
66 class ChangelogController(BaseRepoController):
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
67
93
aec4c0071cb3 added empty controllers for branches tags files graph, routing and test for them
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 def __before__(self):
192
f191f99f59c9 full changelog caching, secured changelog with LoginRequired, some minor changes in graph
Marcin Kuzminski <marcin@python-works.com>
parents: 142
diff changeset
69 super(ChangelogController, self).__before__()
1130
1cecc7db3106 fixed some limits in changesets and changelogs
Marcin Kuzminski <marcin@python-works.com>
parents: 1109
diff changeset
70 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
71
3996
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
72 def __get_cs_or_redirect(self, rev, repo, redirect_after=True,
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
73 partial=False):
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
74 """
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
75 Safe way to get changeset if error occur it redirects to changeset with
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
76 proper message. If partial is set then don't do redirect raise Exception
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
77 instead
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
78
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
79 :param rev: revision to fetch
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
80 :param repo: repo instance
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
81 """
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
82
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
83 try:
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
84 return c.rhodecode_repo.get_changeset(rev)
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
85 except EmptyRepositoryError, e:
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
86 if not redirect_after:
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
87 return None
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
88 h.flash(h.literal(_('There are no changesets yet')),
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
89 category='warning')
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
90 redirect(url('changelog_home', repo_name=repo.repo_name))
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
91
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
92 except RepositoryError, e:
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
93 log.error(traceback.format_exc())
4077
0e1023147334 Use safe_str on flash messages.
Marcin Kuzminski <marcin@python-works.com>
parents: 4036
diff changeset
94 h.flash(safe_str(e), category='warning')
3996
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
95 if not partial:
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
96 redirect(h.url('changelog_home', repo_name=repo.repo_name))
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
97 raise HTTPBadRequest()
267bb347d68c Added missing __get_cs_or_redirect method for file history.
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
98
3749
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
99 def _graph(self, repo, revs_int, repo_size, size, p):
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
100 """
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
101 Generates a DAG graph for repo
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
102
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
103 :param repo:
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
104 :param revs_int:
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
105 :param repo_size:
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
106 :param size:
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
107 :param p:
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
108 """
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
109 if not revs_int:
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
110 c.jsdata = json.dumps([])
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
111 return
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
112
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
113 data = []
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
114 revs = revs_int
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
115
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
116 dag = _dagwalker(repo, revs, repo.alias)
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
117 dag = _colored(dag)
4036
4fb3a7286e7b do not overwrite python types
Marcin Kuzminski <marcin@python-works.com>
parents: 4035
diff changeset
118 for (_id, _type, ctx, vtx, edges) in dag:
3749
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
119 data.append(['', vtx, edges])
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
120
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
121 c.jsdata = json.dumps(data)
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
122
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
123 @LoginRequired()
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
124 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
125 'repository.admin')
3760
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
126 def index(self, repo_name, revision=None, f_path=None):
213
Marcin Kuzminski <marcin@python-works.com>
parents: 211
diff changeset
127 limit = 100
1864
baef43bc457c revert default to 20, for large repositories it's better to go less and have it faster.
Marcin Kuzminski <marcin@python-works.com>
parents: 1850
diff changeset
128 default = 20
3748
9d743ca9cede usage of request.GET is now more consistent
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
129 if request.GET.get('size'):
9d743ca9cede usage of request.GET is now more consistent
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
130 c.size = max(min(safe_int(request.GET.get('size')), limit), 1)
192
f191f99f59c9 full changelog caching, secured changelog with LoginRequired, some minor changes in graph
Marcin Kuzminski <marcin@python-works.com>
parents: 142
diff changeset
131 session['changelog_size'] = c.size
f191f99f59c9 full changelog caching, secured changelog with LoginRequired, some minor changes in graph
Marcin Kuzminski <marcin@python-works.com>
parents: 142
diff changeset
132 session.save()
142
f7218849798a Changeg graph to changelog, and changelog to shortlog
Marcin Kuzminski <marcin@python-works.com>
parents: 127
diff changeset
133 else:
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 276
diff changeset
134 c.size = int(session.get('changelog_size', default))
2628
4548912f48c8 fixes issue #502, float division error on setting maxsize of changelog to 0
Marcin Kuzminski <marcin@python-works.com>
parents: 2520
diff changeset
135 # min size must be 1
4548912f48c8 fixes issue #502, float division error on setting maxsize of changelog to 0
Marcin Kuzminski <marcin@python-works.com>
parents: 2520
diff changeset
136 c.size = max(c.size, 1)
3748
9d743ca9cede usage of request.GET is now more consistent
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
137 p = safe_int(request.GET.get('page', 1), 1)
9d743ca9cede usage of request.GET is now more consistent
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
138 branch_name = request.GET.get('branch', None)
4022
4a0bce848ed8 changelog: use unknown branch names as revisions
Mads Kiilerich <madski@unity3d.com>
parents: 4020
diff changeset
139 if (branch_name and
4a0bce848ed8 changelog: use unknown branch names as revisions
Mads Kiilerich <madski@unity3d.com>
parents: 4020
diff changeset
140 branch_name not in c.rhodecode_repo.branches and
4a0bce848ed8 changelog: use unknown branch names as revisions
Mads Kiilerich <madski@unity3d.com>
parents: 4020
diff changeset
141 branch_name not in c.rhodecode_repo.closed_branches and
4a0bce848ed8 changelog: use unknown branch names as revisions
Mads Kiilerich <madski@unity3d.com>
parents: 4020
diff changeset
142 not revision):
4a0bce848ed8 changelog: use unknown branch names as revisions
Mads Kiilerich <madski@unity3d.com>
parents: 4020
diff changeset
143 return redirect(url('changelog_file_home', repo_name=c.repo_name,
4a0bce848ed8 changelog: use unknown branch names as revisions
Mads Kiilerich <madski@unity3d.com>
parents: 4020
diff changeset
144 revision=branch_name, f_path=f_path or ''))
4a0bce848ed8 changelog: use unknown branch names as revisions
Mads Kiilerich <madski@unity3d.com>
parents: 4020
diff changeset
145
3760
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
146 c.changelog_for_path = f_path
1656
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
147 try:
3760
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
148
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
149 if f_path:
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
150 log.debug('generating changelog for path %s' % f_path)
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
151 # get the history for the file !
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
152 tip_cs = c.rhodecode_repo.get_changeset()
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
153 try:
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
154 collection = tip_cs.get_file_history(f_path)
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
155 except (NodeDoesNotExistError, ChangesetError):
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
156 #this node is not present at tip !
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
157 try:
4035
4627bc2dc8be fixed typo in __get_cs_or_redirect method
Marcin Kuzminski <marcin@python-works.com>
parents: 4022
diff changeset
158 cs = self.__get_cs_or_redirect(revision, repo_name)
3760
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
159 collection = cs.get_file_history(f_path)
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
160 except RepositoryError, e:
4077
0e1023147334 Use safe_str on flash messages.
Marcin Kuzminski <marcin@python-works.com>
parents: 4036
diff changeset
161 h.flash(safe_str(e), category='warning')
3760
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
162 redirect(h.url('changelog_home', repo_name=repo_name))
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
163 collection = list(reversed(collection))
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
164 else:
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
165 collection = c.rhodecode_repo.get_changesets(start=0,
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
166 branch_name=branch_name)
3747
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3573
diff changeset
167 c.total_cs = len(collection)
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
168
1656
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
169 c.pagination = RepoPage(collection, page=p, item_count=c.total_cs,
3915
a42bfe8a9335 moved make-index command to paster_commands module
Marcin Kuzminski <marcin@python-works.com>
parents: 3794
diff changeset
170 items_per_page=c.size, branch=branch_name,)
1884
0614862a20ec Added number of comments in changelog for each changeset
Marcin Kuzminski <marcin@python-works.com>
parents: 1864
diff changeset
171 collection = list(c.pagination)
3747
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3573
diff changeset
172 page_revisions = [x.raw_id for x in c.pagination]
2520
a1e156503afe Fixed calls to Session in db model
Marcin Kuzminski <marcin@python-works.com>
parents: 2391
diff changeset
173 c.comments = c.rhodecode_db_repo.get_comments(page_revisions)
2215
2c2bdaeca912 code-review initial
Marcin Kuzminski <marcin@python-works.com>
parents: 2204
diff changeset
174 c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
3794
222e9432298e in case of empty directory don't redirect to changelog, it causes an redirection loop
Marcin Kuzminski <marcin@python-works.com>
parents: 3764
diff changeset
175 except (EmptyRepositoryError), e:
4077
0e1023147334 Use safe_str on flash messages.
Marcin Kuzminski <marcin@python-works.com>
parents: 4036
diff changeset
176 h.flash(safe_str(e), category='warning')
3794
222e9432298e in case of empty directory don't redirect to changelog, it causes an redirection loop
Marcin Kuzminski <marcin@python-works.com>
parents: 3764
diff changeset
177 return redirect(url('summary_home', repo_name=c.repo_name))
1656
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
178 except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
179 log.error(traceback.format_exc())
4077
0e1023147334 Use safe_str on flash messages.
Marcin Kuzminski <marcin@python-works.com>
parents: 4036
diff changeset
180 h.flash(safe_str(e), category='error')
3573
881ae12b3c7d report ChangesetDoesNotExistError as an error but don't lose the repo context
Mads Kiilerich <madski@unity3d.com>
parents: 2845
diff changeset
181 return redirect(url('changelog_home', repo_name=c.repo_name))
1656
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
182
833f9dec0a06 implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
183 c.branch_name = branch_name
1884
0614862a20ec Added number of comments in changelog for each changeset
Marcin Kuzminski <marcin@python-works.com>
parents: 1864
diff changeset
184 c.branch_filters = [('', _('All Branches'))] + \
0614862a20ec Added number of comments in changelog for each changeset
Marcin Kuzminski <marcin@python-works.com>
parents: 1864
diff changeset
185 [(k, k) for k in c.rhodecode_repo.branches.keys()]
4020
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3996
diff changeset
186 if c.rhodecode_repo.closed_branches:
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3996
diff changeset
187 prefix = _('(closed)') + ' '
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3996
diff changeset
188 c.branch_filters += [('-', '-')] + \
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3996
diff changeset
189 [(k, prefix + k) for k in c.rhodecode_repo.closed_branches.keys()]
3760
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
190 _revs = []
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
191 if not f_path:
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
192 _revs = [x.revision for x in c.pagination]
6302a1423a4e Use changelog controller for displaying history of files.
Marcin Kuzminski <marcin@python-works.com>
parents: 3749
diff changeset
193 self._graph(c.rhodecode_repo, _revs, c.total_cs, c.size, p)
3747
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3573
diff changeset
194
142
f7218849798a Changeg graph to changelog, and changelog to shortlog
Marcin Kuzminski <marcin@python-works.com>
parents: 127
diff changeset
195 return render('changelog/changelog.html')
f7218849798a Changeg graph to changelog, and changelog to shortlog
Marcin Kuzminski <marcin@python-works.com>
parents: 127
diff changeset
196
3749
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
197 @LoginRequired()
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
198 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3748
diff changeset
199 'repository.admin')
1431
d5d7c40e8591 changelog uses lazy loading of affected files details, in some scenarios this can improve speed
Marcin Kuzminski <marcin@python-works.com>
parents: 1412
diff changeset
200 def changelog_details(self, cs):
d5d7c40e8591 changelog uses lazy loading of affected files details, in some scenarios this can improve speed
Marcin Kuzminski <marcin@python-works.com>
parents: 1412
diff changeset
201 if request.environ.get('HTTP_X_PARTIAL_XHR'):
d5d7c40e8591 changelog uses lazy loading of affected files details, in some scenarios this can improve speed
Marcin Kuzminski <marcin@python-works.com>
parents: 1412
diff changeset
202 c.cs = c.rhodecode_repo.get_changeset(cs)
d5d7c40e8591 changelog uses lazy loading of affected files details, in some scenarios this can improve speed
Marcin Kuzminski <marcin@python-works.com>
parents: 1412
diff changeset
203 return render('changelog/changelog_details.html')
3764
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
204 raise HTTPNotFound()
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
205
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
206 @LoginRequired()
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
207 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
208 'repository.admin')
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
209 def changelog_summary(self, repo_name):
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
210 if request.environ.get('HTTP_X_PARTIAL_XHR'):
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
211 _load_changelog_summary()
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
212
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
213 return render('changelog/changelog_summary_data.html')
c7970889c5c0 Removed shortlog aka lightweight changelog.
Marcin Kuzminski <marcin@python-works.com>
parents: 3760
diff changeset
214 raise HTTPNotFound()