Exemple #1
0
    def test_upgrade_explicit_knit(self):
        # users can force an upgrade to knit format from a metadir weave
        # branch
        url = get_transport(self.get_url('metadir_weave_branch')).base
        # check --format takes effect
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
        (out, err) = self.run_bzr(['upgrade', '--format=knit', url])
        self.assertEqualDiff(
            """starting upgrade of %s
making backup of tree history
%s.bzr has been backed up to %sbackup.bzr
if conversion fails, you can move this directory back to .bzr
if it succeeds, you can remove this directory if you wish
starting repository conversion
repository converted
finished
""" % (url, url, url), out)
        self.assertEqualDiff("", err)
        converted_dir = bzrdir.BzrDir.open(
            self.get_url('metadir_weave_branch'))
        self.assertTrue(
            isinstance(converted_dir._format, bzrdir.BzrDirMetaFormat1))
        self.assertTrue(
            isinstance(converted_dir.open_repository()._format,
                       RepositoryFormatKnit1))
Exemple #2
0
 def test_repository_deprecation_warning(self):
     """Old formats give a warning"""
     # the warning's normally off for testing but we reenable it
     repository._deprecation_warning_done = False
     try:
         os.mkdir('foo')
         bzrdir.BzrDirFormat5().initialize('foo')
         out, err = self.run_bzr("status foo")
         self.assertContainsRe(self._get_log(keep_log_file=True),
                               "bzr upgrade")
     finally:
         repository._deprecation_warning_done = True
Exemple #3
0
    def setUp(self):
        super(TestWithUpgradableBranches, self).setUp()
        self.old_format = bzrdir.BzrDirFormat.get_default_format()
        self.old_ui_factory = ui.ui_factory
        self.addCleanup(self.restoreDefaults)

        ui.ui_factory = TestUIFactory()
        # setup a format 5 branch we can upgrade from.
        self.make_branch_and_tree('format_5_branch',
                                  format=bzrdir.BzrDirFormat5())

        current_tree = self.make_branch_and_tree('current_format_branch',
                                                 format='default')
        self.make_branch_and_tree('metadir_weave_branch', format='metaweave')
        current_tree.branch.create_checkout(
            self.get_url('current_format_checkout'), lightweight=True)
Exemple #4
0
class RepositoryFormat5(PreSplitOutRepositoryFormat):
    """Bzr control format 5.

    This repository format has:
     - weaves for file texts and inventory
     - flat stores
     - TextStores for revisions and signatures.
    """

    _versionedfile_class = weave.WeaveFile
    _matchingbzrdir = bzrdir.BzrDirFormat5()

    def __init__(self):
        super(RepositoryFormat5, self).__init__()
        self._fetch_order = 'topological'
        self._fetch_reconcile = True

    def get_format_description(self):
        """See RepositoryFormat.get_format_description()."""
        return "Weave repository format 5"

    def _get_inventories(self, repo_transport, repo, name='inventory'):
        mapper = versionedfile.ConstantMapper(name)
        return versionedfile.ThunkedVersionedFiles(repo_transport,
                                                   weave.WeaveFile, mapper,
                                                   repo.is_locked)

    def _get_revisions(self, repo_transport, repo):
        from bzrlib.xml5 import serializer_v5
        return RevisionTextStore(repo_transport.clone('revision-store'),
                                 serializer_v5, False,
                                 versionedfile.PrefixMapper(), repo.is_locked,
                                 repo.is_write_locked)

    def _get_signatures(self, repo_transport, repo):
        return SignatureTextStore(repo_transport.clone('revision-store'),
                                  False, versionedfile.PrefixMapper(),
                                  repo.is_locked, repo.is_write_locked)

    def _get_texts(self, repo_transport, repo):
        mapper = versionedfile.PrefixMapper()
        base_transport = repo_transport.clone('weaves')
        return versionedfile.ThunkedVersionedFiles(base_transport,
                                                   weave.WeaveFile, mapper,
                                                   repo.is_locked)
Exemple #5
0
    def test_upgrade_explicit_metaformat(self):
        # users can force an upgrade to metadir format.
        url = get_transport(self.get_url('format_5_branch')).base
        # check --format takes effect
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
        (out, err) = self.run_bzr(['upgrade', '--format=metaweave', url])
        self.assertEqualDiff(
            """starting upgrade of %s
making backup of tree history
%s.bzr has been backed up to %sbackup.bzr
if conversion fails, you can move this directory back to .bzr
if it succeeds, you can remove this directory if you wish
starting upgrade from format 5 to 6
adding prefixes to weaves
adding prefixes to revision-store
starting upgrade from format 6 to metadir
finished
""" % (url, url, url), out)
        self.assertEqualDiff("", err)
        self.assertTrue(
            isinstance(
                bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,
                bzrdir.BzrDirMetaFormat1))