/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Robert Collins
  • Date: 2007-11-27 20:35:02 UTC
  • mfrom: (3036 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3038.
  • Revision ID: robertc@robertcollins.net-20071127203502-280mxe1zvdlagrpe
Merge with bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    osutils,
49
49
    transactions,
50
50
    xml5,
 
51
    xml6,
51
52
    xml7,
52
53
    )
53
54
 
187
188
        }
188
189
 
189
190
    def __init__(self, upload_transport, index_transport, pack_transport,
190
 
        upload_suffix=''):
 
191
        upload_suffix='', file_mode=None):
191
192
        """Create a NewPack instance.
192
193
 
193
194
        :param upload_transport: A writable transport for the pack to be
199
200
            upload_transport.clone('../packs').
200
201
        :param upload_suffix: An optional suffix to be given to any temporary
201
202
            files created during the pack creation. e.g '.autopack'
 
203
        :param file_mode: An optional file mode to create the new files with.
202
204
        """
203
205
        # The relative locations of the packs are constrained, but all are
204
206
        # passed in because the caller has them, so as to avoid object churn.
223
225
        self.index_transport = index_transport
224
226
        # where is the pack renamed to when it is finished?
225
227
        self.pack_transport = pack_transport
 
228
        # What file mode to upload the pack and indices with.
 
229
        self._file_mode = file_mode
226
230
        # tracks the content written to the .pack file.
227
231
        self._hash = md5.new()
228
232
        # a four-tuple with the length in bytes of the indices, once the pack
239
243
        self.start_time = time.time()
240
244
        # open an output stream for the data added to the pack.
241
245
        self.write_stream = self.upload_transport.open_write_stream(
242
 
            self.random_name)
 
246
            self.random_name, mode=self._file_mode)
243
247
        if 'pack' in debug.debug_flags:
244
248
            mutter('%s: create_pack: pack stream open: %s%s t+%6.3fs',
245
249
                time.ctime(), self.upload_transport.base, self.random_name,
368
372
        """
369
373
        index_name = self.index_name(index_type, self.name)
370
374
        self.index_sizes[self.index_offset(index_type)] = \
371
 
            self.index_transport.put_file(index_name, index.finish())
 
375
            self.index_transport.put_file(index_name, index.finish(),
 
376
            mode=self._file_mode)
372
377
        if 'pack' in debug.debug_flags:
373
378
            # XXX: size might be interesting?
374
379
            mutter('%s: create_pack: wrote %s index: %s%s t+%6.3fs',
533
538
        """Open a pack for the pack we are creating."""
534
539
        return NewPack(self._pack_collection._upload_transport,
535
540
            self._pack_collection._index_transport,
536
 
            self._pack_collection._pack_transport, upload_suffix=self.suffix)
 
541
            self._pack_collection._pack_transport, upload_suffix=self.suffix,
 
542
            file_mode=self._pack_collection.repo.control_files._file_mode)
537
543
 
538
544
    def _create_pack_from_packs(self):
539
545
        self.pb.update("Opening pack", 0, 5)
1245
1251
            # changing it.
1246
1252
            for key, value in disk_nodes:
1247
1253
                builder.add_node(key, value)
1248
 
            self.transport.put_file('pack-names', builder.finish())
 
1254
            self.transport.put_file('pack-names', builder.finish(),
 
1255
                mode=self.repo.control_files._file_mode)
1249
1256
            # move the baseline forward
1250
1257
            self._packs_at_load = disk_nodes
1251
1258
            # now clear out the obsolete packs directory
1288
1295
        if not self.repo.is_write_locked():
1289
1296
            raise errors.NotWriteLocked(self)
1290
1297
        self._new_pack = NewPack(self._upload_transport, self._index_transport,
1291
 
            self._pack_transport, upload_suffix='.pack')
 
1298
            self._pack_transport, upload_suffix='.pack',
 
1299
            file_mode=self.repo.control_files._file_mode)
1292
1300
        # allow writing: queue writes to a new index
1293
1301
        self.revision_index.add_writable_index(self._new_pack.revision_index,
1294
1302
            self._new_pack)
1804
1812
    _serializer = xml5.serializer_v5
1805
1813
 
1806
1814
    def _get_matching_bzrdir(self):
1807
 
        return bzrdir.format_registry.make_bzrdir('knitpack-experimental')
 
1815
        return bzrdir.format_registry.make_bzrdir('pack-0.92')
1808
1816
 
1809
1817
    def _ignore_setting_bzrdir(self, format):
1810
1818
        pass
1841
1849
 
1842
1850
    def _get_matching_bzrdir(self):
1843
1851
        return bzrdir.format_registry.make_bzrdir(
1844
 
            'knitpack-subtree-experimental')
 
1852
            'pack-0.92-subtree')
1845
1853
 
1846
1854
    def _ignore_setting_bzrdir(self, format):
1847
1855
        pass
1863
1871
    def get_format_description(self):
1864
1872
        """See RepositoryFormat.get_format_description()."""
1865
1873
        return "Packs containing knits with subtree support\n"
 
1874
 
 
1875
 
 
1876
class RepositoryFormatKnitPack4(RepositoryFormatPack):
 
1877
    """A rich-root, no subtrees parameterised Pack repository.
 
1878
 
 
1879
    This repository format uses the xml6 serializer to get:
 
1880
     - support for recording full info about the tree root
 
1881
 
 
1882
    This format was introduced in 1.0.
 
1883
    """
 
1884
 
 
1885
    repository_class = KnitPackRepository
 
1886
    _commit_builder_class = PackRootCommitBuilder
 
1887
    rich_root_data = True
 
1888
    supports_tree_reference = False
 
1889
    _serializer = xml6.serializer_v6
 
1890
 
 
1891
    def _get_matching_bzrdir(self):
 
1892
        return bzrdir.format_registry.make_bzrdir(
 
1893
            'rich-root-pack')
 
1894
 
 
1895
    def _ignore_setting_bzrdir(self, format):
 
1896
        pass
 
1897
 
 
1898
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
1899
 
 
1900
    def check_conversion_target(self, target_format):
 
1901
        if not target_format.rich_root_data:
 
1902
            raise errors.BadConversionTarget(
 
1903
                'Does not support rich root data.', target_format)
 
1904
 
 
1905
    def get_format_string(self):
 
1906
        """See RepositoryFormat.get_format_string()."""
 
1907
        return ("Bazaar pack repository format 1 with rich root"
 
1908
                " (needs bzr 1.0)\n")
 
1909
 
 
1910
    def get_format_description(self):
 
1911
        """See RepositoryFormat.get_format_description()."""
 
1912
        return "Packs containing knits with rich root support\n"