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