Show More
@@ -245,7 +245,7 b' class RepoFilesView(RepoAppView):' | |||
|
245 | 245 | |
|
246 | 246 | return branch_name, sha_commit_id, is_head |
|
247 | 247 | |
|
248 | def _get_tree_at_commit(self, c, commit_id, f_path, full_load=False): | |
|
248 | def _get_tree_at_commit(self, c, commit_id, f_path, full_load=False, at_rev=None): | |
|
249 | 249 | |
|
250 | 250 | repo_id = self.db_repo.repo_id |
|
251 | 251 | force_recache = self.get_recache_flag() |
@@ -263,17 +263,18 b' class RepoFilesView(RepoAppView):' | |||
|
263 | 263 | |
|
264 | 264 | @region.conditional_cache_on_arguments(namespace=cache_namespace_uid, |
|
265 | 265 | condition=cache_on) |
|
266 | def compute_file_tree(ver, repo_id, commit_id, f_path, full_load): | |
|
266 | def compute_file_tree(ver, repo_id, commit_id, f_path, full_load, at_rev): | |
|
267 | 267 | log.debug('Generating cached file tree at ver:%s for repo_id: %s, %s, %s', |
|
268 | 268 | ver, repo_id, commit_id, f_path) |
|
269 | 269 | |
|
270 | 270 | c.full_load = full_load |
|
271 | 271 | return render( |
|
272 | 272 | 'rhodecode:templates/files/files_browser_tree.mako', |
|
273 | self._get_template_context(c), self.request) | |
|
273 | self._get_template_context(c), self.request, at_rev) | |
|
274 | 274 | |
|
275 | 275 | return compute_file_tree( |
|
276 |
rc_cache.FILE_TREE_CACHE_VER, self.db_repo.repo_id, commit_id, |
|
|
276 | rc_cache.FILE_TREE_CACHE_VER, self.db_repo.repo_id, commit_id, | |
|
277 | f_path, full_load, at_rev) | |
|
277 | 278 | |
|
278 | 279 | def _get_archive_spec(self, fname): |
|
279 | 280 | log.debug('Detecting archive spec for: `%s`', fname) |
@@ -617,15 +618,12 b' class RepoFilesView(RepoAppView):' | |||
|
617 | 618 | c.renderer = view_name == 'repo_files:rendered' or \ |
|
618 | 619 | not self.request.GET.get('no-render', False) |
|
619 | 620 | |
|
620 | # redirect to given commit_id from form if given | |
|
621 | get_commit_id = self.request.GET.get('at_rev', None) | |
|
622 | if get_commit_id: | |
|
623 | self._get_commit_or_redirect(get_commit_id) | |
|
621 | commit_id, f_path = self._get_commit_and_path() | |
|
624 | 622 | |
|
625 | commit_id, f_path = self._get_commit_and_path() | |
|
626 | 623 | c.commit = self._get_commit_or_redirect(commit_id) |
|
627 | 624 | c.branch = self.request.GET.get('branch', None) |
|
628 | 625 | c.f_path = f_path |
|
626 | at_rev = self.request.GET.get('at') | |
|
629 | 627 | |
|
630 | 628 | # prev link |
|
631 | 629 | try: |
@@ -705,7 +703,7 b' class RepoFilesView(RepoAppView):' | |||
|
705 | 703 | c.authors = [] |
|
706 | 704 | # this loads a simple tree without metadata to speed things up |
|
707 | 705 | # later via ajax we call repo_nodetree_full and fetch whole |
|
708 | c.file_tree = self._get_tree_at_commit(c, c.commit.raw_id, f_path) | |
|
706 | c.file_tree = self._get_tree_at_commit(c, c.commit.raw_id, f_path, at_rev=at_rev) | |
|
709 | 707 | |
|
710 | 708 | c.readme_data, c.readme_file = \ |
|
711 | 709 | self._get_readme_data(self.db_repo, c.visual.default_renderer, |
@@ -782,9 +780,10 b' class RepoFilesView(RepoAppView):' | |||
|
782 | 780 | |
|
783 | 781 | c.file = dir_node |
|
784 | 782 | c.commit = commit |
|
783 | at_rev = self.request.GET.get('at') | |
|
785 | 784 | |
|
786 | 785 | html = self._get_tree_at_commit( |
|
787 | c, commit.raw_id, dir_node.path, full_load=True) | |
|
786 | c, commit.raw_id, dir_node.path, full_load=True, at_rev=at_rev) | |
|
788 | 787 | |
|
789 | 788 | return Response(html) |
|
790 | 789 | |
@@ -1038,10 +1037,24 b' class RepoFilesView(RepoAppView):' | |||
|
1038 | 1037 | file_history, _hist = self._get_node_history(commit, f_path) |
|
1039 | 1038 | |
|
1040 | 1039 | res = [] |
|
1041 |
for |
|
|
1040 | for section_items, section in file_history: | |
|
1041 | items = [] | |
|
1042 | for obj_id, obj_text, obj_type in section_items: | |
|
1043 | at_rev = '' | |
|
1044 | if obj_type in ['branch', 'bookmark', 'tag']: | |
|
1045 | at_rev = obj_text | |
|
1046 | entry = { | |
|
1047 | 'id': obj_id, | |
|
1048 | 'text': obj_text, | |
|
1049 | 'type': obj_type, | |
|
1050 | 'at_rev': at_rev | |
|
1051 | } | |
|
1052 | ||
|
1053 | items.append(entry) | |
|
1054 | ||
|
1042 | 1055 | res.append({ |
|
1043 |
'text': |
|
|
1044 | 'children': [{'id': o[0], 'text': o[1], 'type': o[2]} for o in obj[0]] | |
|
1056 | 'text': section, | |
|
1057 | 'children': items | |
|
1045 | 1058 | }) |
|
1046 | 1059 | |
|
1047 | 1060 | data = { |
@@ -47,7 +47,7 b' from .utils import (' | |||
|
47 | 47 | FreshRegionCache, ActiveRegionCache) |
|
48 | 48 | |
|
49 | 49 | |
|
50 |
FILE_TREE_CACHE_VER = 'v |
|
|
50 | FILE_TREE_CACHE_VER = 'v3' | |
|
51 | 51 | |
|
52 | 52 | |
|
53 | 53 | def configure_dogpile_cache(settings): |
@@ -372,9 +372,13 b' var getFilesMetadata = function() {' | |||
|
372 | 372 | var url_data = { |
|
373 | 373 | 'repo_name': templateContext.repo_name, |
|
374 | 374 | 'commit_id': state.commit_id, |
|
375 | 'f_path': state.f_path | |
|
375 | 'f_path': state.f_path, | |
|
376 | 376 | }; |
|
377 | 377 | |
|
378 | if (atRef !== '') { | |
|
379 | url_data['at'] = atRef | |
|
380 | } | |
|
381 | ||
|
378 | 382 | var url = pyroutes.url('repo_nodetree_full', url_data); |
|
379 | 383 | |
|
380 | 384 | metadataRequest = $.ajax({url: url}); |
@@ -1,10 +1,25 b'' | |||
|
1 | <%def name="refs(commit)"> | |
|
2 | ## Build a cache of refs for selector | |
|
1 | <%def name="refs(commit, at_rev=None)"> | |
|
2 | ||
|
3 | ## Build a cache of refs for selector, based on this the files ref selector gets pre-selected values | |
|
3 | 4 | <script> |
|
4 | fileTreeRefs = { | |
|
5 | fileTreeRefs = {} | |
|
6 | </script> | |
|
5 | 7 | |
|
6 | } | |
|
7 | </script> | |
|
8 | % if h.is_svn(c.rhodecode_repo): | |
|
9 | ## since SVN doesn't have an commit<->refs association, we simply inject it | |
|
10 | ## based on our at_rev marker | |
|
11 | % if at_rev and at_rev.startswith('branches/'): | |
|
12 | <% | |
|
13 | commit.branch = at_rev | |
|
14 | %> | |
|
15 | % endif | |
|
16 | % if at_rev and at_rev.startswith('tags/'): | |
|
17 | <% | |
|
18 | commit.tags.append(at_rev) | |
|
19 | %> | |
|
20 | % endif | |
|
21 | ||
|
22 | % endif | |
|
8 | 23 | |
|
9 | 24 | %if commit.merge: |
|
10 | 25 | <span class="mergetag tag"> |
@@ -158,18 +158,24 b'' | |||
|
158 | 158 | |
|
159 | 159 | select2FileHistorySwitcher('#file_refs_filter', loadUrl, initialCommitData); |
|
160 | 160 | |
|
161 | // switcher for files | |
|
161 | 162 | $('#file_refs_filter').on('change', function(e) { |
|
162 | 163 | var data = $('#file_refs_filter').select2('data'); |
|
163 | 164 | var commit_id = data.id; |
|
165 | var params = { | |
|
166 | 'repo_name': templateContext.repo_name, | |
|
167 | 'commit_id': commit_id, | |
|
168 | 'f_path': state.f_path | |
|
169 | }; | |
|
170 | ||
|
171 | if(data.at_rev !== undefined && data.at_rev !== "") { | |
|
172 | params['at'] = data.at_rev; | |
|
173 | } | |
|
164 | 174 | |
|
165 | 175 | if ("${c.annotate}" === "True") { |
|
166 | var url = pyroutes.url('repo_files:annotated', | |
|
167 | {'repo_name': templateContext.repo_name, | |
|
168 | 'commit_id': commit_id, 'f_path': state.f_path}); | |
|
176 | var url = pyroutes.url('repo_files:annotated', params); | |
|
169 | 177 | } else { |
|
170 | var url = pyroutes.url('repo_files', | |
|
171 | {'repo_name': templateContext.repo_name, | |
|
172 | 'commit_id': commit_id, 'f_path': state.f_path}); | |
|
178 | var url = pyroutes.url('repo_files', params); | |
|
173 | 179 | } |
|
174 | 180 | window.location = url; |
|
175 | 181 | |
@@ -334,6 +340,7 b'' | |||
|
334 | 340 | |
|
335 | 341 | select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData); |
|
336 | 342 | |
|
343 | // switcher for file tree | |
|
337 | 344 | $('#refs_filter').on('change', function(e) { |
|
338 | 345 | var data = $('#refs_filter').select2('data'); |
|
339 | 346 | window.location = data.files_url |
@@ -41,7 +41,6 b'' | |||
|
41 | 41 | % endif |
|
42 | 42 | </span> |
|
43 | 43 | % else: |
|
44 | ||
|
45 | 44 | <a href="${h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=h.safe_unicode(node.path), _query=query)}"> |
|
46 | 45 | <i class="${('icon-file-text browser-file' if node.is_file() else 'icon-directory browser-dir')}"></i>${node.name} |
|
47 | 46 | </a> |
@@ -46,7 +46,7 b'' | |||
|
46 | 46 | <a href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">${h.show_id(c.commit)}</a> |
|
47 | 47 | </code> |
|
48 | 48 | <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.commit.raw_id}" title="${_('Copy the full commit id')}"></i> |
|
49 | ${file_base.refs(c.commit)} | |
|
49 | ${file_base.refs(c.commit, request.GET.get('at'))} | |
|
50 | 50 | </div> |
|
51 | 51 | </div> |
|
52 | 52 | </div> |
@@ -33,7 +33,8 b'' | |||
|
33 | 33 | </code> |
|
34 | 34 | |
|
35 | 35 | <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.commit.raw_id}" title="${_('Copy the full commit id')}"></i> |
|
36 | ${file_base.refs(c.commit)} | |
|
36 | ${file_base.refs(c.commit, request.GET.get('at'))} | |
|
37 | ||
|
37 | 38 | </div> |
|
38 | 39 | </div> |
|
39 | 40 |
General Comments 0
You need to be logged in to leave comments.
Login now