Mercurial > kallithea
annotate rhodecode/controllers/shortlog.py @ 3179:cd50d1b5f35b
merged with beta
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 21 Jan 2013 00:03:44 +0100 |
parents | a5f0bc867edc |
children | 7efc8dcc0dc4 |
rev | line source |
---|---|
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
1 # -*- coding: utf-8 -*- |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
2 """ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
3 rhodecode.controllers.shortlog |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
5 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
6 Shortlog controller for rhodecode |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1098
diff
changeset
|
7 |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
8 :created_on: Apr 18, 2010 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
9 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1736
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
12 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
13 # 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
|
14 # 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
|
15 # 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
|
16 # (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:
1098
diff
changeset
|
17 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
18 # 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
|
19 # 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
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
21 # 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:
1098
diff
changeset
|
22 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
23 # 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
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
25 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
26 import logging |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
27 |
1249
13b507b73190
fixes issue #166, made clone-uri use the pylons build in url generators, that way it's more safe.
Marcin Kuzminski <marcin@python-works.com>
parents:
1212
diff
changeset
|
28 from pylons import tmpl_context as c, request, url |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
29 from pylons.i18n.translation import _ |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
30 |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
31 from rhodecode.lib import helpers as h |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
32 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1038
diff
changeset
|
33 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:
1045
diff
changeset
|
34 from rhodecode.lib.helpers import RepoPage |
1736
e2d76554d2c6
added quickstart page for new repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
35 from pylons.controllers.util import redirect |
2845
6b176c679896
failsafe the GET `page` argument
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
36 from rhodecode.lib.utils2 import safe_int |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
37 from rhodecode.lib.vcs.exceptions import NodeDoesNotExistError, ChangesetError,\ |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
38 RepositoryError |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
39 |
83
db39d0ca5308
implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
40 log = logging.getLogger(__name__) |
db39d0ca5308
implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
41 |
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:
1045
diff
changeset
|
42 |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1038
diff
changeset
|
43 class ShortlogController(BaseRepoController): |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
44 |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
127
diff
changeset
|
45 @LoginRequired() |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
46 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
47 'repository.admin') |
83
db39d0ca5308
implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
48 def __before__(self): |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
127
diff
changeset
|
49 super(ShortlogController, self).__before__() |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
50 |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
51 def __get_cs_or_redirect(self, rev, repo_name, redirect_after=True): |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
52 """ |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
53 Safe way to get changeset if error occur it redirects to tip with |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
54 proper message |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
55 |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
56 :param rev: revision to fetch |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
57 :param repo_name: repo name to redirect after |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
58 """ |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
59 |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
60 try: |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
61 return c.rhodecode_repo.get_changeset(rev) |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
62 except RepositoryError, e: |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
63 h.flash(str(e), category='warning') |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
64 redirect(h.url('shortlog_home', repo_name=repo_name)) |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
65 |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
66 def index(self, repo_name, revision=None, f_path=None): |
2845
6b176c679896
failsafe the GET `page` argument
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
67 p = safe_int(request.params.get('page', 1), 1) |
6b176c679896
failsafe the GET `page` argument
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
68 size = safe_int(request.params.get('size', 20), 20) |
3041
a41f0f978185
fixed pager link for file history page
Marcin Kuzminski <marcin@python-works.com>
parents:
3040
diff
changeset
|
69 collection = c.rhodecode_repo |
a41f0f978185
fixed pager link for file history page
Marcin Kuzminski <marcin@python-works.com>
parents:
3040
diff
changeset
|
70 c.file_history = f_path |
1249
13b507b73190
fixes issue #166, made clone-uri use the pylons build in url generators, that way it's more safe.
Marcin Kuzminski <marcin@python-works.com>
parents:
1212
diff
changeset
|
71 |
13b507b73190
fixes issue #166, made clone-uri use the pylons build in url generators, that way it's more safe.
Marcin Kuzminski <marcin@python-works.com>
parents:
1212
diff
changeset
|
72 def url_generator(**kw): |
3041
a41f0f978185
fixed pager link for file history page
Marcin Kuzminski <marcin@python-works.com>
parents:
3040
diff
changeset
|
73 if f_path: |
a41f0f978185
fixed pager link for file history page
Marcin Kuzminski <marcin@python-works.com>
parents:
3040
diff
changeset
|
74 return url('shortlog_file_home', repo_name=repo_name, |
a41f0f978185
fixed pager link for file history page
Marcin Kuzminski <marcin@python-works.com>
parents:
3040
diff
changeset
|
75 revision=revision, f_path=f_path, size=size, **kw) |
1249
13b507b73190
fixes issue #166, made clone-uri use the pylons build in url generators, that way it's more safe.
Marcin Kuzminski <marcin@python-works.com>
parents:
1212
diff
changeset
|
76 return url('shortlog_home', repo_name=repo_name, size=size, **kw) |
3042
303878dc3dac
fix shortlog status generation, just fetch for page, not whole set !
Marcin Kuzminski <marcin@python-works.com>
parents:
3041
diff
changeset
|
77 |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
78 if f_path: |
3042
303878dc3dac
fix shortlog status generation, just fetch for page, not whole set !
Marcin Kuzminski <marcin@python-works.com>
parents:
3041
diff
changeset
|
79 log.debug('generating shortlog for path %s' % f_path) |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
80 # get the history for the file ! |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
81 tip_cs = c.rhodecode_repo.get_changeset() |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
82 try: |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
83 collection = tip_cs.get_file_history(f_path) |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
84 except (NodeDoesNotExistError, ChangesetError): |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
85 #this node is not present at tip ! |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
86 try: |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
87 cs = self.__get_cs_or_redirect(revision, repo_name) |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
88 collection = cs.get_file_history(f_path) |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
89 except RepositoryError, e: |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
90 h.flash(str(e), category='warning') |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
91 redirect(h.url('shortlog_home', repo_name=repo_name)) |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
92 collection = list(reversed(collection)) |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
93 |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
94 c.repo_changesets = RepoPage(collection, page=p, |
3042
303878dc3dac
fix shortlog status generation, just fetch for page, not whole set !
Marcin Kuzminski <marcin@python-works.com>
parents:
3041
diff
changeset
|
95 items_per_page=size, url=url_generator) |
303878dc3dac
fix shortlog status generation, just fetch for page, not whole set !
Marcin Kuzminski <marcin@python-works.com>
parents:
3041
diff
changeset
|
96 page_revisions = [x.raw_id for x in list(c.repo_changesets)] |
2884
a16f9a76c26f
#574 Show pull request status also in shortlog (if any)
Marcin Kuzminski <marcin@python-works.com>
parents:
2845
diff
changeset
|
97 c.statuses = c.rhodecode_db_repo.statuses(page_revisions) |
1736
e2d76554d2c6
added quickstart page for new repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
98 |
e2d76554d2c6
added quickstart page for new repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
99 if not c.repo_changesets: |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
2884
diff
changeset
|
100 h.flash(_('There are no changesets yet'), category='warning') |
1736
e2d76554d2c6
added quickstart page for new repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
101 return redirect(url('summary_home', repo_name=repo_name)) |
e2d76554d2c6
added quickstart page for new repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
102 |
127
20dc7a5eb748
Html changes and cleanups, made folders for html templates, implemented tags and branches pages
Marcin Kuzminski <marcin@python-works.com>
parents:
101
diff
changeset
|
103 c.shortlog_data = render('shortlog/shortlog_data.html') |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
1249
diff
changeset
|
104 if request.environ.get('HTTP_X_PARTIAL_XHR'): |
83
db39d0ca5308
implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
105 return c.shortlog_data |
127
20dc7a5eb748
Html changes and cleanups, made folders for html templates, implemented tags and branches pages
Marcin Kuzminski <marcin@python-works.com>
parents:
101
diff
changeset
|
106 r = render('shortlog/shortlog.html') |
86
e47d1db5ef20
Added few options to configs,
Marcin Kuzminski <marcin@python-blog.com>
parents:
83
diff
changeset
|
107 return r |