~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Martin Pool
  • Date: 2007-09-21 06:43:08 UTC
  • mto: (2592.3.153 repository)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: mbp@sourcefrog.net-20070921064308-3ffuutrtw7tyzhhd
Move pack_transport and pack_name onto RepositoryPackCollection

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
class RepositoryPackCollection(object):
109
109
    """Management of packs within a repository."""
110
110
 
111
 
    def __init__(self, repo, transport, index_transport, upload_transport):
 
111
    def __init__(self, repo, transport, index_transport, upload_transport,
 
112
                 pack_transport):
112
113
        """Create a new RepositoryPackCollection.
113
114
 
114
115
        :param transport: Addresses the repository base directory 
116
117
        :param index_transport: Addresses the directory containing indexes.
117
118
        :param upload_transport: Addresses the directory into which packs are written
118
119
            while they're being created.
 
120
        :param pack_transport: Addresses the directory of existing complete packs.
119
121
        """
120
122
        self.repo = repo
121
123
        self.transport = transport
122
124
        self._index_transport = index_transport
123
125
        self._upload_transport = upload_transport
 
126
        self._pack_transport = pack_transport
124
127
        self.packs = []
125
128
 
126
129
    def add_pack_to_memory(self, pack):
672
675
            index_name = name + suffix
673
676
            new_index = GraphIndex(self._index_transport, index_name)
674
677
            indices.append(new_index)
675
 
            pack_map[new_index] = self.repo._pack_tuple(name)
 
678
            pack_map[new_index] = self._pack_tuple(name)
676
679
        return pack_map, indices
677
680
 
678
681
    def _max_pack_count(self, total_revisions):
731
734
                result.append(size)
732
735
        return list(reversed(result))
733
736
 
 
737
    def _pack_tuple(self, name):
 
738
        """Return a tuple with the transport and file name for a pack name."""
 
739
        return self._pack_transport, name + '.pack'
 
740
 
734
741
    def _remove_pack_by_name(self, name):
735
742
        # strip .pack
736
743
        self._names.pop(name[:-5])
959
966
            # sorting of the indices for better performance ?
960
967
            index_name = self.name_to_signature_index_name(name)
961
968
            indices.append(GraphIndex(self.transport, index_name))
962
 
            pack_map[indices[-1]] = (self.repo._pack_tuple(name))
 
969
            pack_map[indices[-1]] = (self.repo._packs._pack_tuple(name))
963
970
        if self.repo.is_in_write_group():
964
971
            # allow writing: queue writes to a new index
965
972
            indices.insert(0, self.repo._signature_write_index)
1006
1013
            del self.repo._revision_pack_map[self.repo._revision_write_index]
1007
1014
            self.repo._revision_write_index = None
1008
1015
            new_index = GraphIndex(self.transport, new_index_name)
1009
 
            self.repo._revision_pack_map[new_index] = (self.repo._pack_tuple(new_name))
 
1016
            self.repo._revision_pack_map[new_index] = (self.repo._packs._pack_tuple(new_name))
1010
1017
            # revisions 'knit' accessed : update it.
1011
1018
            self.repo._revision_all_indices.insert_index(0, new_index)
1012
1019
            # remove the write buffering index. XXX: API break
1121
1128
            # sorting of the indices for better performance ?
1122
1129
            index_name = self.name_to_text_index_name(name)
1123
1130
            indices.append(GraphIndex(self.transport, index_name))
1124
 
            self.repo._text_pack_map[indices[-1]] = (self.repo._pack_tuple(name))
 
1131
            self.repo._text_pack_map[indices[-1]] = (self.repo._packs._pack_tuple(name))
1125
1132
        if for_write or self.repo.is_in_write_group():
1126
1133
            # allow writing: queue writes to a new index
1127
1134
            indices.insert(0, self.repo._text_write_index)
1253
1260
            # sorting of the indices for better performance ?
1254
1261
            index_name = self.name_to_inv_index_name(name)
1255
1262
            indices.append(GraphIndex(self.transport, index_name))
1256
 
            pack_map[indices[-1]] = (self.repo._pack_tuple(name))
 
1263
            pack_map[indices[-1]] = (self.repo._packs._pack_tuple(name))
1257
1264
        if self.repo.is_in_write_group():
1258
1265
            # allow writing: queue writes to a new index
1259
1266
            indices.append(self.repo._inv_write_index)
1342
1349
        index_transport = control_files._transport.clone('indices')
1343
1350
        self._packs = RepositoryPackCollection(self, control_files._transport,
1344
1351
            index_transport,
1345
 
            control_files._transport.clone('upload'))
 
1352
            control_files._transport.clone('upload'),
 
1353
            control_files._transport.clone('packs'))
1346
1354
        self._revision_store = GraphKnitRevisionStore(self, index_transport, self._revision_store)
1347
1355
        self.weave_store = GraphKnitTextStore(self, index_transport, self.weave_store)
1348
1356
        self._inv_thunk = InventoryKnitThunk(self, index_transport)
1349
 
        self._pack_transport = control_files._transport.clone('packs')
1350
1357
        # for tests
1351
1358
        self._reconcile_does_inventory_gc = False
1352
1359
 
1353
1360
    def _abort_write_group(self):
1354
1361
        self._packs._abort_write_group()
1355
1362
 
1356
 
    def _pack_tuple(self, name):
1357
 
        """Return a tuple with the transport and file name for a pack name."""
1358
 
        return self._pack_transport, name + '.pack'
1359
 
 
1360
1363
    def _refresh_data(self):
1361
1364
        if self.control_files._lock_count==1:
1362
1365
            self._revision_store.reset()
1413
1416
        index_transport = control_files._transport.clone('indices')
1414
1417
        self._packs = RepositoryPackCollection(self, control_files._transport,
1415
1418
            index_transport,
1416
 
            control_files._transport.clone('upload'))
 
1419
            control_files._transport.clone('upload'),
 
1420
            control_files._transport.clone('packs'))
1417
1421
        self._revision_store = GraphKnitRevisionStore(self, index_transport, self._revision_store)
1418
1422
        self.weave_store = GraphKnitTextStore(self, index_transport, self.weave_store)
1419
1423
        self._inv_thunk = InventoryKnitThunk(self, index_transport)
1420
 
        self._pack_transport = control_files._transport.clone('packs')
1421
1424
        # for tests
1422
1425
        self._reconcile_does_inventory_gc = False
1423
1426
 
1424
1427
    def _abort_write_group(self):
1425
1428
        return self._packs._abort_write_group()
1426
1429
 
1427
 
    def _pack_tuple(self, name):
1428
 
        """Return a tuple with the transport and file name for a pack name."""
1429
 
        return self._pack_transport, name + '.pack'
1430
 
 
1431
1430
    def _refresh_data(self):
1432
1431
        if self.control_files._lock_count==1:
1433
1432
            self._revision_store.reset()