~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Robert Collins
  • Date: 2007-11-22 00:30:29 UTC
  • mto: This revision was merged to the branch mainline in revision 3014.
  • Revision ID: robertc@robertcollins.net-20071122003029-puc7qosvic1beace
Provide file modes to files created by pack repositories

Show diffs side-by-side

added added

removed removed

Lines of Context:
187
187
        }
188
188
 
189
189
    def __init__(self, upload_transport, index_transport, pack_transport,
190
 
        upload_suffix=''):
 
190
        upload_suffix='', file_mode=None):
191
191
        """Create a NewPack instance.
192
192
 
193
193
        :param upload_transport: A writable transport for the pack to be
199
199
            upload_transport.clone('../packs').
200
200
        :param upload_suffix: An optional suffix to be given to any temporary
201
201
            files created during the pack creation. e.g '.autopack'
 
202
        :param file_mode: An optional file mode to create the new files with.
202
203
        """
203
204
        # The relative locations of the packs are constrained, but all are
204
205
        # passed in because the caller has them, so as to avoid object churn.
223
224
        self.index_transport = index_transport
224
225
        # where is the pack renamed to when it is finished?
225
226
        self.pack_transport = pack_transport
 
227
        # What file mode to upload the pack and indices with.
 
228
        self._file_mode = file_mode
226
229
        # tracks the content written to the .pack file.
227
230
        self._hash = md5.new()
228
231
        # a four-tuple with the length in bytes of the indices, once the pack
239
242
        self.start_time = time.time()
240
243
        # open an output stream for the data added to the pack.
241
244
        self.write_stream = self.upload_transport.open_write_stream(
242
 
            self.random_name)
 
245
            self.random_name, mode=self._file_mode)
243
246
        if 'pack' in debug.debug_flags:
244
247
            mutter('%s: create_pack: pack stream open: %s%s t+%6.3fs',
245
248
                time.ctime(), self.upload_transport.base, self.random_name,
368
371
        """
369
372
        index_name = self.index_name(index_type, self.name)
370
373
        self.index_sizes[self.index_offset(index_type)] = \
371
 
            self.index_transport.put_file(index_name, index.finish())
 
374
            self.index_transport.put_file(index_name, index.finish(),
 
375
            mode=self._file_mode)
372
376
        if 'pack' in debug.debug_flags:
373
377
            # XXX: size might be interesting?
374
378
            mutter('%s: create_pack: wrote %s index: %s%s t+%6.3fs',
533
537
        """Open a pack for the pack we are creating."""
534
538
        return NewPack(self._pack_collection._upload_transport,
535
539
            self._pack_collection._index_transport,
536
 
            self._pack_collection._pack_transport, upload_suffix=self.suffix)
 
540
            self._pack_collection._pack_transport, upload_suffix=self.suffix,
 
541
            file_mode=self._pack_collection.repo.control_files._file_mode)
537
542
 
538
543
    def _create_pack_from_packs(self):
539
544
        self.pb.update("Opening pack", 0, 5)
1245
1250
            # changing it.
1246
1251
            for key, value in disk_nodes:
1247
1252
                builder.add_node(key, value)
1248
 
            self.transport.put_file('pack-names', builder.finish())
 
1253
            self.transport.put_file('pack-names', builder.finish(),
 
1254
                mode=self.repo.control_files._file_mode)
1249
1255
            # move the baseline forward
1250
1256
            self._packs_at_load = disk_nodes
1251
1257
            # now clear out the obsolete packs directory
1288
1294
        if not self.repo.is_write_locked():
1289
1295
            raise errors.NotWriteLocked(self)
1290
1296
        self._new_pack = NewPack(self._upload_transport, self._index_transport,
1291
 
            self._pack_transport, upload_suffix='.pack')
 
1297
            self._pack_transport, upload_suffix='.pack',
 
1298
            file_mode=self.repo.control_files._file_mode)
1292
1299
        # allow writing: queue writes to a new index
1293
1300
        self.revision_index.add_writable_index(self._new_pack.revision_index,
1294
1301
            self._new_pack)