834
834
self.repo.weave_store.setup()
835
835
self.repo._inv_thunk.setup()
837
def _commit_write_group(self):
838
data_inserted = (self.repo._revision_store.data_inserted() or
839
self.repo.weave_store.data_inserted() or
840
self.repo._inv_thunk.data_inserted())
842
self.repo._open_pack_writer.end()
843
new_name = self.repo._open_pack_hash.hexdigest()
845
new_pack.name = new_name
846
new_pack.transport = self.repo._upload_transport.clone('../packs/')
848
# new_pack.revision_index =
849
# new_pack.inventory_index =
850
# new_pack.text_index =
851
# new_pack.signature_index =
852
self.repo.weave_store.flush(new_name, new_pack)
853
self.repo._inv_thunk.flush(new_name, new_pack)
854
self.repo._revision_store.flush(new_name, new_pack)
855
self.repo._write_stream.close()
856
self.repo._upload_transport.rename(self.repo._open_pack_tuple[1],
857
'../packs/' + new_name + '.pack')
858
# If this fails, its a hash collision. We should:
859
# - determine if its a collision or
860
# - the same content or
861
# - the existing name is not the actual hash - e.g.
862
# its a deliberate attack or data corruption has
863
# occuring during the write of that file.
864
self.allocate(new_name, new_pack.revision_index_length,
865
new_pack.inventory_index_length, new_pack.text_index_length,
866
new_pack.signature_index_length)
867
self.repo._open_pack_tuple = None
868
if not self.autopack():
871
# remove the pending upload
872
self.repo._upload_transport.delete(self.repo._open_pack_tuple[1])
873
self.repo._revision_store.reset()
874
self.repo.weave_store.reset()
875
self.repo._inv_thunk.reset()
876
# forget what names there are - should just refresh and deal with the
879
self.repo._open_pack_hash = None
880
self.repo._write_stream = None
838
882
class GraphKnitRevisionStore(KnitRevisionStore):
839
883
"""An object to adapt access from RevisionStore's to use GraphKnits.
1316
1360
self._packs._start_write_group()
1318
1362
def _commit_write_group(self):
1319
data_inserted = (self._revision_store.data_inserted() or
1320
self.weave_store.data_inserted() or
1321
self._inv_thunk.data_inserted())
1323
self._open_pack_writer.end()
1324
new_name = self._open_pack_hash.hexdigest()
1326
new_pack.name = new_name
1327
new_pack.transport = self._upload_transport.clone('../packs/')
1329
# new_pack.revision_index =
1330
# new_pack.inventory_index =
1331
# new_pack.text_index =
1332
# new_pack.signature_index =
1333
self.weave_store.flush(new_name, new_pack)
1334
self._inv_thunk.flush(new_name, new_pack)
1335
self._revision_store.flush(new_name, new_pack)
1336
self._write_stream.close()
1337
self._upload_transport.rename(self._open_pack_tuple[1],
1338
'../packs/' + new_name + '.pack')
1339
# If this fails, its a hash collision. We should:
1340
# - determine if its a collision or
1341
# - the same content or
1342
# - the existing name is not the actual hash - e.g.
1343
# its a deliberate attack or data corruption has
1344
# occuring during the write of that file.
1345
self._packs.allocate(new_name, new_pack.revision_index_length,
1346
new_pack.inventory_index_length, new_pack.text_index_length,
1347
new_pack.signature_index_length)
1348
self._open_pack_tuple = None
1349
if not self._packs.autopack():
1352
# remove the pending upload
1353
self._upload_transport.delete(self._open_pack_tuple[1])
1354
self._revision_store.reset()
1355
self.weave_store.reset()
1356
self._inv_thunk.reset()
1357
# forget what names there are - should just refresh and deal with the
1360
self._open_pack_hash = None
1361
self._write_stream = None
1363
return self._packs._commit_write_group()
1363
1365
def get_inventory_weave(self):
1364
1366
return self._inv_thunk.get_weave()
1435
1437
self._packs._start_write_group()
1437
1439
def _commit_write_group(self):
1438
data_inserted = (self._revision_store.data_inserted() or
1439
self.weave_store.data_inserted() or
1440
self._inv_thunk.data_inserted())
1442
self._open_pack_writer.end()
1443
new_name = self._open_pack_hash.hexdigest()
1445
new_pack.name = new_name
1446
new_pack.transport = self._upload_transport.clone('../packs/')
1448
# new_pack.revision_index =
1449
# new_pack.inventory_index =
1450
# new_pack.text_index =
1451
# new_pack.signature_index =
1452
self.weave_store.flush(new_name, new_pack)
1453
self._inv_thunk.flush(new_name, new_pack)
1454
self._revision_store.flush(new_name, new_pack)
1455
self._write_stream.close()
1456
self._upload_transport.rename(self._open_pack_tuple[1],
1457
'../packs/' + new_name + '.pack')
1458
# If this fails, its a hash collision. We should:
1459
# - determine if its a collision or
1460
# - the same content or
1461
# - the existing name is not the actual hash - e.g.
1462
# its a deliberate attack or data corruption has
1463
# occuring during the write of that file.
1464
self._packs.allocate(new_name, new_pack.revision_index_length,
1465
new_pack.inventory_index_length, new_pack.text_index_length,
1466
new_pack.signature_index_length)
1467
self._open_pack_tuple = None
1468
if not self._packs.autopack():
1471
# remove the pending upload
1472
self._upload_transport.delete(self._open_pack_tuple[1])
1473
self._revision_store.reset()
1474
self.weave_store.reset()
1475
self._inv_thunk.reset()
1476
# forget what names there are - should just refresh and deal with the
1479
self._open_pack_hash = None
1480
self._write_stream = None
1440
return self._packs._commit_write_group()
1482
1442
def get_inventory_weave(self):
1483
1443
return self._inv_thunk.get_weave()