summaryrefslogtreecommitdiff
path: root/lib/git/index/base.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-22 21:23:47 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-22 21:23:47 +0200
commitbe97c4558992a437cde235aafc7ae2bd6df84ac8 (patch)
tree3e44a7c38e356817ca81721725709d7374f95012 /lib/git/index/base.py
parent778234d544b3f58dd415aaf10679d15b01a5281f (diff)
downloadgitpython-be97c4558992a437cde235aafc7ae2bd6df84ac8.tar.gz
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
Diffstat (limited to 'lib/git/index/base.py')
-rw-r--r--lib/git/index/base.py24
1 files changed, 21 insertions, 3 deletions
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 """
@@ -241,6 +240,26 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
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):
"""
Merge the given treeish revisions into a new index which is returned.
@@ -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))