Show More
@@ -67,13 +67,11 b' class ChangelogController(BaseRepoContro' | |||
|
67 | 67 | except EmptyRepositoryError: |
|
68 | 68 | if not redirect_after: |
|
69 | 69 | return None |
|
70 |
h.flash |
|
|
71 | category='warning') | |
|
70 | h.flash(_('There are no commits yet'), category='warning') | |
|
72 | 71 | redirect(url('changelog_home', repo_name=repo.repo_name)) |
|
73 | 72 | except RepositoryError as e: |
|
74 |
|
|
|
75 | log.exception(msg) | |
|
76 | h.flash(msg, category='warning') | |
|
73 | log.exception(safe_str(e)) | |
|
74 | h.flash(safe_str(h.escape(e)), category='warning') | |
|
77 | 75 | if not partial: |
|
78 | 76 | redirect(h.url('changelog_home', repo_name=repo.repo_name)) |
|
79 | 77 | raise HTTPBadRequest() |
@@ -113,7 +111,7 b' class ChangelogController(BaseRepoContro' | |||
|
113 | 111 | |
|
114 | 112 | def _check_if_valid_branch(self, branch_name, repo_name, f_path): |
|
115 | 113 | if branch_name not in c.rhodecode_repo.branches_all: |
|
116 | h.flash('Branch {} is not found.'.format(branch_name), | |
|
114 | h.flash('Branch {} is not found.'.format(h.escape(branch_name)), | |
|
117 | 115 | category='warning') |
|
118 | 116 | redirect(url('changelog_file_home', repo_name=repo_name, |
|
119 | 117 | revision=branch_name, f_path=f_path or '')) |
@@ -189,12 +187,11 b' class ChangelogController(BaseRepoContro' | |||
|
189 | 187 | collection, p, chunk_size, c.branch_name, dynamic=f_path) |
|
190 | 188 | |
|
191 | 189 | except EmptyRepositoryError as e: |
|
192 | h.flash(safe_str(e), category='warning') | |
|
190 | h.flash(safe_str(h.escape(e)), category='warning') | |
|
193 | 191 | return redirect(h.route_path('repo_summary', repo_name=repo_name)) |
|
194 | 192 | except (RepositoryError, CommitDoesNotExistError, Exception) as e: |
|
195 |
|
|
|
196 | log.exception(msg) | |
|
197 | h.flash(msg, category='error') | |
|
193 | log.exception(safe_str(e)) | |
|
194 | h.flash(safe_str(h.escape(e)), category='error') | |
|
198 | 195 | return redirect(url('changelog_home', repo_name=repo_name)) |
|
199 | 196 | |
|
200 | 197 | if (request.environ.get('HTTP_X_PARTIAL_XHR') |
@@ -24,7 +24,7 b' Compare controller for showing differenc' | |||
|
24 | 24 | |
|
25 | 25 | import logging |
|
26 | 26 | |
|
27 | from webob.exc import HTTPBadRequest | |
|
27 | from webob.exc import HTTPBadRequest, HTTPNotFound | |
|
28 | 28 | from pylons import request, tmpl_context as c, url |
|
29 | 29 | from pylons.controllers.util import redirect |
|
30 | 30 | from pylons.i18n.translation import _ |
@@ -66,9 +66,8 b' class CompareController(BaseRepoControll' | |||
|
66 | 66 | redirect(h.route_path('repo_summary', repo_name=repo.repo_name)) |
|
67 | 67 | |
|
68 | 68 | except RepositoryError as e: |
|
69 |
|
|
|
70 | log.exception(msg) | |
|
71 | h.flash(msg, category='warning') | |
|
69 | log.exception(safe_str(e)) | |
|
70 | h.flash(safe_str(h.escape(e)), category='warning') | |
|
72 | 71 | if not partial: |
|
73 | 72 | redirect(h.route_path('repo_summary', repo_name=repo.repo_name)) |
|
74 | 73 | raise HTTPBadRequest() |
@@ -86,6 +85,10 b' class CompareController(BaseRepoControll' | |||
|
86 | 85 | target_repo = request.GET.get('target_repo', source_repo) |
|
87 | 86 | c.source_repo = Repository.get_by_repo_name(source_repo) |
|
88 | 87 | c.target_repo = Repository.get_by_repo_name(target_repo) |
|
88 | ||
|
89 | if c.source_repo is None or c.target_repo is None: | |
|
90 | raise HTTPNotFound() | |
|
91 | ||
|
89 | 92 | c.source_ref = c.target_ref = _('Select commit') |
|
90 | 93 | c.source_ref_type = "" |
|
91 | 94 | c.target_ref_type = "" |
@@ -141,18 +144,17 b' class CompareController(BaseRepoControll' | |||
|
141 | 144 | target_repo = Repository.get_by_repo_name(target_repo_name) |
|
142 | 145 | |
|
143 | 146 | if source_repo is None: |
|
144 |
|
|
|
145 |
|
|
|
146 | ||
|
147 | log.error(msg) | |
|
148 | h.flash(msg, category='error') | |
|
147 | log.error('Could not find the source repo: {}' | |
|
148 | .format(source_repo_name)) | |
|
149 | h.flash(_('Could not find the source repo: `{}`') | |
|
150 | .format(h.escape(source_repo_name)), category='error') | |
|
149 | 151 | return redirect(url('compare_home', repo_name=c.repo_name)) |
|
150 | 152 | |
|
151 | 153 | if target_repo is None: |
|
152 |
|
|
|
153 |
|
|
|
154 | log.error(msg) | |
|
155 |
h. |
|
|
154 | log.error('Could not find the target repo: {}' | |
|
155 | .format(source_repo_name)) | |
|
156 | h.flash(_('Could not find the target repo: `{}`') | |
|
157 | .format(h.escape(target_repo_name)), category='error') | |
|
156 | 158 | return redirect(url('compare_home', repo_name=c.repo_name)) |
|
157 | 159 | |
|
158 | 160 | source_scm = source_repo.scm_instance() |
@@ -107,7 +107,7 b' class FilesController(BaseRepoController' | |||
|
107 | 107 | h.flash(msg, category='error') |
|
108 | 108 | raise HTTPNotFound() |
|
109 | 109 | except RepositoryError as e: |
|
110 | h.flash(safe_str(e), category='error') | |
|
110 | h.flash(safe_str(h.escape(e)), category='error') | |
|
111 | 111 | raise HTTPNotFound() |
|
112 | 112 | |
|
113 | 113 | def __get_filenode_or_redirect(self, repo_name, commit, path): |
@@ -128,7 +128,7 b' class FilesController(BaseRepoController' | |||
|
128 | 128 | h.flash(_('No such commit exists for this repository'), category='error') |
|
129 | 129 | raise HTTPNotFound() |
|
130 | 130 | except RepositoryError as e: |
|
131 | h.flash(safe_str(e), category='error') | |
|
131 | h.flash(safe_str(h.escape(e)), category='error') | |
|
132 | 132 | raise HTTPNotFound() |
|
133 | 133 | |
|
134 | 134 | return file_node |
@@ -256,7 +256,7 b' class FilesController(BaseRepoController' | |||
|
256 | 256 | repo_name, c.commit.raw_id, f_path) |
|
257 | 257 | |
|
258 | 258 | except RepositoryError as e: |
|
259 | h.flash(safe_str(e), category='error') | |
|
259 | h.flash(safe_str(h.escape(e)), category='error') | |
|
260 | 260 | raise HTTPNotFound() |
|
261 | 261 | |
|
262 | 262 | if request.environ.get('HTTP_X_PJAX'): |
@@ -472,9 +472,8 b' class FilesController(BaseRepoController' | |||
|
472 | 472 | _('Successfully deleted file `{}`').format( |
|
473 | 473 | h.escape(f_path)), category='success') |
|
474 | 474 | except Exception: |
|
475 |
|
|
|
476 | log.exception(msg) | |
|
477 | h.flash(msg, category='error') | |
|
475 | log.exception('Error during commit operation') | |
|
476 | h.flash(_('Error occurred during commit'), category='error') | |
|
478 | 477 | return redirect(url('changeset_home', |
|
479 | 478 | repo_name=c.repo_name, revision='tip')) |
|
480 | 479 |
@@ -1066,7 +1066,7 b' class BaseCommit(object):' | |||
|
1066 | 1066 | def no_node_at_path(self, path): |
|
1067 | 1067 | return NodeDoesNotExistError( |
|
1068 | 1068 | u"There is no file nor directory at the given path: " |
|
1069 |
u" |
|
|
1069 | u"`%s` at commit %s" % (safe_unicode(path), self.short_id)) | |
|
1070 | 1070 | |
|
1071 | 1071 | def _fix_path(self, path): |
|
1072 | 1072 | """ |
@@ -489,7 +489,22 b' class TestCompareController(object):' | |||
|
489 | 489 | compare_page = ComparePage(response) |
|
490 | 490 | compare_page.contains_commits(commits=[commit1], ancestors=[commit0]) |
|
491 | 491 | |
|
492 | def test_errors_when_comparing_unknown_repo(self, backend): | |
|
492 | def test_errors_when_comparing_unknown_source_repo(self, backend): | |
|
493 | repo = backend.repo | |
|
494 | badrepo = 'badrepo' | |
|
495 | ||
|
496 | response = self.app.get( | |
|
497 | url('compare_url', | |
|
498 | repo_name=badrepo, | |
|
499 | source_ref_type="rev", | |
|
500 | source_ref='tip', | |
|
501 | target_ref_type="rev", | |
|
502 | target_ref='tip', | |
|
503 | target_repo=repo.repo_name, | |
|
504 | merge='1',), | |
|
505 | status=404) | |
|
506 | ||
|
507 | def test_errors_when_comparing_unknown_target_repo(self, backend): | |
|
493 | 508 | repo = backend.repo |
|
494 | 509 | badrepo = 'badrepo' |
|
495 | 510 | |
@@ -504,7 +519,8 b' class TestCompareController(object):' | |||
|
504 | 519 | merge='1',), |
|
505 | 520 | status=302) |
|
506 | 521 | redirected = response.follow() |
|
507 | redirected.mustcontain('Could not find the other repo: %s' % badrepo) | |
|
522 | redirected.mustcontain( | |
|
523 | 'Could not find the target repo: `{}`'.format(badrepo)) | |
|
508 | 524 | |
|
509 | 525 | def test_compare_not_in_preview_mode(self, backend_stub): |
|
510 | 526 | commit0 = backend_stub.repo.get_commit(commit_idx=0) |
@@ -484,7 +484,7 b' class TestRawFileHandling(object):' | |||
|
484 | 484 | |
|
485 | 485 | msg = ( |
|
486 | 486 | "There is no file nor directory at the given path: " |
|
487 |
" |
|
|
487 | "`%s` at commit %s" % (f_path, commit.short_id)) | |
|
488 | 488 | response.mustcontain(msg) |
|
489 | 489 | |
|
490 | 490 | def test_raw_ok(self, backend): |
@@ -517,7 +517,7 b' class TestRawFileHandling(object):' | |||
|
517 | 517 | f_path=f_path), status=404) |
|
518 | 518 | msg = ( |
|
519 | 519 | "There is no file nor directory at the given path: " |
|
520 |
" |
|
|
520 | "`%s` at commit %s" % (f_path, commit.short_id)) | |
|
521 | 521 | response.mustcontain(msg) |
|
522 | 522 | |
|
523 | 523 | def test_raw_svg_should_not_be_rendered(self, backend): |
General Comments 0
You need to be logged in to leave comments.
Login now