Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master-1, master-0, and 0.9.4

Cope with locking.

Changeset 62b640c90838

Parent 7a3a2de9670e

by Jelmer Vernooij

Changes to 2 files · Browse files at 62b640c90838 Showing diff from parent 7a3a2de9670e 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)