Files
@ a520d542697e
Branch filter:
Location: kallithea/rhodecode/controllers/shortlog.py - annotation
a520d542697e
3.9 KiB
text/x-python
Implemented file history page for showing detailed changelog for a given file
- fixed git detection of filenode history when executed on directory
- shortlog uses urlify_commit function now
- fixed git detection of filenode history when executed on directory
- shortlog uses urlify_commit function now
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | fd2ea6ceadc8 fd2ea6ceadc8 fd2ea6ceadc8 fd2ea6ceadc8 fd2ea6ceadc8 fd2ea6ceadc8 6832ef664673 fd2ea6ceadc8 fd2ea6ceadc8 89efedac4e6c fd2ea6ceadc8 fd2ea6ceadc8 a671db5bdd58 a671db5bdd58 a671db5bdd58 a671db5bdd58 6832ef664673 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 6832ef664673 1e757ac98988 a671db5bdd58 fd2ea6ceadc8 fd2ea6ceadc8 fd2ea6ceadc8 13b507b73190 a520d542697e fd2ea6ceadc8 a520d542697e 1e757ac98988 3fc9183e05dd 91ddd4db4614 e2d76554d2c6 6b176c679896 a520d542697e a520d542697e fd2ea6ceadc8 1e757ac98988 1e757ac98988 91ddd4db4614 3fc9183e05dd fd2ea6ceadc8 1e757ac98988 1e757ac98988 fd2ea6ceadc8 1e757ac98988 1e757ac98988 fd2ea6ceadc8 a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e 6b176c679896 6b176c679896 13b507b73190 13b507b73190 13b507b73190 13b507b73190 a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e a520d542697e 833f9dec0a06 a520d542697e a16f9a76c26f e2d76554d2c6 e2d76554d2c6 a520d542697e e2d76554d2c6 e2d76554d2c6 1e757ac98988 c6b811f11c94 1e757ac98988 1e757ac98988 1e757ac98988 | # -*- coding: utf-8 -*-
"""
rhodecode.controllers.shortlog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shortlog controller for rhodecode
:created_on: Apr 18, 2010
:author: marcink
:copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
:license: GPLv3, see COPYING for more details.
"""
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
from pylons import tmpl_context as c, request, url
from pylons.i18n.translation import _
from rhodecode.lib import helpers as h
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
from rhodecode.lib.base import BaseRepoController, render
from rhodecode.lib.helpers import RepoPage
from pylons.controllers.util import redirect
from rhodecode.lib.utils2 import safe_int
from rhodecode.lib.vcs.exceptions import NodeDoesNotExistError, ChangesetError,\
RepositoryError
log = logging.getLogger(__name__)
class ShortlogController(BaseRepoController):
@LoginRequired()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
def __before__(self):
super(ShortlogController, self).__before__()
def __get_cs_or_redirect(self, rev, repo_name, redirect_after=True):
"""
Safe way to get changeset if error occur it redirects to tip with
proper message
:param rev: revision to fetch
:param repo_name: repo name to redirect after
"""
try:
return c.rhodecode_repo.get_changeset(rev)
except RepositoryError, e:
h.flash(str(e), category='warning')
redirect(h.url('shortlog_home', repo_name=repo_name))
def index(self, repo_name, revision=None, f_path=None):
p = safe_int(request.params.get('page', 1), 1)
size = safe_int(request.params.get('size', 20), 20)
def url_generator(**kw):
return url('shortlog_home', repo_name=repo_name, size=size, **kw)
collection = c.rhodecode_repo
c.file_history = f_path
if f_path:
f_path = f_path.lstrip('/')
# get the history for the file !
tip_cs = c.rhodecode_repo.get_changeset()
try:
collection = tip_cs.get_file_history(f_path)
except (NodeDoesNotExistError, ChangesetError):
#this node is not present at tip !
try:
cs = self.__get_cs_or_redirect(revision, repo_name)
collection = cs.get_file_history(f_path)
except RepositoryError, e:
h.flash(str(e), category='warning')
redirect(h.url('shortlog_home', repo_name=repo_name))
collection = list(reversed(collection))
c.repo_changesets = RepoPage(collection, page=p,
items_per_page=size, url=url_generator)
page_revisions = [x.raw_id for x in list(collection)]
c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
if not c.repo_changesets:
h.flash(_('There are no changesets yet'), category='warning')
return redirect(url('summary_home', repo_name=repo_name))
c.shortlog_data = render('shortlog/shortlog_data.html')
if request.environ.get('HTTP_X_PARTIAL_XHR'):
return c.shortlog_data
r = render('shortlog/shortlog.html')
return r
|