##// END OF EJS Templates
Added missing __get_cs_or_redirect method for file history....
marcink -
r3996:267bb347 default
parent child Browse files
Show More
@@ -29,6 +29,7 b' import traceback'
29 from pylons import request, url, session, tmpl_context as c
29 from pylons import request, url, session, tmpl_context as c
30 from pylons.controllers.util import redirect
30 from pylons.controllers.util import redirect
31 from pylons.i18n.translation import _
31 from pylons.i18n.translation import _
32 from webob.exc import HTTPNotFound, HTTPBadRequest
32
33
33 import rhodecode.lib.helpers as h
34 import rhodecode.lib.helpers as h
34 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
35 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
@@ -39,7 +40,7 b' from rhodecode.lib.graphmod import _colo'
39 from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError,\
40 from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError,\
40 ChangesetError, NodeDoesNotExistError, EmptyRepositoryError
41 ChangesetError, NodeDoesNotExistError, EmptyRepositoryError
41 from rhodecode.lib.utils2 import safe_int
42 from rhodecode.lib.utils2 import safe_int
42 from webob.exc import HTTPNotFound
43
43
44
44 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
45
46
@@ -68,6 +69,33 b' class ChangelogController(BaseRepoContro'
68 super(ChangelogController, self).__before__()
69 super(ChangelogController, self).__before__()
69 c.affected_files_cut_off = 60
70 c.affected_files_cut_off = 60
70
71
72 def __get_cs_or_redirect(self, rev, repo, redirect_after=True,
73 partial=False):
74 """
75 Safe way to get changeset if error occur it redirects to changeset with
76 proper message. If partial is set then don't do redirect raise Exception
77 instead
78
79 :param rev: revision to fetch
80 :param repo: repo instance
81 """
82
83 try:
84 return c.rhodecode_repo.get_changeset(rev)
85 except EmptyRepositoryError, e:
86 if not redirect_after:
87 return None
88 h.flash(h.literal(_('There are no changesets yet')),
89 category='warning')
90 redirect(url('changelog_home', repo_name=repo.repo_name))
91
92 except RepositoryError, e:
93 log.error(traceback.format_exc())
94 h.flash(str(e), category='warning')
95 if not partial:
96 redirect(h.url('changelog_home', repo_name=repo.repo_name))
97 raise HTTPBadRequest()
98
71 def _graph(self, repo, revs_int, repo_size, size, p):
99 def _graph(self, repo, revs_int, repo_size, size, p):
72 """
100 """
73 Generates a DAG graph for repo
101 Generates a DAG graph for repo
@@ -120,7 +148,7 b' class ChangelogController(BaseRepoContro'
120 except (NodeDoesNotExistError, ChangesetError):
148 except (NodeDoesNotExistError, ChangesetError):
121 #this node is not present at tip !
149 #this node is not present at tip !
122 try:
150 try:
123 cs = self.__get_cs_or_redirect(revision, repo_name)
151 cs = self.__get_css_or_redirect(revision, repo_name)
124 collection = cs.get_file_history(f_path)
152 collection = cs.get_file_history(f_path)
125 except RepositoryError, e:
153 except RepositoryError, e:
126 h.flash(str(e), category='warning')
154 h.flash(str(e), category='warning')
General Comments 0
You need to be logged in to leave comments. Login now