Пример #1
0
 def test_convert(self):
     """Ensure the upgrade adds weaves for roots"""
     format = bzrdir.BzrDirMetaFormat1()
     format.repository_format = knitrepo.RepositoryFormatKnit1()
     tree = self.make_branch_and_tree('.', format)
     tree.commit("Dull commit", rev_id="dull")
     revision_tree = tree.branch.repository.revision_tree('dull')
     revision_tree.lock_read()
     try:
         self.assertRaises(errors.NoSuchFile, revision_tree.get_file_lines,
             revision_tree.inventory.root.file_id)
     finally:
         revision_tree.unlock()
     format = bzrdir.BzrDirMetaFormat1()
     format.repository_format = knitrepo.RepositoryFormatKnit3()
     upgrade.Convert('.', format)
     tree = workingtree.WorkingTree.open('.')
     revision_tree = tree.branch.repository.revision_tree('dull')
     revision_tree.lock_read()
     try:
         revision_tree.get_file_lines(revision_tree.inventory.root.file_id)
     finally:
         revision_tree.unlock()
     tree.commit("Another dull commit", rev_id='dull2')
     revision_tree = tree.branch.repository.revision_tree('dull2')
     revision_tree.lock_read()
     self.addCleanup(revision_tree.unlock)
     self.assertEqual('dull', revision_tree.inventory.root.revision)
Пример #2
0
    def test_checkout_reconstitutes_working_trees(self):
        # doing a 'bzr checkout' in the directory of a branch with no tree
        # or a 'bzr checkout path' with path the name of a directory with
        # a branch with no tree will reconsistute the tree.
        os.mkdir('treeless-branch')
        branch = bzrdir.BzrDir.create_branch_convenience(
            'treeless-branch',
            force_new_tree=False,
            format=bzrdir.BzrDirMetaFormat1())
        # check no tree was created
        self.assertRaises(errors.NoWorkingTree, branch.bzrdir.open_workingtree)
        out, err = self.run_bzr('checkout treeless-branch')
        # we should have a tree now
        branch.bzrdir.open_workingtree()
        # with no diff
        out, err = self.run_bzr('diff treeless-branch')

        # now test with no parameters
        branch = bzrdir.BzrDir.create_branch_convenience(
            '.', force_new_tree=False, format=bzrdir.BzrDirMetaFormat1())
        # check no tree was created
        self.assertRaises(errors.NoWorkingTree, branch.bzrdir.open_workingtree)
        out, err = self.run_bzr('checkout')
        # we should have a tree now
        branch.bzrdir.open_workingtree()
        # with no diff
        out, err = self.run_bzr('diff')
Пример #3
0
 def test_update_returns_conflict_count(self):
     # working tree formats from the meta-dir format and newer support
     # setting the last revision on a tree independently of that on the
     # branch. Its concievable that some future formats may want to
     # couple them again (i.e. because its really a smart server and
     # the working tree will always match the branch). So we test
     # that formats where initialising a branch does not initialise a
     # tree - and thus have separable entities - support skewing the
     # two things.
     main_branch = self.make_branch('tree')
     try:
         # if there is a working tree now, this is not supported.
         main_branch.bzrdir.open_workingtree()
         return
     except errors.NoWorkingTree:
         pass
     wt = main_branch.bzrdir.create_workingtree()
     # create an out of date working tree by making a checkout in this
     # current format
     self.build_tree(['checkout/', 'tree/file'])
     checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
     branch.BranchReferenceFormat().initialize(checkout, main_branch)
     old_tree = self.workingtree_format.initialize(checkout)
     # now commit to 'tree'
     wt.add('file')
     wt.commit('A', rev_id='A')
     # and add a file file to the checkout
     self.build_tree(['checkout/file'])
     old_tree.add('file')
     # and update old_tree
     self.assertEqual(1, old_tree.update())
     self.assertEqual(['A'], old_tree.get_parent_ids())
Пример #4
0
    def assertInitializeEx(self, t, need_meta=False, **kwargs):
        """Execute initialize_on_transport_ex and check it succeeded correctly.

        This involves checking that the disk objects were created, open with
        the same format returned, and had the expected disk format.

        :param t: The transport to initialize on.
        :param **kwargs: Additional arguments to pass to
            initialize_on_transport_ex.
        :return: the resulting repo, control dir tuple.
        """
        if not self.bzrdir_format.is_initializable():
            raise TestNotApplicable("control dir format is not "
                "initializable")
        repo, control, require_stacking, repo_policy = \
            self.bzrdir_format.initialize_on_transport_ex(t, **kwargs)
        if repo is not None:
            # Repositories are open write-locked
            self.assertTrue(repo.is_write_locked())
            self.addCleanup(repo.unlock)
        self.assertIsInstance(control, bzrdir.BzrDir)
        opened = bzrdir.BzrDir.open(t.base)
        expected_format = self.bzrdir_format
        if need_meta and expected_format.fixed_components:
            # Pre-metadir formats change when we are making something that
            # needs a metaformat, because clone is used for push.
            expected_format = bzrdir.BzrDirMetaFormat1()
        if not isinstance(expected_format, RemoteBzrDirFormat):
            self.assertEqual(control._format.network_name(),
                expected_format.network_name())
            self.assertEqual(control._format.network_name(),
                opened._format.network_name())
        self.assertEqual(control.__class__, opened.__class__)
        return repo, control
Пример #5
0
 def test_upgrade_v6_to_meta_no_workingtree(self):
     # Some format6 branches do not have checkout files. Upgrading
     # such a branch to metadir must not setup a working tree.
     self.build_tree_contents(_upgrade1_template)
     upgrade('.', bzrdir.BzrDirFormat6())
     transport = get_transport('.')
     transport.delete_multi(['.bzr/pending-merges', '.bzr/inventory'])
     self.assertFalse(transport.has('.bzr/stat-cache'))
     # XXX: upgrade fails if a backup.bzr is already present
     # -- David Allouche 2006-08-11
     transport.delete_tree('backup.bzr')
     # At this point, we have a format6 branch without checkout files.
     upgrade('.', bzrdir.BzrDirMetaFormat1())
     # The upgrade should not have set up a working tree.
     control = bzrdir.BzrDir.open('.')
     self.assertFalse(control.has_workingtree())
     # We have covered the scope of this test, we may as well check that
     # upgrade has not eaten our data, even if it's a bit redundant with
     # other tests.
     self.failUnless(isinstance(control._format, bzrdir.BzrDirMetaFormat1))
     branch = control.open_branch()
     self.assertEquals(branch.revision_history(), [
         '[email protected]',
         '[email protected]'
     ])
Пример #6
0
 def test_reweave_empty(self):
     # we want a repo capable format
     parent = bzrdir.BzrDirMetaFormat1().initialize('.')
     parent.create_repository(shared=True)
     parent.root_transport.mkdir('child')
     child = bzrdir.BzrDirMetaFormat1().initialize('child')
     self.assertRaises(errors.NoRepositoryPresent, child.open_repository)
     reconciler = Reconciler(child)
     reconciler.reconcile()
     # smoke test for reconcile appears to work too.
     reconcile(child)
     # no inconsistent parents should have been found
     # but the values should have been set.
     self.assertEqual(0, reconciler.inconsistent_parents)
     # and no garbage inventories
     self.assertEqual(0, reconciler.garbage_inventories)
Пример #7
0
 def convert(self, to_convert, pb):
     ui.ui_factory.note('starting upgrade from old test format to 2a')
     to_convert.control_transport.put_bytes(
         'branch-format',
         bzrdir.BzrDirMetaFormat1().get_format_string(),
         mode=to_convert._get_file_mode())
     return controldir.ControlDir.open(to_convert.user_url)
Пример #8
0
 def test_find_format_unknown_format(self):
     dir = bzrdir.BzrDirMetaFormat1().initialize('.')
     dir.create_repository()
     dir.create_branch()
     SampleTreeFormat().initialize(dir)
     self.assertRaises(errors.UnknownFormatError,
                       workingtree.WorkingTreeFormat.find_format, dir)
Пример #9
0
 def test_get_set_default_format(self):
     old_default = bzrdir.format_registry.get('default')
     private_default = old_default().repository_format.__class__
     old_format = repository.RepositoryFormat.get_default_format()
     self.assertTrue(isinstance(old_format, private_default))
     def make_sample_bzrdir():
         my_bzrdir = bzrdir.BzrDirMetaFormat1()
         my_bzrdir.repository_format = SampleRepositoryFormat()
         return my_bzrdir
     bzrdir.format_registry.remove('default')
     bzrdir.format_registry.register('sample', make_sample_bzrdir, '')
     bzrdir.format_registry.set_default('sample')
     # creating a repository should now create an instrumented dir.
     try:
         # the default branch format is used by the meta dir format
         # which is not the default bzrdir format at this point
         dir = bzrdir.BzrDirMetaFormat1().initialize('memory:///')
         result = dir.create_repository()
         self.assertEqual(result, 'A bzr repository dir')
     finally:
         bzrdir.format_registry.remove('default')
         bzrdir.format_registry.remove('sample')
         bzrdir.format_registry.register('default', old_default, '')
     self.assertIsInstance(repository.RepositoryFormat.get_default_format(),
                           old_format.__class__)
Пример #10
0
 def test_upgrade_to_meta_sets_workingtree_last_revision(self):
     self.build_tree_contents(_upgrade_dir_template)
     upgrade.upgrade('.', bzrdir.BzrDirMetaFormat1())
     tree = workingtree.WorkingTree.open('.')
     self.addCleanup(tree.lock_read().unlock)
     self.assertEqual([tree.branch._revision_history()[-1]],
         tree.get_parent_ids())
Пример #11
0
 def test_missing_pending_merges(self):
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     control.create_repository()
     control.create_branch()
     tree = workingtree.WorkingTreeFormat3().initialize(control)
     tree._transport.delete("pending-merges")
     self.assertEqual([], tree.get_parent_ids())
Пример #12
0
 def test_disk_layout(self):
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = knitrepo.RepositoryFormatKnit1().initialize(control)
     # in case of side effects of locking.
     repo.lock_write()
     repo.unlock()
     # we want:
     # format 'Bazaar-NG Knit Repository Format 1'
     # lock: is a directory
     # inventory.weave == empty_weave
     # empty revision-store directory
     # empty weaves directory
     t = control.get_repository_transport(None)
     self.assertEqualDiff('Bazaar-NG Knit Repository Format 1',
                          t.get('format').read())
     # XXX: no locks left when unlocked at the moment
     # self.assertEqualDiff('', t.get('lock').read())
     self.assertTrue(S_ISDIR(t.stat('knits').st_mode))
     self.check_knits(t)
     # Check per-file knits.
     branch = control.create_branch()
     tree = control.create_workingtree()
     tree.add(['foo'], ['Nasty-IdC:'], ['file'])
     tree.put_file_bytes_non_atomic('Nasty-IdC:', '')
     tree.commit('1st post', rev_id='foo')
     self.assertHasKnit(t, 'knits/e8/%254easty-%2549d%2543%253a',
         '\nfoo fulltext 0 81  :')
Пример #13
0
 def test_shared_no_tree_disk_layout(self):
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
     repo.set_make_working_trees(False)
     # we want:
     # format 'Bazaar-NG Repository format 7'
     # lock ''
     # inventory.weave == empty_weave
     # empty revision-store directory
     # empty weaves directory
     # a 'shared-storage' marker file.
     t = control.get_repository_transport(None)
     self.assertEqualDiff('Bazaar-NG Repository format 7',
                          t.get('format').read())
     ## self.assertEqualDiff('', t.get('lock').read())
     self.assertEqualDiff('', t.get('shared-storage').read())
     self.assertEqualDiff('', t.get('no-working-trees').read())
     repo.set_make_working_trees(True)
     self.assertFalse(t.has('no-working-trees'))
     self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
     self.assertTrue(S_ISDIR(t.stat('weaves').st_mode))
     self.assertEqualDiff('# bzr weave file v5\n'
                          'w\n'
                          'W\n',
                          t.get('inventory.weave').read())
Пример #14
0
 def test_creation(self):
     format = bzrdir.BzrDirMetaFormat1()
     format.set_branch_format(_mod_branch.BzrBranchFormat6())
     branch = self.make_branch('a', format=format)
     self.assertIsInstance(branch, self.get_class())
     branch = self.make_branch('b', format=self.get_format_name())
     self.assertIsInstance(branch, self.get_class())
     branch = _mod_branch.Branch.open('a')
     self.assertIsInstance(branch, self.get_class())
Пример #15
0
    def test_fetch_root_knit(self):
        """Ensure that knit2.fetch() updates the root knit

        This tests the case where the root has a new revision, but there are no
        corresponding filename, parent, contents or other changes.
        """
        knit1_format = bzrdir.BzrDirMetaFormat1()
        knit1_format.repository_format = knitrepo.RepositoryFormatKnit1()
        knit2_format = bzrdir.BzrDirMetaFormat1()
        knit2_format.repository_format = knitrepo.RepositoryFormatKnit3()
        # we start with a knit1 repository because that causes the
        # root revision to change for each commit, even though the content,
        # parent, name, and other attributes are unchanged.
        tree = self.make_branch_and_tree('tree', knit1_format)
        tree.set_root_id('tree-root')
        tree.commit('rev1', rev_id='rev1')
        tree.commit('rev2', rev_id='rev2')

        # Now we convert it to a knit2 repository so that it has a root knit
        Convert(tree.basedir, knit2_format)
        tree = WorkingTree.open(tree.basedir)
        branch = self.make_branch('branch', format=knit2_format)
        branch.pull(tree.branch, stop_revision='rev1')
        repo = branch.repository
        repo.lock_read()
        try:
            # Make sure fetch retrieved only what we requested
            self.assertEqual({('tree-root', 'rev1'): ()},
                             repo.texts.get_parent_map([('tree-root', 'rev1'),
                                                        ('tree-root', 'rev2')
                                                        ]))
        finally:
            repo.unlock()
        branch.pull(tree.branch)
        # Make sure that the next revision in the root knit was retrieved,
        # even though the text, name, parent_id, etc., were unchanged.
        repo.lock_read()
        try:
            # Make sure fetch retrieved only what we requested
            self.assertEqual(
                {('tree-root', 'rev2'): (('tree-root', 'rev1'), )},
                repo.texts.get_parent_map([('tree-root', 'rev2')]))
        finally:
            repo.unlock()
Пример #16
0
 def test_find_format_factory(self):
     dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     SampleSupportedBranchFormat().initialize(dir)
     factory = _mod_branch.MetaDirBranchFormatFactory(
         SampleSupportedBranchFormatString, "bzrlib.tests.test_branch",
         "SampleSupportedBranchFormat")
     _mod_branch.format_registry.register(factory)
     self.addCleanup(_mod_branch.format_registry.remove, factory)
     b = _mod_branch.Branch.open(self.get_url())
     self.assertEqual(b, "opened supported branch.")
Пример #17
0
 def make_workingtree(self, relpath=''):
     url = self.get_url(relpath)
     if relpath:
         self.build_tree([relpath + '/'])
     dir = bzrdir.BzrDirMetaFormat1().initialize(url)
     repo = dir.create_repository()
     branch = dir.create_branch()
     try:
         return workingtree_4.WorkingTreeFormat4().initialize(dir)
     except errors.NotLocalUrl:
         raise TestSkipped('Not a local URL')
Пример #18
0
 def test_get_set_default_format(self):
     # set the format and then set it back again
     old_format = _mod_branch.format_registry.get_default()
     _mod_branch.format_registry.set_default(SampleBranchFormat())
     try:
         # the default branch format is used by the meta dir format
         # which is not the default bzrdir format at this point
         dir = bzrdir.BzrDirMetaFormat1().initialize('memory:///')
         result = dir.create_branch()
         self.assertEqual(result, 'A branch')
     finally:
         _mod_branch.format_registry.set_default(old_format)
     self.assertEqual(old_format, _mod_branch.format_registry.get_default())
Пример #19
0
 def test_register_unregister_format(self):
     format = SampleRepositoryFormat()
     # make a control dir
     dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     # make a repo
     format.initialize(dir)
     # register a format for it.
     repository.RepositoryFormat.register_format(format)
     # which repository.Open will refuse (not supported)
     self.assertRaises(UnsupportedFormatError, repository.Repository.open, self.get_url())
     # but open(unsupported) will work
     self.assertEqual(format.open(dir), "opened repository.")
     # unregister the format
     repository.RepositoryFormat.unregister_format(format)
Пример #20
0
 def test_convert_empty(self):
     t = get_transport(self.get_url('.'))
     t.mkdir('repository')
     repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository')
     repo = weaverepo.RepositoryFormat7().initialize(repo_dir)
     target_format = knitrepo.RepositoryFormatKnit1()
     converter = repository.CopyConverter(target_format)
     pb = bzrlib.ui.ui_factory.nested_progress_bar()
     try:
         converter.convert(repo, pb)
     finally:
         pb.finished()
     repo = repo_dir.open_repository()
     self.assertTrue(isinstance(target_format, repo._format.__class__))
Пример #21
0
 def test_create_open_reference(self):
     bzrdirformat = bzrdir.BzrDirMetaFormat1()
     t = self.get_transport()
     t.mkdir('repo')
     dir = bzrdirformat.initialize(self.get_url('repo'))
     dir.create_repository()
     target_branch = dir.create_branch()
     t.mkdir('branch')
     branch_dir = bzrdirformat.initialize(self.get_url('branch'))
     made_branch = _mod_branch.BranchReferenceFormat().initialize(
         branch_dir, target_branch=target_branch)
     self.assertEqual(made_branch.base, target_branch.base)
     opened_branch = branch_dir.open_branch()
     self.assertEqual(opened_branch.base, target_branch.base)
Пример #22
0
 def test_creates_lockdir(self):
     """Make sure it appears to be controlled by a LockDir existence"""
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
     t = control.get_repository_transport(None)
     # TODO: Should check there is a 'lock' toplevel directory, 
     # regardless of contents
     self.assertFalse(t.has('lock/held/info'))
     repo.lock_write()
     try:
         self.assertTrue(t.has('lock/held/info'))
     finally:
         # unlock so we don't get a warning about failing to do so
         repo.unlock()
Пример #23
0
 def test_branch_format_5_uses_lockdir(self):
     url = self.get_url()
     bdir = bzrdir.BzrDirMetaFormat1().initialize(url)
     bdir.create_repository()
     branch = BzrBranchFormat5().initialize(bdir)
     t = self.get_transport()
     self.log("branch instance is %r" % branch)
     self.assertTrue(isinstance(branch, BzrBranch5))
     self.assertIsDirectory('.', t)
     self.assertIsDirectory('.bzr/branch', t)
     self.assertIsDirectory('.bzr/branch/lock', t)
     branch.lock_write()
     self.addCleanup(branch.unlock)
     self.assertIsDirectory('.bzr/branch/lock/held', t)
Пример #24
0
 def test_uses_lockdir(self):
     """repo format 7 actually locks on lockdir"""
     base_url = self.get_url()
     control = bzrdir.BzrDirMetaFormat1().initialize(base_url)
     repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
     t = control.get_repository_transport(None)
     repo.lock_write()
     repo.unlock()
     del repo
     # make sure the same lock is created by opening it
     repo = repository.Repository.open(base_url)
     repo.lock_write()
     self.assertTrue(t.has('lock/held/info'))
     repo.unlock()
     self.assertFalse(t.has('lock/held/info'))
Пример #25
0
    def test_update_with_merges(self):
        # Test that 'bzr update' works correctly when you have
        # an update in the master tree, and a lightweight checkout
        # which has merged another branch
        master = self.make_branch_and_tree('master')
        self.build_tree(['master/file'])
        master.add(['file'])
        master.commit('one', rev_id='m1')

        self.build_tree(['checkout1/'])
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
        checkout_dir.set_branch_reference(master.branch)
        checkout1 = checkout_dir.create_workingtree('m1')

        # Create a second branch, with an extra commit
        other = master.bzrdir.sprout('other').open_workingtree()
        self.build_tree(['other/file2'])
        other.add(['file2'])
        other.commit('other2', rev_id='o2')

        # Create a new commit in the master branch
        self.build_tree(['master/file3'])
        master.add(['file3'])
        master.commit('f3', rev_id='m2')

        # Merge the other branch into checkout
        os.chdir('checkout1')
        self.run_bzr('merge ../other')

        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])

        # At this point, 'commit' should fail, because we are out of date
        self.run_bzr_error(["please run 'bzr update'"], 'commit -m merged')

        # This should not report about local commits being pending
        # merges, because they were real merges
        out, err = self.run_bzr('update')
        self.assertEqual('', out)
        self.assertEqualDiff(
            '''+N  file3
All changes applied successfully.
Updated to revision 2 of branch %s
''' % osutils.pathjoin(
                self.test_dir,
                'master',
            ), err)
        # The pending merges should still be there
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
Пример #26
0
 def test_get_set_default_format(self):
     old_format = workingtree.WorkingTreeFormat.get_default_format()
     # default is 3
     self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
     workingtree.WorkingTreeFormat.set_default_format(SampleTreeFormat())
     try:
         # the default branch format is used by the meta dir format
         # which is not the default bzrdir format at this point
         dir = bzrdir.BzrDirMetaFormat1().initialize('.')
         dir.create_repository()
         dir.create_branch()
         result = dir.create_workingtree()
         self.assertEqual(result, 'A tree')
     finally:
         workingtree.WorkingTreeFormat.set_default_format(old_format)
     self.assertEqual(old_format,
                      workingtree.WorkingTreeFormat.get_default_format())
Пример #27
0
 def test_shared_disk_layout(self):
     control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     repo = knitrepo.RepositoryFormatKnit1().initialize(control, shared=True)
     # we want:
     # format 'Bazaar-NG Knit Repository Format 1'
     # lock: is a directory
     # inventory.weave == empty_weave
     # empty revision-store directory
     # empty weaves directory
     # a 'shared-storage' marker file.
     t = control.get_repository_transport(None)
     self.assertEqualDiff('Bazaar-NG Knit Repository Format 1',
                          t.get('format').read())
     # XXX: no locks left when unlocked at the moment
     # self.assertEqualDiff('', t.get('lock').read())
     self.assertEqualDiff('', t.get('shared-storage').read())
     self.assertTrue(S_ISDIR(t.stat('knits').st_mode))
     self.check_knits(t)
Пример #28
0
 def test_register_unregister_format(self):
     format = SampleTreeFormat()
     # make a control dir
     dir = bzrdir.BzrDirMetaFormat1().initialize('.')
     dir.create_repository()
     dir.create_branch()
     # make a branch
     format.initialize(dir)
     # register a format for it.
     workingtree.WorkingTreeFormat.register_format(format)
     # which branch.Open will refuse (not supported)
     self.assertRaises(errors.UnsupportedFormatError,
                       workingtree.WorkingTree.open, '.')
     # but open_downlevel will work
     self.assertEqual(format.open(dir),
                      workingtree.WorkingTree.open_downlevel('.'))
     # unregister the format
     workingtree.WorkingTreeFormat.unregister_format(format)
Пример #29
0
 def test_register_unregister_format(self):
     format = SampleBranchFormat()
     # make a control dir
     dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
     # make a branch
     format.initialize(dir)
     # register a format for it.
     BranchFormat.register_format(format)
     # which branch.Open will refuse (not supported)
     self.assertRaises(UnsupportedFormatError, Branch.open, self.get_url())
     self.make_branch_and_tree('foo')
     # but open_downlevel will work
     self.assertEqual(
         format.open(dir),
         bzrdir.BzrDir.open(self.get_url()).open_branch(unsupported=True))
     # unregister the format
     BranchFormat.unregister_format(format)
     self.make_branch_and_tree('bar')
Пример #30
0
    def test_update_with_merge_merged_to_master(self):
        # Test that 'bzr update' works correctly when you have
        # an update in the master tree, and a [lightweight or otherwise]
        # checkout which has merge a revision merged to master already.
        master = self.make_branch_and_tree('master')
        self.build_tree(['master/file'])
        master.add(['file'])
        master.commit('one', rev_id='m1')

        self.build_tree(['checkout1/'])
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
        checkout_dir.set_branch_reference(master.branch)
        checkout1 = checkout_dir.create_workingtree('m1')

        # Create a second branch, with an extra commit
        other = master.bzrdir.sprout('other').open_workingtree()
        self.build_tree(['other/file2'])
        other.add(['file2'])
        other.commit('other2', rev_id='o2')

        # Merge the other branch into checkout -  'start reviewing a patch'
        checkout1.merge_from_branch(other.branch)
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])

        # Create a new commit in the master branch - 'someone else lands its'
        master.merge_from_branch(other.branch)
        master.commit('f3', rev_id='m2')

        # This should not report about local commits being pending
        # merges, because they were real merges (but are now gone).
        # It should perhaps report on them.
        out, err = self.run_bzr('update', working_dir='checkout1')
        self.assertEqual('', out)
        self.assertEqualDiff(
            '''All changes applied successfully.
Updated to revision 2 of branch %s
''' % osutils.pathjoin(
                self.test_dir,
                'master',
            ), err)
        # The pending merges should still be there
        self.assertEqual([], checkout1.get_parent_ids()[1:])