diff options
author | Steve Frécinaux <code@istique.net> | 2008-09-05 23:04:58 +0200 |
---|---|---|
committer | Steve Frécinaux <code@istique.net> | 2008-09-05 23:04:58 +0200 |
commit | 43eb1edf93c381bf3f3809a809df33dae23b50d9 (patch) | |
tree | 616cc636a1f5aacd31d3b7707d621e5fe8397151 /lib/git/tree.py | |
parent | b377c07200392ac35a6ed668673451d3c9b1f5c7 (diff) | |
download | gitpython-43eb1edf93c381bf3f3809a809df33dae23b50d9.tar.gz |
Initialize trees completely in tree.__bake__().
This is a simplification of the tree baking code.
As a matter of consequency, Tree.construct() and
tree.construct_initialize() have been killed, and repo.tree() has lost
the "paths" argument. This is not a problem since one can just have the
same result with:
dict(k, o for k, o in tree.items() if k in paths)
Diffstat (limited to 'lib/git/tree.py')
-rw-r--r-- | lib/git/tree.py | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/git/tree.py b/lib/git/tree.py index 86e893ef..1ed3396d 100644 --- a/lib/git/tree.py +++ b/lib/git/tree.py @@ -21,28 +21,18 @@ class Tree(LazyMixin): setattr(self, k, v) def __bake__(self): - temp = Tree.construct(self.repo, self.id) - self.contents = temp.contents + # Ensure the treeish references directly a tree + treeish = self.id + if not treeish.endswith(':'): + treeish = treeish + ':' - @classmethod - def construct(cls, repo, treeish, paths = []): - output = repo.git.ls_tree(treeish, *paths) - return Tree(repo, id=treeish).construct_initialize(repo, treeish, output) - - def construct_initialize(self, repo, id, text): - self.repo = repo - self.id = id + # Read the tree contents. self.contents = {} - self.__baked__ = False - - for line in text.splitlines(): + for line in self.repo.git.ls_tree(self.id).splitlines(): obj = self.content_from_string(self.repo, line) if obj: self.contents[obj.name] = obj - self.__bake_it__() - return self - def content_from_string(self, repo, text): """ Parse a content item and create the appropriate object |