vcs: optimized pre-load attributes for better caching.
This commit is contained in:
parent
16c2d9514a
commit
cab16efa4e
6 changed files with 13 additions and 14 deletions
|
|
@ -50,8 +50,6 @@ class GitCommit(base.BaseCommit):
|
|||
_filter_pre_load = [
|
||||
# done through a more complex tree walk on parents
|
||||
"affected_files",
|
||||
# based on repository cached property
|
||||
"branch",
|
||||
# done through subprocess not remote call
|
||||
"children",
|
||||
# done through a more complex tree walk on parents
|
||||
|
|
@ -82,6 +80,7 @@ class GitCommit(base.BaseCommit):
|
|||
self._submodules = None
|
||||
|
||||
def _set_bulk_properties(self, pre_load):
|
||||
|
||||
if not pre_load:
|
||||
return
|
||||
pre_load = [entry for entry in pre_load
|
||||
|
|
@ -98,6 +97,8 @@ class GitCommit(base.BaseCommit):
|
|||
value = utcdate_fromtimestamp(*value)
|
||||
elif attr == "parents":
|
||||
value = self._make_commits(value)
|
||||
elif attr == "branch":
|
||||
value = value[0] if value else None
|
||||
self.__dict__[attr] = value
|
||||
|
||||
@LazyProperty
|
||||
|
|
@ -157,12 +158,10 @@ class GitCommit(base.BaseCommit):
|
|||
|
||||
@LazyProperty
|
||||
def branch(self):
|
||||
# actually commit can have multiple branches
|
||||
branches = self.commit_branches
|
||||
branches = safe_unicode(self._remote.branch(self.raw_id))
|
||||
if branches:
|
||||
return branches[0]
|
||||
|
||||
return None
|
||||
# actually commit can have multiple branches in git
|
||||
return safe_unicode(branches[0])
|
||||
|
||||
def _get_tree_id_for_path(self, path):
|
||||
path = safe_str(path)
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ class FileNode(Node):
|
|||
@LazyProperty
|
||||
def last_commit(self):
|
||||
if self.commit:
|
||||
pre_load = ["author", "date", "message"]
|
||||
pre_load = ["author", "date", "message", "parents"]
|
||||
return self.commit.get_path_commit(self.path, pre_load=pre_load)
|
||||
raise NodeError(
|
||||
"Cannot retrieve last commit of the file without "
|
||||
|
|
@ -548,7 +548,7 @@ class FileNode(Node):
|
|||
"""
|
||||
if self.commit is None:
|
||||
raise NodeError('Unable to get commit for this FileNode')
|
||||
pre_load = ["author", "date", "message"]
|
||||
pre_load = ["author", "date", "message", "parents"]
|
||||
return self.commit.get_file_annotate(self.path, pre_load=pre_load)
|
||||
|
||||
@LazyProperty
|
||||
|
|
@ -756,7 +756,7 @@ class DirNode(Node):
|
|||
@LazyProperty
|
||||
def last_commit(self):
|
||||
if self.commit:
|
||||
pre_load = ["author", "date", "message"]
|
||||
pre_load = ["author", "date", "message", "parents"]
|
||||
return self.commit.get_path_commit(self.path, pre_load=pre_load)
|
||||
raise NodeError(
|
||||
"Cannot retrieve last commit of the file without "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue