##// END OF EJS Templates
Add check for existing revisions in compare view
marcink -
r2593:16a6a2f5 beta
parent child Browse files
Show More
@@ -29,7 +29,9 b' import traceback'
29 from webob.exc import HTTPNotFound
29 from webob.exc import HTTPNotFound
30 from pylons import request, response, session, tmpl_context as c, url
30 from pylons import request, response, session, tmpl_context as c, url
31 from pylons.controllers.util import abort, redirect
31 from pylons.controllers.util import abort, redirect
32 from pylons.i18n.translation import _
32
33
34 from rhodecode.lib.vcs.exceptions import EmptyRepositoryError, RepositoryError
33 from rhodecode.lib import helpers as h
35 from rhodecode.lib import helpers as h
34 from rhodecode.lib.base import BaseRepoController, render
36 from rhodecode.lib.base import BaseRepoController, render
35 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
37 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
@@ -49,6 +51,29 b' class CompareController(BaseRepoControll'
49 def __before__(self):
51 def __before__(self):
50 super(CompareController, self).__before__()
52 super(CompareController, self).__before__()
51
53
54 def __get_cs_or_redirect(self, rev, repo, redirect_after=True):
55 """
56 Safe way to get changeset if error occur it redirects to changeset with
57 proper message
58
59 :param rev: revision to fetch
60 :param repo: repo instance
61 """
62
63 try:
64 type_, rev = rev
65 return repo.scm_instance.get_changeset(rev)
66 except EmptyRepositoryError, e:
67 if not redirect_after:
68 return None
69 h.flash(h.literal(_('There are no changesets yet')),
70 category='warning')
71 redirect(url('summary_home', repo_name=repo.repo_name))
72
73 except RepositoryError, e:
74 h.flash(str(e), category='warning')
75 redirect(h.url('summary_home', repo_name=repo.repo_name))
76
52 def index(self, org_ref_type, org_ref, other_ref_type, other_ref):
77 def index(self, org_ref_type, org_ref, other_ref_type, other_ref):
53
78
54 org_repo = c.rhodecode_db_repo.repo_name
79 org_repo = c.rhodecode_db_repo.repo_name
@@ -72,6 +97,9 b' class CompareController(BaseRepoControll'
72 log.error('Review not available for GIT REPOS')
97 log.error('Review not available for GIT REPOS')
73 raise HTTPNotFound
98 raise HTTPNotFound
74
99
100 self.__get_cs_or_redirect(rev=org_ref, repo=org_repo)
101 self.__get_cs_or_redirect(rev=other_ref, repo=other_repo)
102
75 c.cs_ranges, discovery_data = PullRequestModel().get_compare_data(
103 c.cs_ranges, discovery_data = PullRequestModel().get_compare_data(
76 org_repo, org_ref, other_repo, other_ref
104 org_repo, org_ref, other_repo, other_ref
77 )
105 )
General Comments 0
You need to be logged in to leave comments. Login now