Show More
@@ -56,9 +56,11 b' class FilesController(BaseRepoController' | |||
|
56 | 56 | super(FilesController, self).__before__() |
|
57 | 57 | c.cut_off_limit = self.cut_off_limit |
|
58 | 58 | |
|
59 | def __get_cs(self, rev, repo_name): | |
|
59 | def __get_cs_or_redirect(self, rev, repo_name): | |
|
60 | 60 | """ |
|
61 |
Safe way to get changeset if error |
|
|
61 | Safe way to get changeset if error occur it redirects to tip with | |
|
62 | proper message | |
|
63 | ||
|
62 | 64 | :param rev: revision to fetch |
|
63 | 65 | :param repo_name: repo name to redirect after |
|
64 | 66 | """ |
@@ -74,27 +76,25 b' class FilesController(BaseRepoController' | |||
|
74 | 76 | redirect(h.url('files_home', repo_name=repo_name, revision='tip')) |
|
75 | 77 | |
|
76 | 78 | def index(self, repo_name, revision, f_path): |
|
77 | ||
|
78 | try: | |
|
79 | #reditect to given revision from form | |
|
79 | #reditect to given revision from form if given | |
|
80 | 80 |
|
|
81 | 81 |
|
|
82 | post_revision = c.rhodecode_repo.get_changeset(post_revision).raw_id | |
|
82 | cs = self.__get_cs_or_redirect(revision, repo_name) | |
|
83 | 83 |
|
|
84 |
|
|
|
84 | revision=cs.raw_id, f_path=f_path)) | |
|
85 | ||
|
85 | 86 | |
|
87 | c.changeset = self.__get_cs_or_redirect(revision, repo_name) | |
|
86 | 88 |
|
|
87 | ||
|
88 | 89 |
|
|
89 | 90 | |
|
90 | c.changeset = c.rhodecode_repo.get_changeset(revision) | |
|
91 | 91 |
|
|
92 | 92 | |
|
93 | 93 |
|
|
94 | 94 |
|
|
95 |
|
|
|
95 | prev_rev = c.rhodecode_repo.get_changeset(cur_rev).prev(c.branch) | |
|
96 | 96 |
|
|
97 |
|
|
|
97 | revision=prev_rev.raw_id, f_path=f_path) | |
|
98 | 98 |
|
|
99 | 99 |
|
|
100 | 100 |
|
@@ -102,9 +102,9 b' class FilesController(BaseRepoController' | |||
|
102 | 102 | |
|
103 | 103 |
|
|
104 | 104 |
|
|
105 |
|
|
|
105 | next_rev = c.rhodecode_repo.get_changeset(cur_rev).next(c.branch) | |
|
106 | 106 |
|
|
107 |
|
|
|
107 | revision=next_rev.raw_id, f_path=f_path) | |
|
108 | 108 |
|
|
109 | 109 |
|
|
110 | 110 |
|
@@ -113,30 +113,24 b' class FilesController(BaseRepoController' | |||
|
113 | 113 |
|
|
114 | 114 |
|
|
115 | 115 |
|
|
116 |
|
|
|
116 | c.file_history = self._get_history(c.rhodecode_repo, | |
|
117 | c.files_list, f_path) | |
|
117 | 118 |
|
|
118 | 119 |
|
|
119 |
|
|
|
120 | ||
|
121 | except EmptyRepositoryError, e: | |
|
122 | h.flash(_('There are no files yet'), category='warning') | |
|
123 | redirect(h.url('summary_home', repo_name=repo_name)) | |
|
124 | ||
|
125 | except RepositoryError, e: | |
|
126 | h.flash(str(e), category='warning') | |
|
127 | redirect(h.url('files_home', repo_name=repo_name, revision='tip')) | |
|
128 | ||
|
120 | redirect(h.url('files_home', repo_name=repo_name, | |
|
121 | revision=revision)) | |
|
129 | 122 | |
|
130 | 123 | |
|
131 | 124 | return render('files/files.html') |
|
132 | 125 | |
|
133 | 126 | def rawfile(self, repo_name, revision, f_path): |
|
134 | cs = self.__get_cs(revision, repo_name) | |
|
127 | cs = self.__get_cs_or_redirect(revision, repo_name) | |
|
135 | 128 | try: |
|
136 | 129 | file_node = cs.get_node(f_path) |
|
137 | 130 | except RepositoryError, e: |
|
138 | 131 | h.flash(str(e), category='warning') |
|
139 |
redirect(h.url('files_home', repo_name=repo_name, |
|
|
132 | redirect(h.url('files_home', repo_name=repo_name, | |
|
133 | revision=cs.raw_id)) | |
|
140 | 134 | |
|
141 | 135 | fname = f_path.split('/')[-1].encode('utf8', 'replace') |
|
142 | 136 | response.content_type = file_node.mimetype |
@@ -144,26 +138,29 b' class FilesController(BaseRepoController' | |||
|
144 | 138 | return file_node.content |
|
145 | 139 | |
|
146 | 140 | def raw(self, repo_name, revision, f_path): |
|
147 | cs = self.__get_cs(revision, repo_name) | |
|
141 | cs = self.__get_cs_or_redirect(revision, repo_name) | |
|
148 | 142 | try: |
|
149 | 143 | file_node = cs.get_node(f_path) |
|
150 | 144 | except RepositoryError, e: |
|
151 | 145 | h.flash(str(e), category='warning') |
|
152 |
redirect(h.url('files_home', repo_name=repo_name, |
|
|
146 | redirect(h.url('files_home', repo_name=repo_name, | |
|
147 | revision=cs.raw_id)) | |
|
153 | 148 | |
|
154 | 149 | response.content_type = 'text/plain' |
|
155 | 150 | |
|
156 | 151 | return file_node.content |
|
157 | 152 | |
|
158 | 153 | def annotate(self, repo_name, revision, f_path): |
|
159 | cs = self.__get_cs(revision, repo_name) | |
|
154 | cs = self.__get_cs_or_redirect(revision, repo_name) | |
|
160 | 155 | try: |
|
161 | 156 | c.file = cs.get_node(f_path) |
|
162 | 157 | except RepositoryError, e: |
|
163 | 158 | h.flash(str(e), category='warning') |
|
164 |
redirect(h.url('files_home', repo_name=repo_name, |
|
|
159 | redirect(h.url('files_home', repo_name=repo_name, | |
|
160 | revision=cs.raw_id)) | |
|
165 | 161 | |
|
166 |
c.file_history = self._get_history(c.rhodecode_repo, |
|
|
162 | c.file_history = self._get_history(c.rhodecode_repo, | |
|
163 | c.file, f_path) | |
|
167 | 164 | c.cs = cs |
|
168 | 165 | c.f_path = f_path |
|
169 | 166 |
General Comments 0
You need to be logged in to leave comments.
Login now