From be97c4558992a437cde235aafc7ae2bd6df84ac8 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 22 Jun 2010 21:23:47 +0200 Subject: Initial frame for implementing read_tree using pure python. As git-read-tree can do much more than we can ( and faster assumably ), the .new method is used to create new index instances from up to 3 trees. Implemented multi-tree traversal to facilitate building a stage list more efficiently ( although I am not sure whether it could be faster to use a dictionary together with some intensive lookup ), including test Added performance to learn how fast certain operations are, and whether one should be preferred over another --- lib/git/index/base.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'lib/git/index/base.py') diff --git a/lib/git/index/base.py b/lib/git/index/base.py index 06437702..f1be00e0 100644 --- a/lib/git/index/base.py +++ b/lib/git/index/base.py @@ -133,7 +133,6 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): def _index_path(self): return join_path_native(self.repo.git_dir, "index") - @property def path(self): """ :return: Path to the index file we are representing """ @@ -240,6 +239,26 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): self.repo.git.read_tree(args) return self + @classmethod + def new(cls, repo, *tree_sha): + """ Merge the given treeish revisions into a new index which is returned. + This method behaves like git-read-tree --aggressive when doing the merge. + + :param repo: The repository treeish are located in. + + :param *tree_sha: + see ``from_tree`` + + :return: + New IndexFile instance. Its path will be undefined. + If you intend to write such a merged Index, supply an alternate file_path + to its 'write' method.""" + base_entries = aggressive_tree_merge(repo.odb, tree_sha) + + inst = cls(self.repo) + raise NotImplementedError("convert to entries") + + @classmethod def from_tree(cls, repo, *treeish, **kwargs): """ @@ -275,8 +294,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): As the underlying git-read-tree command takes into account the current index, it will be temporarily moved out of the way to assure there are no unsuspected - interferences. - """ + interferences.""" if len(treeish) == 0 or len(treeish) > 3: raise ValueError("Please specify between 1 and 3 treeish, got %i" % len(treeish)) -- cgit v1.2.1