##// END OF EJS Templates
vcs: optimized pre-load attributes for better caching.
marcink -
r3850:0415fef3 default
parent child Browse files
Show More
@@ -458,7 +458,7 b' class BaseReferencesView(RepoAppView):'
458
458
459 def load_refs_context(self, ref_items, partials_template):
459 def load_refs_context(self, ref_items, partials_template):
460 _render = self.request.get_partial_renderer(partials_template)
460 _render = self.request.get_partial_renderer(partials_template)
461 pre_load = ["author", "date", "message"]
461 pre_load = ["author", "date", "message", "parents"]
462
462
463 is_svn = h.is_svn(self.rhodecode_vcs_repo)
463 is_svn = h.is_svn(self.rhodecode_vcs_repo)
464 is_hg = h.is_hg(self.rhodecode_vcs_repo)
464 is_hg = h.is_hg(self.rhodecode_vcs_repo)
@@ -211,7 +211,7 b' class RepoCompareView(RepoAppView):'
211 c.source_ref_type = source_ref_type
211 c.source_ref_type = source_ref_type
212 c.target_ref_type = target_ref_type
212 c.target_ref_type = target_ref_type
213
213
214 pre_load = ["author", "branch", "date", "message"]
214 pre_load = ["author", "date", "message", "branch"]
215 c.ancestor = None
215 c.ancestor = None
216
216
217 try:
217 try:
@@ -687,7 +687,7 b' class RepoPullRequestsView(RepoAppView, '
687 commit_cache = collections.OrderedDict()
687 commit_cache = collections.OrderedDict()
688 missing_requirements = False
688 missing_requirements = False
689 try:
689 try:
690 pre_load = ["author", "branch", "date", "message", "parents"]
690 pre_load = ["author", "date", "message", "branch", "parents"]
691 show_revs = pull_request_at_ver.revisions
691 show_revs = pull_request_at_ver.revisions
692 for rev in show_revs:
692 for rev in show_revs:
693 comm = commits_source_repo.get_commit(
693 comm = commits_source_repo.get_commit(
@@ -50,8 +50,6 b' class GitCommit(base.BaseCommit):'
50 _filter_pre_load = [
50 _filter_pre_load = [
51 # done through a more complex tree walk on parents
51 # done through a more complex tree walk on parents
52 "affected_files",
52 "affected_files",
53 # based on repository cached property
54 "branch",
55 # done through subprocess not remote call
53 # done through subprocess not remote call
56 "children",
54 "children",
57 # done through a more complex tree walk on parents
55 # done through a more complex tree walk on parents
@@ -82,6 +80,7 b' class GitCommit(base.BaseCommit):'
82 self._submodules = None
80 self._submodules = None
83
81
84 def _set_bulk_properties(self, pre_load):
82 def _set_bulk_properties(self, pre_load):
83
85 if not pre_load:
84 if not pre_load:
86 return
85 return
87 pre_load = [entry for entry in pre_load
86 pre_load = [entry for entry in pre_load
@@ -98,6 +97,8 b' class GitCommit(base.BaseCommit):'
98 value = utcdate_fromtimestamp(*value)
97 value = utcdate_fromtimestamp(*value)
99 elif attr == "parents":
98 elif attr == "parents":
100 value = self._make_commits(value)
99 value = self._make_commits(value)
100 elif attr == "branch":
101 value = value[0] if value else None
101 self.__dict__[attr] = value
102 self.__dict__[attr] = value
102
103
103 @LazyProperty
104 @LazyProperty
@@ -157,12 +158,10 b' class GitCommit(base.BaseCommit):'
157
158
158 @LazyProperty
159 @LazyProperty
159 def branch(self):
160 def branch(self):
160 # actually commit can have multiple branches
161 branches = safe_unicode(self._remote.branch(self.raw_id))
161 branches = self.commit_branches
162 if branches:
162 if branches:
163 return branches[0]
163 # actually commit can have multiple branches in git
164
164 return safe_unicode(branches[0])
165 return None
166
165
167 def _get_tree_id_for_path(self, path):
166 def _get_tree_id_for_path(self, path):
168 path = safe_str(path)
167 path = safe_str(path)
@@ -432,7 +432,7 b' class FileNode(Node):'
432 @LazyProperty
432 @LazyProperty
433 def last_commit(self):
433 def last_commit(self):
434 if self.commit:
434 if self.commit:
435 pre_load = ["author", "date", "message"]
435 pre_load = ["author", "date", "message", "parents"]
436 return self.commit.get_path_commit(self.path, pre_load=pre_load)
436 return self.commit.get_path_commit(self.path, pre_load=pre_load)
437 raise NodeError(
437 raise NodeError(
438 "Cannot retrieve last commit of the file without "
438 "Cannot retrieve last commit of the file without "
@@ -548,7 +548,7 b' class FileNode(Node):'
548 """
548 """
549 if self.commit is None:
549 if self.commit is None:
550 raise NodeError('Unable to get commit for this FileNode')
550 raise NodeError('Unable to get commit for this FileNode')
551 pre_load = ["author", "date", "message"]
551 pre_load = ["author", "date", "message", "parents"]
552 return self.commit.get_file_annotate(self.path, pre_load=pre_load)
552 return self.commit.get_file_annotate(self.path, pre_load=pre_load)
553
553
554 @LazyProperty
554 @LazyProperty
@@ -756,7 +756,7 b' class DirNode(Node):'
756 @LazyProperty
756 @LazyProperty
757 def last_commit(self):
757 def last_commit(self):
758 if self.commit:
758 if self.commit:
759 pre_load = ["author", "date", "message"]
759 pre_load = ["author", "date", "message", "parents"]
760 return self.commit.get_path_commit(self.path, pre_load=pre_load)
760 return self.commit.get_path_commit(self.path, pre_load=pre_load)
761 raise NodeError(
761 raise NodeError(
762 "Cannot retrieve last commit of the file without "
762 "Cannot retrieve last commit of the file without "
@@ -749,7 +749,7 b' class PullRequestModel(BaseModel):'
749
749
750 # re-compute commit ids
750 # re-compute commit ids
751 old_commit_ids = pull_request.revisions
751 old_commit_ids = pull_request.revisions
752 pre_load = ["author", "branch", "date", "message"]
752 pre_load = ["author", "date", "message", "branch"]
753 commit_ranges = target_repo.compare(
753 commit_ranges = target_repo.compare(
754 target_commit.raw_id, source_commit.raw_id, source_repo, merge=True,
754 target_commit.raw_id, source_commit.raw_id, source_repo, merge=True,
755 pre_load=pre_load)
755 pre_load=pre_load)
General Comments 0
You need to be logged in to leave comments. Login now