Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master

Merge fix for use of alternates in DiskObjectStore.__contains__ and DiskObjectStore.__iter__.

Changeset 11e4b3d18288

Parents c4f0c51e7583

Parents 75f7f6668c89

by Jelmer Vernooij

Changes to 3 files · Browse files at 11e4b3d18288 Showing diff from parent c4f0c51e7583 75f7f6668c89 Diff from another changeset...

Change 1 of 1 Show Entire File NEWS Stacked
 
1
 
 
 
 
 
2
3
4
 
1
2
3
4
5
6
7
8
9
@@ -1,4 +1,9 @@
 0.9.0 UNRELEASED + + BUG FIXES + + * Fix use of alternates in ``DiskObjectStore``.{__contains__,__iter__}. + (Dmitriy)    0.8.6 2012-11-09  
 
231
232
233
234
 
 
 
 
235
236
 
 
 
 
 
 
 
 
 
 
 
 
237
238
239
 
257
258
259
 
 
 
 
 
 
260
261
262
 
283
284
285
286
 
287
288
289
290
 
 
 
 
291
292
293
 
231
232
233
 
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
 
272
273
274
275
276
277
278
279
280
281
282
283
 
304
305
306
 
307
308
309
310
 
311
312
313
314
315
316
317
@@ -231,9 +231,24 @@
  return []     def contains_packed(self, sha): - """Check if a particular object is present by SHA1 and is packed.""" + """Check if a particular object is present by SHA1 and is packed. + + This does not check alternates. + """   for pack in self.packs:   if sha in pack: + return True + return False + + def __contains__(self, sha): + """Check if a particular object is present by SHA1. + + This method makes no distinction between loose and packed objects. + """ + if self.contains_packed(sha) or self.contains_loose(sha): + return True + for alternate in self.alternates: + if sha in alternate:   return True   return False   @@ -257,6 +272,12 @@
  if self._pack_cache is None or self._pack_cache_stale():   self._pack_cache = self._load_packs()   return self._pack_cache + + def _iter_alternate_objects(self): + """Iterate over the SHAs of all the objects in alternate stores.""" + for alternate in self.alternates: + for alternate_object in alternate: + yield alternate_object     def _iter_loose_objects(self):   """Iterate over the SHAs of all loose objects.""" @@ -283,11 +304,14 @@
    def __iter__(self):   """Iterate over the SHAs that are present in this store.""" - iterables = self.packs + [self._iter_loose_objects()] + iterables = self.packs + [self._iter_loose_objects()] + [self._iter_alternate_objects()]   return itertools.chain(*iterables)     def contains_loose(self, sha): - """Check if a particular object is present by SHA1 and is loose.""" + """Check if a particular object is present by SHA1 and is loose. + + This does not check alternates. + """   return self._get_loose_object(sha) is not None     def get_raw(self, name):
 
237
238
239
 
240
241
242
 
237
238
239
240
241
242
243
@@ -237,6 +237,7 @@
  store = DiskObjectStore(self.store_dir)   self.assertRaises(KeyError, store.__getitem__, b2.id)   store.add_alternate_path(alternate_dir) + self.assertIn(b2.id, store)   self.assertEqual(b2, store[b2.id])     def test_add_alternate_path(self):