@@ -104,7 +104,6 @@ def __init__(self, root_path):
104
104
super (PureRootPathDB , self ).__init__ (root_path )
105
105
106
106
107
-
108
107
#{ Interface
109
108
def root_path (self ):
110
109
return self ._root_path
@@ -132,44 +131,33 @@ class PureCompoundDB(CompoundDB, PureObjectDBR, LazyMixin, CachingDB):
132
131
def _set_cache_ (self , attr ):
133
132
if attr == '_dbs' :
134
133
self ._dbs = list ()
135
- elif attr == '_obj_cache' :
136
- self ._obj_cache = dict ()
137
134
else :
138
135
super (PureCompoundDB , self )._set_cache_ (attr )
139
136
140
- def _db_query (self , sha ):
141
- """:return: database containing the given 20 byte sha
142
- :raise BadObject:"""
143
- # most databases use binary representations, prevent converting
144
- # it everytime a database is being queried
145
- try :
146
- return self ._obj_cache [sha ]
147
- except KeyError :
148
- pass
149
- # END first level cache
150
-
151
- for db in self ._dbs :
152
- if db .has_object (sha ):
153
- self ._obj_cache [sha ] = db
154
- return db
155
- # END for each database
156
- raise BadObject (sha )
157
-
158
137
#{ PureObjectDBR interface
159
138
160
139
def has_object (self , sha ):
161
- try :
162
- self ._db_query (sha )
163
- return True
164
- except BadObject :
165
- return False
166
- # END handle exceptions
140
+ for db in self ._dbs :
141
+ if db .has_object (sha ):
142
+ return True
143
+ #END for each db
144
+ return False
167
145
168
146
def info (self , sha ):
169
- return self ._db_query (sha ).info (sha )
147
+ for db in self ._dbs :
148
+ try :
149
+ return db .info (sha )
150
+ except BadObject :
151
+ pass
152
+ #END for each db
170
153
171
154
def stream (self , sha ):
172
- return self ._db_query (sha ).stream (sha )
155
+ for db in self ._dbs :
156
+ try :
157
+ return db .stream (sha )
158
+ except BadObject :
159
+ pass
160
+ #END for each db
173
161
174
162
def size (self ):
175
163
return reduce (lambda x ,y : x + y , (db .size () for db in self ._dbs ), 0 )
@@ -186,7 +174,6 @@ def databases(self):
186
174
187
175
def update_cache (self , force = False ):
188
176
# something might have changed, clear everything
189
- self ._obj_cache .clear ()
190
177
stat = False
191
178
for db in self ._dbs :
192
179
if isinstance (db , CachingDB ):
@@ -233,7 +220,7 @@ def partial_to_complete_sha(self, partial_binsha, hex_len):
233
220
234
221
class PureRepositoryPathsMixin (RepositoryPathsMixin ):
235
222
# slots has no effect here, its just to keep track of used attrs
236
- __slots__ = ("_git_path" , '_bare' )
223
+ __slots__ = ("_git_path" , '_bare' , '_working_tree_dir' )
237
224
238
225
#{ Configuration
239
226
repo_dir = '.git'
@@ -272,14 +259,16 @@ def _initialize(self, path):
272
259
raise InvalidGitRepositoryError (epath )
273
260
# END path not found
274
261
275
- self ._bare = self ._git_path . endswith ( self . repo_dir )
262
+ self ._bare = self ._working_tree_dir is None
276
263
if hasattr (self , 'config_reader' ):
277
264
try :
278
265
self ._bare = self .config_reader ("repository" ).getboolean ('core' ,'bare' )
279
266
except Exception :
280
267
# lets not assume the option exists, although it should
281
268
pass
269
+ #END handle exception
282
270
#END check bare flag
271
+ self ._working_tree_dir = self ._bare and None or self ._working_tree_dir
283
272
284
273
#} end subclass interface
285
274
@@ -313,7 +302,7 @@ def git_dir(self):
313
302
314
303
@property
315
304
def working_tree_dir (self ):
316
- if self .is_bare :
305
+ if self ._working_tree_dir is None :
317
306
raise AssertionError ("Repository at %s is bare and does not have a working tree directory" % self .git_dir )
318
307
#END assertion
319
308
return dirname (self .git_dir )
@@ -354,6 +343,10 @@ class PureConfigurationMixin(ConfigurationMixin):
354
343
repo_config_file_name = "config"
355
344
#} END
356
345
346
+ def __new__ (cls , * args , ** kwargs ):
347
+ """This is just a stupid workaround for the evil py2.6 change which makes mixins quite impossible"""
348
+ return super (PureConfigurationMixin , cls ).__new__ (cls , * args , ** kwargs )
349
+
357
350
def __init__ (self , * args , ** kwargs ):
358
351
"""Verify prereqs"""
359
352
try :
@@ -421,7 +414,11 @@ class PureAlternatesFileMixin(object):
421
414
#} END configuration
422
415
423
416
def __init__ (self , * args , ** kwargs ):
424
- super (PureAlternatesFileMixin , self ).__init__ (* args , ** kwargs )
417
+ try :
418
+ super (PureAlternatesFileMixin , self ).__init__ (* args , ** kwargs )
419
+ except TypeError :
420
+ pass
421
+ #END handle py2.6 code breaking changes
425
422
self ._alternates_path () # throws on incompatible type
426
423
427
424
#{ Interface
0 commit comments