def testSourceFormatChange(self):
        # If a branch that has already been mirrored changes format, then we
        # when we re-mirror the branch, the mirror will acquire the new
        # format.

        # Create and mirror a branch in weave format.
        self._createSourceBranch(RepositoryFormat7(), BzrDirMetaFormat1())
        self.worker.mirror()

        # Change the branch to knit format and mirror again.
        self.get_transport().delete_tree(self._source_branch_path)
        self._createSourceBranch(RepositoryFormatKnit1(), BzrDirMetaFormat1())
        self.worker.mirror()

        # The mirrored branch should now be in knit format.
        self.assertMirrored(
            Branch.open(self.worker.source), Branch.open(self.worker.dest))
Exemplo n.º 2
0
    def test_push_only_pushes_history(self):
        # Knit branches should only push the history for the current revision.
        format = BzrDirMetaFormat1()
        format.repository_format = RepositoryFormatKnit1()
        shared_repo = self.make_repository('repo', format=format, shared=True)
        shared_repo.set_make_working_trees(True)

        def make_shared_tree(path):
            shared_repo.bzrdir.root_transport.mkdir(path)
            shared_repo.bzrdir.create_branch_convenience('repo/' + path)
            return WorkingTree.open('repo/' + path)

        tree_a = make_shared_tree('a')
        self.build_tree(['repo/a/file'])
        tree_a.add('file')
        tree_a.commit('commit a-1', rev_id='a-1')
        f = open('repo/a/file', 'ab')
        f.write('more stuff\n')
        f.close()
        tree_a.commit('commit a-2', rev_id='a-2')

        tree_b = make_shared_tree('b')
        self.build_tree(['repo/b/file'])
        tree_b.add('file')
        tree_b.commit('commit b-1', rev_id='b-1')

        self.assertTrue(shared_repo.has_revision('a-1'))
        self.assertTrue(shared_repo.has_revision('a-2'))
        self.assertTrue(shared_repo.has_revision('b-1'))

        # Now that we have a repository with shared files, make sure
        # that things aren't copied out by a 'push'
        os.chdir('repo/b')
        self.run_bzr('push ../../push-b')
        pushed_tree = WorkingTree.open('../../push-b')
        pushed_repo = pushed_tree.branch.repository
        self.assertFalse(pushed_repo.has_revision('a-1'))
        self.assertFalse(pushed_repo.has_revision('a-2'))
        self.assertTrue(pushed_repo.has_revision('b-1'))
 def testMirrorKnitAsKnit(self):
     # Create a source branch in knit format, and check that the mirror is
     # in knit format.
     self._testMirrorWithFormats(
         RepositoryFormatKnit1(), BzrDirMetaFormat1())