##// END OF EJS Templates
quick-filter: use a dedicated method for fetching quick filter nodes....
marcink -
r3925:66f1ac00 default
parent child Browse files
Show More
@@ -920,8 +920,7 b' class RepoFilesView(RepoAppView):'
920 log.debug('Generating cached nodelist for repo_id:%s, %s, %s',
920 log.debug('Generating cached nodelist for repo_id:%s, %s, %s',
921 repo_id, commit_id, f_path)
921 repo_id, commit_id, f_path)
922 try:
922 try:
923 _d, _f = ScmModel().get_nodes(
923 _d, _f = ScmModel().get_quick_filter_nodes(repo_name, commit_id, f_path)
924 repo_name, commit_id, f_path, flat=False)
925 except (RepositoryError, CommitDoesNotExistError, Exception) as e:
924 except (RepositoryError, CommitDoesNotExistError, Exception) as e:
926 log.exception(safe_str(e))
925 log.exception(safe_str(e))
927 h.flash(safe_str(h.escape(e)), category='error')
926 h.flash(safe_str(h.escape(e)), category='error')
@@ -667,7 +667,7 b' class DirNode(Node):'
667 """
667 """
668 DirNode stores list of files and directories within this node.
668 DirNode stores list of files and directories within this node.
669 Nodes may be used standalone but within repository context they
669 Nodes may be used standalone but within repository context they
670 lazily fetch data within same repositorty's commit.
670 lazily fetch data within same repository's commit.
671 """
671 """
672
672
673 def __init__(self, path, nodes=(), commit=None):
673 def __init__(self, path, nodes=(), commit=None):
@@ -583,6 +583,42 b' class ScmModel(BaseModel):'
583
583
584 return _dirs, _files
584 return _dirs, _files
585
585
586 def get_quick_filter_nodes(self, repo_name, commit_id, root_path='/'):
587 """
588 Generate files for quick filter in files view
589 """
590
591 _files = list()
592 _dirs = list()
593 try:
594 _repo = self._get_repo(repo_name)
595 commit = _repo.scm_instance().get_commit(commit_id=commit_id)
596 root_path = root_path.lstrip('/')
597 for __, dirs, files in commit.walk(root_path):
598
599 for f in files:
600
601 _data = {
602 "name": h.escape(f.unicode_path),
603 "type": "file",
604 }
605
606 _files.append(_data)
607
608 for d in dirs:
609
610 _data = {
611 "name": h.escape(d.unicode_path),
612 "type": "dir",
613 }
614
615 _dirs.append(_data)
616 except RepositoryError:
617 log.exception("Exception in get_quick_filter_nodes")
618 raise
619
620 return _dirs, _files
621
586 def get_node(self, repo_name, commit_id, file_path,
622 def get_node(self, repo_name, commit_id, file_path,
587 extended_info=False, content=False, max_file_bytes=None, cache=True):
623 extended_info=False, content=False, max_file_bytes=None, cache=True):
588 """
624 """
General Comments 0
You need to be logged in to leave comments. Login now