| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,8 @@ | |||
| 17 | 17 | from pygit2 import Repository as Pygit2Repo | |
| 18 | 18 | ||
| 19 | 19 | from git.base import OInfo, OStream | |
| 20 | - from git.fun import type_id_to_type_map, type_to_type_id_map | ||
| 20 | + from git.fun import type_id_to_type_map, type_to_type_id_map | ||
| 21 | + from git.util import hex_to_bin | ||
| 21 | 22 | ||
| 22 | 23 | from cStringIO import StringIO | |
| 23 | 24 | import os | |
@@ -49,23 +50,25 @@ def __getattr__(self, attr): | |||
| 49 | 50 | ||
| 50 | 51 | #{ Object DBR | |
| 51 | 52 | ||
| 52 | - # def info(self, binsha): | ||
| 53 | - # type_id, uncomp_data = self._py2_repo.object_store.get_raw(binsha) | ||
| 54 | - # return OInfo(binsha, type_id_to_type_map[type_id], len(uncomp_data)) | ||
| 55 | - # | ||
| 56 | - # def stream(self, binsha): | ||
| 57 | - # type_id, uncomp_data = self._py2_repo.object_store.get_raw(binsha) | ||
| 58 | - # return OStream(binsha, type_id_to_type_map[type_id], len(uncomp_data), StringIO(uncomp_data)) | ||
| 59 | - # | ||
| 53 | + def info(self, binsha): | ||
| 54 | + type_id, uncomp_data = self._py2_repo.read(binsha) | ||
| 55 | + return OInfo(binsha, type_id_to_type_map[type_id], len(uncomp_data)) | ||
| 56 | + | ||
| 57 | + def stream(self, binsha): | ||
| 58 | + type_id, uncomp_data = self._py2_repo.read(binsha) | ||
| 59 | + return OStream(binsha, type_id_to_type_map[type_id], len(uncomp_data), StringIO(uncomp_data)) | ||
| 60 | + | ||
| 60 | 61 | # #}END object dbr | |
| 61 | 62 | # | |
| 62 | 63 | # #{ Object DBW | |
| 63 | - # | ||
| 64 | - # def store(self, istream): | ||
| 65 | - # obj = ShaFile.from_raw_string(type_to_type_id_map[istream.type], istream.read()) | ||
| 66 | - # self._py2_repo.object_store.add_object(obj) | ||
| 67 | - # istream.binsha = obj.sha().digest() | ||
| 68 | - # return istream | ||
| 64 | + def store(self, istream): | ||
| 65 | + # TODO: remove this check once the required functionality was merged in pygit2 | ||
| 66 | + if hasattr(self._py2_repo, 'write'): | ||
| 67 | + istream.binsha = hex_to_bin(self._py2_repo.write(type_to_type_id_map[istream.type], istream.read())) | ||
| 68 | + return istream | ||
| 69 | + else: | ||
| 70 | + return super(Pygit2GitODB, self).store(istream) | ||
| 71 | + #END handle write support | ||
| 69 | 72 | ||
| 70 | 73 | #}END object dbw | |
| 71 | 74 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ | |||
| 7 | 7 | from git.test.db.dulwich.lib import DulwichRequiredMetaMixin | |
| 8 | 8 | from odb_impl import TestObjDBPerformanceBase | |
| 9 | 9 | ||
| 10 | - class TestPureDB(TestObjDBPerformanceBase): | ||
| 10 | + class TestDulwichDB(TestObjDBPerformanceBase): | ||
| 11 | 11 | __metaclass__ = DulwichRequiredMetaMixin | |
| 12 | 12 | RepoCls = DulwichCompatibilityGitDB | |
| 13 | 13 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,13 +1,13 @@ | |||
| 1 | 1 | try: | |
| 2 | - from git.db.dulwich.complex import DulwichCompatibilityGitDB | ||
| 2 | + from git.db.pygit2.complex import Pygit2CompatibilityGitDB | ||
| 3 | 3 | except ImportError: | |
| 4 | - from git.db.complex import PureCompatibilityGitDB as DulwichCompatibilityGitDB | ||
| 5 | - #END handle dulwich compatibility | ||
| 4 | + from git.db.complex import PureCompatibilityGitDB as Pygit2CompatibilityGitDB | ||
| 5 | + #END handle pygit2 compatibility | ||
| 6 | 6 | ||
| 7 | - from git.test.db.dulwich.lib import DulwichRequiredMetaMixin | ||
| 7 | + from git.test.db.pygit2.lib import Pygit2RequiredMetaMixin | ||
| 8 | 8 | from odb_impl import TestObjDBPerformanceBase | |
| 9 | 9 | ||
| 10 | - class TestPureDB(TestObjDBPerformanceBase): | ||
| 11 | - __metaclass__ = DulwichRequiredMetaMixin | ||
| 12 | - RepoCls = DulwichCompatibilityGitDB | ||
| 10 | + class TestPygit2DB(TestObjDBPerformanceBase): | ||
| 11 | + __metaclass__ = Pygit2RequiredMetaMixin | ||
| 12 | + RepoCls = Pygit2CompatibilityGitDB | ||
| 13 | 13 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments