Skip to content

Commit f4f330f

Browse files
committed
Added store support. Now the basic object IO is implemented, which shall be enough for the first batch of work
1 parent 6a10c8a commit f4f330f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

git/db/dulwich/complex.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
#from git.db.interface import ObjectDBW, ObjectDBR
1818
from dulwich.repo import Repo as DulwichRepo
19+
from dulwich.objects import ShaFile
1920

2021
from git.base import OInfo, OStream
21-
from git.fun import type_id_to_type_map
22+
from git.fun import type_id_to_type_map, type_to_type_id_map
2223

2324
from cStringIO import StringIO
2425
import os
@@ -57,7 +58,16 @@ def stream(self, binsha):
5758
return OStream(binsha, type_id_to_type_map[type_id], len(uncomp_data), StringIO(uncomp_data))
5859

5960
#}END object dbr
61+
62+
#{ 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._dw_repo.object_store.add_object(obj)
67+
istream.binsha = obj.sha().digest()
68+
return istream
6069

70+
#}END object dbw
6171

6272
class DulwichGitDB( PureRepositoryPathsMixin, PureConfigurationMixin,
6373
PureReferencesMixin, PureSubmoduleDB,

0 commit comments

Comments
 (0)