Example #1
0
    def test_stack_upgrade(self):
        """Correct checks when stacked-on repository is upgraded.

        We initially stack on a repo with the same rich root support,
        we then upgrade it and should fail, we then upgrade the overlaid
        repository.
        """
        base = self.make_branch_and_tree('base',
                                         format=self.scenario_old_format)
        self.build_tree(['base/foo'])
        base.commit('base commit')
        # make another one stacked
        stacked = base.bzrdir.sprout('stacked', stacked=True)
        # this must really be stacked (or get_stacked_on_url raises an error)
        self.assertTrue(stacked.open_branch().get_stacked_on_url())
        # now we'll upgrade the underlying branch, then upgrade the stacked
        # branch, and this should still work.
        new_format = controldir.format_registry.make_bzrdir(
            self.scenario_new_format)
        upgrade('base', new_format)
        # in some cases you'll get an error if the underlying model has
        # changed; if just the data format has changed this should still work
        if self.scenario_model_change:
            self.assertRaises(errors.IncompatibleRepositories,
                              stacked.open_branch)
        else:
            check.check_dwim('stacked', False, True, True)
        stacked = controldir.ControlDir.open('stacked')
        # but we can upgrade the stacked repository
        upgrade('stacked', new_format)
        # and now it opens ok
        stacked = controldir.ControlDir.open('stacked')
        # And passes check.
        check.check_dwim('stacked', False, True, True)
Example #2
0
    def test_merge_new_file(self):
        """Commit merge of two trees with no overlapping files."""
        wtx = self.make_branch_and_tree("x")
        base_rev = wtx.commit("common parent")
        bx = wtx.branch
        wtx.commit("establish root id")
        wty = wtx.bzrdir.sprout("y").open_workingtree()
        self.assertEqual(wtx.get_root_id(), wty.get_root_id())
        by = wty.branch

        self.build_tree(["x/ecks", "y/why"])

        wtx.add(["ecks"], ["ecks-id"])
        wty.add(["why"], ["why-id"])

        wtx.commit("commit one", rev_id="x@u-0-1", allow_pointless=True)
        wty.commit("commit two", rev_id="y@u-0-1", allow_pointless=True)

        wty.merge_from_branch(bx)

        # partial commit of merges is currently not allowed, because
        # it would give different merge graphs for each file which
        # might be complex.  it can be allowed in the future.
        self.assertRaises(Exception, wty.commit, "partial commit", allow_pointless=False, specific_files=["ecks"])

        wty.commit("merge from x", rev_id="y@u-0-2", allow_pointless=False)
        tree = by.repository.revision_tree("y@u-0-2")
        self.assertEquals(tree.get_file_revision("ecks-id"), "x@u-0-1")
        self.assertEquals(tree.get_file_revision("why-id"), "y@u-0-1")

        check.check_dwim(bx.base, False, True, True)
        check.check_dwim(by.base, False, True, True)
    def test_stack_upgrade(self):
        """Correct checks when stacked-on repository is upgraded.

        We initially stack on a repo with the same rich root support,
        we then upgrade it and should fail, we then upgrade the overlaid
        repository.
        """
        base = self.make_branch_and_tree("base", format=self.scenario_old_format)
        self.build_tree(["base/foo"])
        base.commit("base commit")
        # make another one stacked
        stacked = base.bzrdir.sprout("stacked", stacked=True)
        # this must really be stacked (or get_stacked_on_url raises an error)
        self.assertTrue(stacked.open_branch().get_stacked_on_url())
        # now we'll upgrade the underlying branch, then upgrade the stacked
        # branch, and this should still work.
        new_format = controldir.format_registry.make_bzrdir(self.scenario_new_format)
        upgrade("base", new_format)
        # in some cases you'll get an error if the underlying model has
        # changed; if just the data format has changed this should still work
        if self.scenario_model_change:
            self.assertRaises(errors.IncompatibleRepositories, stacked.open_branch)
        else:
            check.check_dwim("stacked", False, True, True)
        stacked = controldir.ControlDir.open("stacked")
        # but we can upgrade the stacked repository
        upgrade("stacked", new_format)
        # and now it opens ok
        stacked = controldir.ControlDir.open("stacked")
        # And passes check.
        check.check_dwim("stacked", False, True, True)
Example #4
0
    def test_push_with_default_stacking_does_not_create_broken_branch(self):
        """Pushing a new standalone branch works even when there's a default
        stacking policy at the destination.

        The new branch will preserve the repo format (even if it isn't the
        default for the branch), and will be stacked when the repo format
        allows (which means that the branch format isn't necessarly preserved).
        """
        if self.bzrdir_format.fixed_components:
            raise tests.TestNotApplicable('Not a metadir format.')
        if isinstance(self.branch_format, branch.BranchReferenceFormat):
            # This test could in principle apply to BranchReferenceFormat, but
            # make_branch_builder doesn't support it.
            raise tests.TestSkipped(
                "BranchBuilder can't make reference branches.")
        # Make a branch called "local" in a stackable repository
        # The branch has 3 revisions:
        #   - rev-1, adds a file
        #   - rev-2, no changes
        #   - rev-3, modifies the file.
        repo = self.make_repository('repo', shared=True, format='1.6')
        builder = self.make_branch_builder('repo/local')
        builder.start_series()
        builder.build_snapshot('rev-1', None,
                               [('add', ('', 'root-id', 'directory', '')),
                                ('add',
                                 ('filename', 'f-id', 'file', 'content\n'))])
        builder.build_snapshot('rev-2', ['rev-1'], [])
        builder.build_snapshot('rev-3', ['rev-2'],
                               [('modify', ('f-id', 'new-content\n'))])
        builder.finish_series()
        trunk = builder.get_branch()
        # Sprout rev-1 to "trunk", so that we can stack on it.
        trunk.bzrdir.sprout(self.get_url('trunk'), revision_id='rev-1')
        # Set a default stacking policy so that new branches will automatically
        # stack on trunk.
        self.make_bzrdir('.').get_config().set_default_stack_on('trunk')
        # Push rev-2 to a new branch "remote".  It will be stacked on "trunk".
        output = StringIO()
        push._show_push_branch(trunk, 'rev-2', self.get_url('remote'), output)
        # Push rev-3 onto "remote".  If "remote" not stacked and is missing the
        # fulltext record for f-id @ rev-1, then this will fail.
        remote_branch = branch.Branch.open(self.get_url('remote'))
        trunk.push(remote_branch)
        check.check_dwim(remote_branch.base, False, True, True)
Example #5
0
    def test_push_with_default_stacking_does_not_create_broken_branch(self):
        """Pushing a new standalone branch works even when there's a default
        stacking policy at the destination.

        The new branch will preserve the repo format (even if it isn't the
        default for the branch), and will be stacked when the repo format
        allows (which means that the branch format isn't necessarly preserved).
        """
        if self.bzrdir_format.fixed_components:
            raise tests.TestNotApplicable('Not a metadir format.')
        if isinstance(self.branch_format, branch.BranchReferenceFormat):
            # This test could in principle apply to BranchReferenceFormat, but
            # make_branch_builder doesn't support it.
            raise tests.TestSkipped(
                "BranchBuilder can't make reference branches.")
        # Make a branch called "local" in a stackable repository
        # The branch has 3 revisions:
        #   - rev-1, adds a file
        #   - rev-2, no changes
        #   - rev-3, modifies the file.
        repo = self.make_repository('repo', shared=True, format='1.6')
        builder = self.make_branch_builder('repo/local')
        builder.start_series()
        builder.build_snapshot('rev-1', None, [
            ('add', ('', 'root-id', 'directory', '')),
            ('add', ('filename', 'f-id', 'file', 'content\n'))])
        builder.build_snapshot('rev-2', ['rev-1'], [])
        builder.build_snapshot('rev-3', ['rev-2'],
            [('modify', ('f-id', 'new-content\n'))])
        builder.finish_series()
        trunk = builder.get_branch()
        # Sprout rev-1 to "trunk", so that we can stack on it.
        trunk.bzrdir.sprout(self.get_url('trunk'), revision_id='rev-1')
        # Set a default stacking policy so that new branches will automatically
        # stack on trunk.
        self.make_bzrdir('.').get_config().set_default_stack_on('trunk')
        # Push rev-2 to a new branch "remote".  It will be stacked on "trunk".
        output = StringIO()
        push._show_push_branch(trunk, 'rev-2', self.get_url('remote'), output)
        # Push rev-3 onto "remote".  If "remote" not stacked and is missing the
        # fulltext record for f-id @ rev-1, then this will fail.
        remote_branch = branch.Branch.open(self.get_url('remote'))
        trunk.push(remote_branch)
        check.check_dwim(remote_branch.base, False, True, True)
 def test_pull_delta_when_stacked(self):
     if not self.branch_format.supports_stacking():
         raise TestNotApplicable("%r does not support stacking" %
                                 self.branch_format)
     stack_on = self.make_branch_and_tree('stack-on')
     text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
     self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
     stack_on.add('a')
     stack_on.commit('base commit')
     # make a stacked branch from the mainline
     stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
     stacked_tree = stacked_dir.open_workingtree()
     # make a second non-stacked branch from the mainline
     other_dir = stack_on.bzrdir.sprout('other')
     other_tree = other_dir.open_workingtree()
     text_lines[9] = 'changed in other\n'
     self.build_tree_contents([('other/a', ''.join(text_lines))])
     stacked_revid = other_tree.commit('commit in other')
     # this should have generated a delta; try to pull that across
     # bug 252821 caused a RevisionNotPresent here...
     stacked_tree.pull(other_tree.branch)
     stacked_tree.branch.repository.pack()
     check.check_dwim(stacked_tree.branch.base, False, True, True)
     self.check_lines_added_or_present(stacked_tree.branch, stacked_revid)
 def test_autopack_when_stacked(self):
     # in bzr.dev as of 20080730, autopack was reported to fail in stacked
     # repositories because of problems with text deltas spanning physical
     # repository boundaries.  however, i didn't actually get this test to
     # fail on that code. -- mbp
     # see https://bugs.launchpad.net/bzr/+bug/252821
     stack_on = self.make_branch_and_tree('stack-on')
     if not stack_on.branch._format.supports_stacking():
         raise TestNotApplicable("%r does not support stacking" %
                                 self.branch_format)
     text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
     self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
     stack_on.add('a')
     stack_on.commit('base commit')
     stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
     stacked_branch = stacked_dir.open_branch()
     local_tree = stack_on.bzrdir.sprout('local').open_workingtree()
     for i in range(20):
         text_lines[0] = 'changed in %d\n' % i
         self.build_tree_contents([('local/a', ''.join(text_lines))])
         local_tree.commit('commit %d' % i)
         local_tree.branch.push(stacked_branch)
     stacked_branch.repository.pack()
     check.check_dwim(stacked_branch.base, False, True, True)
Example #8
0
    def test_merge_new_file(self):
        """Commit merge of two trees with no overlapping files."""
        wtx = self.make_branch_and_tree('x')
        base_rev = wtx.commit('common parent')
        bx = wtx.branch
        wtx.commit('establish root id')
        wty = wtx.bzrdir.sprout('y').open_workingtree()
        self.assertEqual(wtx.get_root_id(), wty.get_root_id())
        by = wty.branch

        self.build_tree(['x/ecks', 'y/why'])

        wtx.add(['ecks'], ['ecks-id'])
        wty.add(['why'], ['why-id'])

        wtx.commit('commit one', rev_id='x@u-0-1', allow_pointless=True)
        wty.commit('commit two', rev_id='y@u-0-1', allow_pointless=True)

        wty.merge_from_branch(bx)

        # partial commit of merges is currently not allowed, because
        # it would give different merge graphs for each file which
        # might be complex.  it can be allowed in the future.
        self.assertRaises(Exception,
                          wty.commit,
                          'partial commit',
                          allow_pointless=False,
                          specific_files=['ecks'])

        wty.commit('merge from x', rev_id='y@u-0-2', allow_pointless=False)
        tree = by.repository.revision_tree('y@u-0-2')
        self.assertEqual(tree.get_file_revision('ecks-id'), 'x@u-0-1')
        self.assertEqual(tree.get_file_revision('why-id'), 'y@u-0-1')

        check.check_dwim(bx.base, False, True, True)
        check.check_dwim(by.base, False, True, True)
Example #9
0
 def test_pull_delta_when_stacked(self):
     if not self.branch_format.supports_stacking():
         raise TestNotApplicable("%r does not support stacking"
             % self.branch_format)
     stack_on = self.make_branch_and_tree('stack-on')
     text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
     self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
     stack_on.add('a')
     stack_on.commit('base commit')
     # make a stacked branch from the mainline
     stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
     stacked_tree = stacked_dir.open_workingtree()
     # make a second non-stacked branch from the mainline
     other_dir = stack_on.bzrdir.sprout('other')
     other_tree = other_dir.open_workingtree()
     text_lines[9] = 'changed in other\n'
     self.build_tree_contents([('other/a', ''.join(text_lines))])
     stacked_revid = other_tree.commit('commit in other')
     # this should have generated a delta; try to pull that across
     # bug 252821 caused a RevisionNotPresent here...
     stacked_tree.pull(other_tree.branch)
     stacked_tree.branch.repository.pack()
     check.check_dwim(stacked_tree.branch.base, False, True, True)
     self.check_lines_added_or_present(stacked_tree.branch, stacked_revid)
Example #10
0
 def test_autopack_when_stacked(self):
     # in bzr.dev as of 20080730, autopack was reported to fail in stacked
     # repositories because of problems with text deltas spanning physical
     # repository boundaries.  however, i didn't actually get this test to
     # fail on that code. -- mbp
     # see https://bugs.launchpad.net/bzr/+bug/252821
     stack_on = self.make_branch_and_tree('stack-on')
     if not stack_on.branch._format.supports_stacking():
         raise TestNotApplicable("%r does not support stacking"
             % self.branch_format)
     text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
     self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
     stack_on.add('a')
     stack_on.commit('base commit')
     stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
     stacked_branch = stacked_dir.open_branch()
     local_tree = stack_on.bzrdir.sprout('local').open_workingtree()
     for i in range(20):
         text_lines[0] = 'changed in %d\n' % i
         self.build_tree_contents([('local/a', ''.join(text_lines))])
         local_tree.commit('commit %d' % i)
         local_tree.branch.push(stacked_branch)
     stacked_branch.repository.pack()
     check.check_dwim(stacked_branch.base, False, True, True)