summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2011-07-08 17:34:19 +0200
committerSebastian Thiel <byronimo@gmail.com>2011-07-08 17:34:19 +0200
commita5a0fa2d3befd21534de91e4e2013fbe885995c6 (patch)
tree3287cf74ceba287fd9403b6d4da89ad089789b74 /git
parent16a13276f26e2b4b0cad35c66a527bb8d128d587 (diff)
downloadgitpython-a5a0fa2d3befd21534de91e4e2013fbe885995c6.tar.gz
Fixed up tests to actually use pygit2. Its worth noting that the performance tests only work reliably in a patched up version, or the next point release.
Diffstat (limited to 'git')
-rw-r--r--git/db/pygit2/complex.py33
-rw-r--r--git/test/performance/db/test_odb_dulwich.py2
-rw-r--r--git/test/performance/db/test_odb_pygit2.py14
3 files changed, 26 insertions, 23 deletions
diff --git a/git/db/pygit2/complex.py b/git/db/pygit2/complex.py
index 67635a1e..c1563bca 100644
--- a/git/db/pygit2/complex.py
+++ b/git/db/pygit2/complex.py
@@ -17,7 +17,8 @@ from git.db.compat import RepoCompatibilityInterface
from pygit2 import Repository as Pygit2Repo
from git.base import OInfo, OStream
-from git.fun import type_id_to_type_map, type_to_type_id_map
+from git.fun import type_id_to_type_map, type_to_type_id_map
+from git.util import hex_to_bin
from cStringIO import StringIO
import os
@@ -49,23 +50,25 @@ class Pygit2GitODB(PureGitODB):
#{ Object DBR
- # def info(self, binsha):
- # type_id, uncomp_data = self._py2_repo.object_store.get_raw(binsha)
- # return OInfo(binsha, type_id_to_type_map[type_id], len(uncomp_data))
- #
- # def stream(self, binsha):
- # type_id, uncomp_data = self._py2_repo.object_store.get_raw(binsha)
- # return OStream(binsha, type_id_to_type_map[type_id], len(uncomp_data), StringIO(uncomp_data))
- #
+ def info(self, binsha):
+ type_id, uncomp_data = self._py2_repo.read(binsha)
+ return OInfo(binsha, type_id_to_type_map[type_id], len(uncomp_data))
+
+ def stream(self, binsha):
+ type_id, uncomp_data = self._py2_repo.read(binsha)
+ return OStream(binsha, type_id_to_type_map[type_id], len(uncomp_data), StringIO(uncomp_data))
+
# #}END object dbr
#
# #{ Object DBW
- #
- # def store(self, istream):
- # obj = ShaFile.from_raw_string(type_to_type_id_map[istream.type], istream.read())
- # self._py2_repo.object_store.add_object(obj)
- # istream.binsha = obj.sha().digest()
- # return istream
+ def store(self, istream):
+ # TODO: remove this check once the required functionality was merged in pygit2
+ if hasattr(self._py2_repo, 'write'):
+ istream.binsha = hex_to_bin(self._py2_repo.write(type_to_type_id_map[istream.type], istream.read()))
+ return istream
+ else:
+ return super(Pygit2GitODB, self).store(istream)
+ #END handle write support
#}END object dbw
diff --git a/git/test/performance/db/test_odb_dulwich.py b/git/test/performance/db/test_odb_dulwich.py
index aa886e08..6802483c 100644
--- a/git/test/performance/db/test_odb_dulwich.py
+++ b/git/test/performance/db/test_odb_dulwich.py
@@ -7,7 +7,7 @@ except ImportError:
from git.test.db.dulwich.lib import DulwichRequiredMetaMixin
from odb_impl import TestObjDBPerformanceBase
-class TestPureDB(TestObjDBPerformanceBase):
+class TestDulwichDB(TestObjDBPerformanceBase):
__metaclass__ = DulwichRequiredMetaMixin
RepoCls = DulwichCompatibilityGitDB
diff --git a/git/test/performance/db/test_odb_pygit2.py b/git/test/performance/db/test_odb_pygit2.py
index aa886e08..bb7ed8a9 100644
--- a/git/test/performance/db/test_odb_pygit2.py
+++ b/git/test/performance/db/test_odb_pygit2.py
@@ -1,13 +1,13 @@
try:
- from git.db.dulwich.complex import DulwichCompatibilityGitDB
+ from git.db.pygit2.complex import Pygit2CompatibilityGitDB
except ImportError:
- from git.db.complex import PureCompatibilityGitDB as DulwichCompatibilityGitDB
-#END handle dulwich compatibility
+ from git.db.complex import PureCompatibilityGitDB as Pygit2CompatibilityGitDB
+#END handle pygit2 compatibility
-from git.test.db.dulwich.lib import DulwichRequiredMetaMixin
+from git.test.db.pygit2.lib import Pygit2RequiredMetaMixin
from odb_impl import TestObjDBPerformanceBase
-class TestPureDB(TestObjDBPerformanceBase):
- __metaclass__ = DulwichRequiredMetaMixin
- RepoCls = DulwichCompatibilityGitDB
+class TestPygit2DB(TestObjDBPerformanceBase):
+ __metaclass__ = Pygit2RequiredMetaMixin
+ RepoCls = Pygit2CompatibilityGitDB