Skip to content

Commit 4ea529d

Browse files
committed
Fixed pure python implementation to run the default repository tests
1 parent 1f71ed9 commit 4ea529d

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

git/db/py/base.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ def store_async(self, reader):
9696
class PureRootPathDB(RootPathDB):
9797

9898
def __init__(self, root_path):
99-
super(PureRootPathDB, self).__init__(root_path)
10099
self._root_path = root_path
100+
super(PureRootPathDB, self).__init__(root_path)
101+
101102

102103

103104
#{ Interface
@@ -127,8 +128,8 @@ class PureCompoundDB(CompoundDB, PureObjectDBR, LazyMixin, CachingDB):
127128
def _set_cache_(self, attr):
128129
if attr == '_dbs':
129130
self._dbs = list()
130-
elif attr == '_db_cache':
131-
self._db_cache = dict()
131+
elif attr == '_obj_cache':
132+
self._obj_cache = dict()
132133
else:
133134
super(PureCompoundDB, self)._set_cache_(attr)
134135

@@ -138,14 +139,14 @@ def _db_query(self, sha):
138139
# most databases use binary representations, prevent converting
139140
# it everytime a database is being queried
140141
try:
141-
return self._db_cache[sha]
142+
return self._obj_cache[sha]
142143
except KeyError:
143144
pass
144145
# END first level cache
145146

146147
for db in self._dbs:
147148
if db.has_object(sha):
148-
self._db_cache[sha] = db
149+
self._obj_cache[sha] = db
149150
return db
150151
# END for each database
151152
raise BadObject(sha)
@@ -181,7 +182,7 @@ def databases(self):
181182

182183
def update_cache(self, force=False):
183184
# something might have changed, clear everything
184-
self._db_cache.clear()
185+
self._obj_cache.clear()
185186
stat = False
186187
for db in self._dbs:
187188
if isinstance(db, CachingDB):
@@ -191,8 +192,6 @@ def update_cache(self, force=False):
191192
return stat
192193

193194
def partial_to_complete_sha_hex(self, partial_hexsha):
194-
databases = self.databases()
195-
196195
len_partial_hexsha = len(partial_hexsha)
197196
if len_partial_hexsha % 2 != 0:
198197
partial_binsha = hex_to_bin(partial_hexsha + "0")

git/db/py/complex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
__all__ = ('PureGitODB', 'PurePartialGitDB', 'PureCompatibilityGitDB')
3939

4040

41-
class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB):
41+
class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB, PureAlternatesFileMixin):
4242
"""A git-style object-only database, which contains all objects in the 'objects'
4343
subdirectory.
4444
:note: The type needs to be initialized on the ./objects directory to function,
@@ -105,7 +105,7 @@ def set_ostream(self, ostream):
105105

106106
class PurePartialGitDB(PureGitODB,
107107
PureRepositoryPathsMixin, PureConfigurationMixin,
108-
PureReferencesMixin, PureSubmoduleDB, PureAlternatesFileMixin,
108+
PureReferencesMixin, PureSubmoduleDB,
109109
PureIndexDB, PureTransportDB
110110
# HighLevelRepository Currently not implemented !
111111
):

git/db/py/ref.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def _update_dbs_from_ref_file(self):
3131
dbcls = self.ObjectDBCls
3232
if dbcls is None:
3333
# late import
34-
from complex import PureGitODB # TODO: This should be a configurable for flexibility
35-
dbcls = PureGitODB
34+
import complex
35+
dbcls = complex.PureGitODB
3636
# END get db type
3737

3838
# try to get as many as possible, don't fail if some are unavailable

0 commit comments

Comments
 (0)