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

Cope with locking.

Changeset e129c806e7e5

Parent 3ccf689dcff5

by Jelmer Vernooij

Changes to 2 files · Browse files at e129c806e7e5 Showing diff from parent 3ccf689dcff5 Diff from another changeset...

 
387
388
389
390
391
392
393
 
 
 
 
 
 
 
 
 
 
 
 
 
394
395
396
 
387
388
389
 
 
 
 
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
@@ -387,10 +387,19 @@
  except OSError, e:   if e.errno != errno.EEXIST:   raise - # FIXME: Locking - f = GitFile(os.path.join(self.path, "info/alternates"), 'wb') - try: - f.seek(0, os.SEEK_END) + alternates_path = os.path.join(self.path, "info/alternates") + f = GitFile(alternates_path, 'wb') + try: + try: + orig_f = open(alternates_path, 'rb') + except (OSError, IOError), e: + if e.errno != errno.ENOENT: + raise + else: + try: + f.write(orig_f.read()) + finally: + orig_f.close()   f.write("%s\n" % path)   finally:   f.close()
 
238
239
240
 
 
 
 
 
 
 
 
 
 
241
242
243
 
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
@@ -238,6 +238,16 @@
  self.assertRaises(KeyError, store.__getitem__, b2.id)   store.add_alternate_path(alternate_dir)   self.assertEquals(b2, store[b2.id]) + + def test_add_alternate_path(self): + store = DiskObjectStore(self.store_dir) + self.assertEquals([], store._read_alternate_paths()) + store.add_alternate_path("/foo/path") + self.assertEquals(["/foo/path"], store._read_alternate_paths()) + store.add_alternate_path("/bar/path") + self.assertEquals( + ["/foo/path", "/bar/path"], + store._read_alternate_paths())     def test_pack_dir(self):   o = DiskObjectStore(self.store_dir)