Esempio n. 1
0
 def test_init(self):
     self.run_bzr("init-repo a")
     self.run_bzr("init --format=default a/b")
     dir = ControlDir.open('a')
     self.assertIs(dir.open_repository().is_shared(), True)
     self.assertRaises(errors.NotBranchError, dir.open_branch)
     self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
     bdir = ControlDir.open('a/b')
     bdir.open_branch()
     self.assertRaises(errors.NoRepositoryPresent, bdir.open_repository)
     wt = bdir.open_workingtree()
Esempio n. 2
0
 def test_init(self):
     self.run_bzr("init-repo a")
     self.run_bzr("init --format=default a/b")
     dir = ControlDir.open('a')
     self.assertIs(dir.open_repository().is_shared(), True)
     self.assertRaises(errors.NotBranchError, dir.open_branch)
     self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
     bdir = ControlDir.open('a/b')
     bdir.open_branch()
     self.assertRaises(errors.NoRepositoryPresent, bdir.open_repository)
     wt = bdir.open_workingtree()
Esempio n. 3
0
    def follow_reference(self, url):
        """Get the branch-reference value at the specified url.

        This exists as a separate method only to be overriden in unit tests.
        """
        bzrdir = ControlDir.open(url, probers=self.probers)
        return bzrdir.get_branch_reference()
Esempio n. 4
0
    def run(self, location=None, remember=False, directory=None,
            no_rebase=False, strict=None):
        from bzrlib import urlutils
        from bzrlib.controldir import ControlDir
        from bzrlib.errors import BzrCommandError, NoWorkingTree
        from bzrlib.workingtree import WorkingTree

        if directory is None:
            directory = "."
        try:
            source_wt = WorkingTree.open_containing(directory)[0]
            source_branch = source_wt.branch
        except NoWorkingTree:
            source_branch = Branch.open(directory)
            source_wt = None
        if source_wt is not None:
            source_wt.check_changed_or_out_of_date(
                strict, 'dpush_strict',
                more_error='Use --no-strict to force the push.',
                more_warning='Uncommitted changes will not be pushed.')
        stored_loc = source_branch.get_push_location()
        if location is None:
            if stored_loc is None:
                raise BzrCommandError(gettext("No push location known or specified."))
            else:
                display_url = urlutils.unescape_for_display(stored_loc,
                        self.outf.encoding)
                self.outf.write(
                       gettext("Using saved location: %s\n") % display_url)
                location = stored_loc

        controldir = ControlDir.open(location)
        target_branch = controldir.open_branch()
        target_branch.lock_write()
        try:
            try:
                push_result = source_branch.push(target_branch, lossy=True)
            except errors.LossyPushToSameVCS:
                raise BzrCommandError(gettext("{0!r} and {1!r} are in the same VCS, lossy "
                    "push not necessary. Please use regular push.").format(
                    source_branch, target_branch))
            # We successfully created the target, remember it
            if source_branch.get_push_location() is None or remember:
                # FIXME: Should be done only if we succeed ? -- vila 2012-01-18
                source_branch.set_push_location(target_branch.base)
            if not no_rebase:
                old_last_revid = source_branch.last_revision()
                source_branch.pull(target_branch, overwrite=True)
                new_last_revid = source_branch.last_revision()
                if source_wt is not None and old_last_revid != new_last_revid:
                    source_wt.lock_write()
                    try:
                        target = source_wt.branch.repository.revision_tree(
                            new_last_revid)
                        update_workingtree_fileids(source_wt, target)
                    finally:
                        source_wt.unlock()
            push_result.report(self.outf)
        finally:
            target_branch.unlock()
Esempio n. 5
0
    def follow_reference(self, url):
        """Get the branch-reference value at the specified url.

        This exists as a separate method only to be overriden in unit tests.
        """
        bzrdir = ControlDir.open(url, probers=self.probers)
        return bzrdir.get_branch_reference()
Esempio n. 6
0
 def test_notification_on_branch_from_repository(self):
     out, err = self.run_bzr("init-repository -q a")
     self.assertEqual(out, "")
     self.assertEqual(err, "")
     dir = ControlDir.open('a')
     dir.open_repository() # there is a repository there
     e = self.assertRaises(errors.NotBranchError, dir.open_branch)
     self.assertContainsRe(str(e), "location is a repository")
Esempio n. 7
0
 def test_make_repository_quiet(self):
     out, err = self.run_bzr("init-repository a -q")
     self.assertEqual(out, "")
     self.assertEqual(err, "")
     dir = ControlDir.open('a')
     self.assertIs(dir.open_repository().is_shared(), True)
     self.assertRaises(errors.NotBranchError, dir.open_branch)
     self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
Esempio n. 8
0
    def test_init_repo_existing_dir(self):
        """Make repo in existing directory.

        (Malone #38331)
        """
        out, err = self.run_bzr("init-repository .")
        dir = ControlDir.open('.')
        self.assertTrue(dir.open_repository())
Esempio n. 9
0
 def test_branch(self):
     self.run_bzr("init-repo a")
     self.run_bzr("init --format=default a/b")
     self.run_bzr('branch a/b a/c')
     cdir = ControlDir.open('a/c')
     cdir.open_branch()
     self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
     cdir.open_workingtree()
Esempio n. 10
0
 def test_branch(self):
     self.run_bzr("init-repo a")
     self.run_bzr("init --format=default a/b")
     self.run_bzr('branch a/b a/c')
     cdir = ControlDir.open('a/c')
     cdir.open_branch()
     self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
     cdir.open_workingtree()
Esempio n. 11
0
 def test_notification_on_branch_from_repository(self):
     out, err = self.run_bzr("init-repository -q a")
     self.assertEqual(out, "")
     self.assertEqual(err, "")
     dir = ControlDir.open('a')
     dir.open_repository()  # there is a repository there
     e = self.assertRaises(errors.NotBranchError, dir.open_branch)
     self.assertContainsRe(str(e), "location is a repository")
Esempio n. 12
0
    def test_init_repo_existing_dir(self):
        """Make repo in existing directory.

        (Malone #38331)
        """
        out, err = self.run_bzr("init-repository .")
        dir = ControlDir.open('.')
        self.assertTrue(dir.open_repository())
Esempio n. 13
0
 def test_make_repository_quiet(self):
     out, err = self.run_bzr("init-repository a -q")
     self.assertEqual(out, "")
     self.assertEqual(err, "")
     dir = ControlDir.open('a')
     self.assertIs(dir.open_repository().is_shared(), True)
     self.assertRaises(errors.NotBranchError, dir.open_branch)
     self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
Esempio n. 14
0
 def convert(self, to_convert, pb):
     """See Converter.convert()."""
     self.bzrdir = to_convert
     pb = ui.ui_factory.nested_progress_bar()
     try:
         ui.ui_factory.note(gettext('starting upgrade from format 5 to 6'))
         self._convert_to_prefixed()
         return ControlDir.open(self.bzrdir.user_url)
     finally:
         pb.finished()
Esempio n. 15
0
 def convert(self, to_convert, pb):
     """See Converter.convert()."""
     self.bzrdir = to_convert
     pb = ui.ui_factory.nested_progress_bar()
     try:
         ui.ui_factory.note(gettext('starting upgrade from format 5 to 6'))
         self._convert_to_prefixed()
         return ControlDir.open(self.bzrdir.user_url)
     finally:
         pb.finished()
Esempio n. 16
0
    def test_make_repository(self):
        out, err = self.run_bzr("init-repository a")
        self.assertEqual(out,
"""Shared repository with trees (format: 2a)
Location:
  shared repository: a
""")
        self.assertEqual(err, "")
        dir = ControlDir.open('a')
        self.assertIs(dir.open_repository().is_shared(), True)
        self.assertRaises(errors.NotBranchError, dir.open_branch)
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
Esempio n. 17
0
    def test_make_repository(self):
        out, err = self.run_bzr("init-repository a")
        self.assertEqual(
            out, """Shared repository with trees (format: 2a)
Location:
  shared repository: a
""")
        self.assertEqual(err, "")
        dir = ControlDir.open('a')
        self.assertIs(dir.open_repository().is_shared(), True)
        self.assertRaises(errors.NotBranchError, dir.open_branch)
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
Esempio n. 18
0
    def test_branch_tree(self):
        self.run_bzr("init-repo --trees a")
        self.run_bzr("init --format=default b")
        with file('b/hello', 'wt') as f: f.write('bar')
        self.run_bzr("add b/hello")
        self.run_bzr("commit -m bar b/hello")

        self.run_bzr('branch b a/c')
        cdir = ControlDir.open('a/c')
        cdir.open_branch()
        self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
        self.assertPathExists('a/c/hello')
        cdir.open_workingtree()
Esempio n. 19
0
    def test_branch_tree(self):
        self.run_bzr("init-repo --trees a")
        self.run_bzr("init --format=default b")
        with file('b/hello', 'wt') as f:
            f.write('bar')
        self.run_bzr("add b/hello")
        self.run_bzr("commit -m bar b/hello")

        self.run_bzr('branch b a/c')
        cdir = ControlDir.open('a/c')
        cdir.open_branch()
        self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
        self.assertPathExists('a/c/hello')
        cdir.open_workingtree()
Esempio n. 20
0
 def convert(self, to_convert, pb):
     """See Converter.convert()."""
     self.bzrdir = to_convert
     if pb is not None:
         warnings.warn(gettext("pb parameter to convert() is deprecated"))
     self.pb = ui.ui_factory.nested_progress_bar()
     try:
         ui.ui_factory.note(gettext('starting upgrade from format 4 to 5'))
         if isinstance(self.bzrdir.transport, local.LocalTransport):
             self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
         self._convert_to_weaves()
         return ControlDir.open(self.bzrdir.user_url)
     finally:
         self.pb.finished()
Esempio n. 21
0
 def convert(self, to_convert, pb):
     """See Converter.convert()."""
     self.bzrdir = to_convert
     if pb is not None:
         warnings.warn(gettext("pb parameter to convert() is deprecated"))
     self.pb = ui.ui_factory.nested_progress_bar()
     try:
         ui.ui_factory.note(gettext('starting upgrade from format 4 to 5'))
         if isinstance(self.bzrdir.transport, local.LocalTransport):
             self.bzrdir.get_workingtree_transport(None).delete(
                 'stat-cache')
         self._convert_to_weaves()
         return ControlDir.open(self.bzrdir.user_url)
     finally:
         self.pb.finished()
Esempio n. 22
0
 def test_switch_new_colocated(self):
     # Create a branch branch-1 that initially is a checkout of 'foo'
     # Use switch to create 'anotherbranch' which derives from that
     repo = self.make_repository('branch-1', format='development-colo')
     target_branch = repo.bzrdir.create_branch(name='foo')
     repo.bzrdir.set_branch_reference(target_branch)
     tree = repo.bzrdir.create_workingtree()
     self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
     tree.add('file-1')
     revid1 = tree.commit('rev1')
     self.run_bzr(['switch', '-b', 'anotherbranch'], working_dir='branch-1')
     bzrdir = ControlDir.open("branch-1")
     self.assertEqual(set([b.name for b in bzrdir.list_branches()]),
                      set(["foo", "anotherbranch"]))
     self.assertEqual(bzrdir.open_branch().name, "anotherbranch")
     self.assertEqual(bzrdir.open_branch().last_revision(), revid1)
Esempio n. 23
0
 def test_switch_new_colocated(self):
     # Create a branch branch-1 that initially is a checkout of 'foo'
     # Use switch to create 'anotherbranch' which derives from that
     repo = self.make_repository('branch-1', format='development-colo')
     target_branch = repo.bzrdir.create_branch(name='foo')
     repo.bzrdir.set_branch_reference(target_branch)
     tree = repo.bzrdir.create_workingtree()
     self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
     tree.add('file-1')
     revid1 = tree.commit('rev1')
     self.run_bzr(['switch', '-b', 'anotherbranch'], working_dir='branch-1')
     bzrdir = ControlDir.open("branch-1")
     self.assertEquals(
         set([b.name for b in bzrdir.list_branches()]),
         set(["foo", "anotherbranch"]))
     self.assertEquals(bzrdir.open_branch().name, "anotherbranch")
     self.assertEquals(bzrdir.open_branch().last_revision(), revid1)
Esempio n. 24
0
 def test_mode_0(self):
     """Test when a transport returns null permissions for .bzr"""
     if isinstance(self.branch_format, RemoteBranchFormat):
         # Remote branch format have no permission logic in them; there's
         # nothing to test here.
         raise tests.TestNotApplicable('Remote branches have no'
                                       ' permission logic')
     self.make_branch_and_tree('.')
     bzrdir = ControlDir.open('.')
     # Monkey patch the transport
     _orig_stat = bzrdir.transport.stat
     def null_perms_stat(*args, **kwargs):
         result = _orig_stat(*args, **kwargs)
         return _NullPermsStat(result)
     bzrdir.transport.stat = null_perms_stat
     self.assertIs(None, bzrdir._get_dir_mode())
     self.assertIs(None, bzrdir._get_file_mode())
Esempio n. 25
0
    def test_mode_0(self):
        """Test when a transport returns null permissions for .bzr"""
        if isinstance(self.branch_format, RemoteBranchFormat):
            # Remote branch format have no permission logic in them; there's
            # nothing to test here.
            raise tests.TestNotApplicable('Remote branches have no'
                                          ' permission logic')
        self.make_branch_and_tree('.')
        bzrdir = ControlDir.open('.')
        # Monkey patch the transport
        _orig_stat = bzrdir.transport.stat

        def null_perms_stat(*args, **kwargs):
            result = _orig_stat(*args, **kwargs)
            return _NullPermsStat(result)

        bzrdir.transport.stat = null_perms_stat
        self.assertIs(None, bzrdir._get_dir_mode())
        self.assertIs(None, bzrdir._get_file_mode())
Esempio n. 26
0
 def test_send_without_workingtree(self):
     ControlDir.open("local").destroy_workingtree()
     self.assertSendSucceeds([])
Esempio n. 27
0
 def open_branch(url):
     dir = ControlDir.open(url, probers=self.probers)
     return dir.open_branch()
Esempio n. 28
0
 def test_trees_default(self):
     # 0.15 switched to trees by default
     self.run_bzr("init-repo repo")
     repo = ControlDir.open("repo").open_repository()
     self.assertEqual(True, repo.make_working_trees())
Esempio n. 29
0
 def test_trees_default(self):
     # 0.15 switched to trees by default
     self.run_bzr("init-repo repo")
     repo = ControlDir.open("repo").open_repository()
     self.assertEqual(True, repo.make_working_trees())
Esempio n. 30
0
 def test_no_trees_argument(self):
     # --no-trees should make it so that there is no working tree
     self.run_bzr("init-repo --no-trees notrees")
     repo = ControlDir.open("notrees").open_repository()
     self.assertEqual(False, repo.make_working_trees())
Esempio n. 31
0
    def convert(self, to_convert, pb):
        """See Converter.convert()."""
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
        from bzrlib.branchfmt.fullhistory import BzrBranchFormat5
        self.bzrdir = to_convert
        self.pb = ui.ui_factory.nested_progress_bar()
        self.count = 0
        self.total = 20  # the steps we know about
        self.garbage_inventories = []
        self.dir_mode = self.bzrdir._get_dir_mode()
        self.file_mode = self.bzrdir._get_file_mode()

        ui.ui_factory.note(
            gettext('starting upgrade from format 6 to metadir'))
        self.bzrdir.transport.put_bytes('branch-format',
                                        "Converting to format 6",
                                        mode=self.file_mode)
        # its faster to move specific files around than to open and use the apis...
        # first off, nuke ancestry.weave, it was never used.
        try:
            self.step(gettext('Removing ancestry.weave'))
            self.bzrdir.transport.delete('ancestry.weave')
        except errors.NoSuchFile:
            pass
        # find out whats there
        self.step(gettext('Finding branch files'))
        last_revision = self.bzrdir.open_branch().last_revision()
        bzrcontents = self.bzrdir.transport.list_dir('.')
        for name in bzrcontents:
            if name.startswith('basis-inventory.'):
                self.garbage_inventories.append(name)
        # create new directories for repository, working tree and branch
        repository_names = [('inventory.weave', True),
                            ('revision-store', True), ('weaves', True)]
        self.step(gettext('Upgrading repository') + '  ')
        self.bzrdir.transport.mkdir('repository', mode=self.dir_mode)
        self.make_lock('repository')
        # we hard code the formats here because we are converting into
        # the meta format. The meta format upgrader can take this to a
        # future format within each component.
        self.put_format('repository', RepositoryFormat7())
        for entry in repository_names:
            self.move_entry('repository', entry)

        self.step(gettext('Upgrading branch') + '      ')
        self.bzrdir.transport.mkdir('branch', mode=self.dir_mode)
        self.make_lock('branch')
        self.put_format('branch', BzrBranchFormat5())
        branch_files = [('revision-history', True), ('branch-name', True),
                        ('parent', False)]
        for entry in branch_files:
            self.move_entry('branch', entry)

        checkout_files = [('pending-merges', True), ('inventory', True),
                          ('stat-cache', False)]
        # If a mandatory checkout file is not present, the branch does not have
        # a functional checkout. Do not create a checkout in the converted
        # branch.
        for name, mandatory in checkout_files:
            if mandatory and name not in bzrcontents:
                has_checkout = False
                break
        else:
            has_checkout = True
        if not has_checkout:
            ui.ui_factory.note(gettext('No working tree.'))
            # If some checkout files are there, we may as well get rid of them.
            for name, mandatory in checkout_files:
                if name in bzrcontents:
                    self.bzrdir.transport.delete(name)
        else:
            from bzrlib.workingtree_3 import WorkingTreeFormat3
            self.step(gettext('Upgrading working tree'))
            self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
            self.make_lock('checkout')
            self.put_format('checkout', WorkingTreeFormat3())
            self.bzrdir.transport.delete_multi(self.garbage_inventories,
                                               self.pb)
            for entry in checkout_files:
                self.move_entry('checkout', entry)
            if last_revision is not None:
                self.bzrdir.transport.put_bytes('checkout/last-revision',
                                                last_revision)
        self.bzrdir.transport.put_bytes(
            'branch-format',
            BzrDirMetaFormat1().get_format_string(),
            mode=self.file_mode)
        self.pb.finished()
        return ControlDir.open(self.bzrdir.user_url)
Esempio n. 32
0
 def test_send_without_workingtree(self):
     ControlDir.open("local").destroy_workingtree()
     self.assertSendSucceeds([])
Esempio n. 33
0
 def test_no_trees_argument(self):
     # --no-trees should make it so that there is no working tree
     self.run_bzr("init-repo --no-trees notrees")
     repo = ControlDir.open("notrees").open_repository()
     self.assertEqual(False, repo.make_working_trees())
Esempio n. 34
0
 def test_trees_argument(self):
     # Supplying the --trees argument should be harmless,
     # as it was previously non-default we need to get it right.
     self.run_bzr("init-repo --trees trees")
     repo = ControlDir.open("trees").open_repository()
     self.assertEqual(True, repo.make_working_trees())
Esempio n. 35
0
    def run(self,
            location=None,
            remember=False,
            directory=None,
            no_rebase=False,
            strict=None):
        from bzrlib import urlutils
        from bzrlib.controldir import ControlDir
        from bzrlib.errors import BzrCommandError, NoWorkingTree
        from bzrlib.workingtree import WorkingTree

        if directory is None:
            directory = "."
        try:
            source_wt = WorkingTree.open_containing(directory)[0]
            source_branch = source_wt.branch
        except NoWorkingTree:
            source_branch = Branch.open(directory)
            source_wt = None
        if source_wt is not None:
            source_wt.check_changed_or_out_of_date(
                strict,
                'dpush_strict',
                more_error='Use --no-strict to force the push.',
                more_warning='Uncommitted changes will not be pushed.')
        stored_loc = source_branch.get_push_location()
        if location is None:
            if stored_loc is None:
                raise BzrCommandError(
                    gettext("No push location known or specified."))
            else:
                display_url = urlutils.unescape_for_display(
                    stored_loc, self.outf.encoding)
                self.outf.write(
                    gettext("Using saved location: %s\n") % display_url)
                location = stored_loc

        controldir = ControlDir.open(location)
        target_branch = controldir.open_branch()
        target_branch.lock_write()
        try:
            try:
                push_result = source_branch.push(target_branch, lossy=True)
            except errors.LossyPushToSameVCS:
                raise BzrCommandError(
                    gettext(
                        "{0!r} and {1!r} are in the same VCS, lossy "
                        "push not necessary. Please use regular push.").format(
                            source_branch, target_branch))
            # We successfully created the target, remember it
            if source_branch.get_push_location() is None or remember:
                # FIXME: Should be done only if we succeed ? -- vila 2012-01-18
                source_branch.set_push_location(target_branch.base)
            if not no_rebase:
                old_last_revid = source_branch.last_revision()
                source_branch.pull(target_branch, overwrite=True)
                new_last_revid = source_branch.last_revision()
                if source_wt is not None and old_last_revid != new_last_revid:
                    source_wt.lock_write()
                    try:
                        target = source_wt.branch.repository.revision_tree(
                            new_last_revid)
                        update_workingtree_fileids(source_wt, target)
                    finally:
                        source_wt.unlock()
            push_result.report(self.outf)
        finally:
            target_branch.unlock()
Esempio n. 36
0
 def test_trees_argument(self):
     # Supplying the --trees argument should be harmless,
     # as it was previously non-default we need to get it right.
     self.run_bzr("init-repo --trees trees")
     repo = ControlDir.open("trees").open_repository()
     self.assertEqual(True, repo.make_working_trees())
Esempio n. 37
0
    def convert(self, to_convert, pb):
        """See Converter.convert()."""
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
        from bzrlib.branchfmt.fullhistory import BzrBranchFormat5
        self.bzrdir = to_convert
        self.pb = ui.ui_factory.nested_progress_bar()
        self.count = 0
        self.total = 20 # the steps we know about
        self.garbage_inventories = []
        self.dir_mode = self.bzrdir._get_dir_mode()
        self.file_mode = self.bzrdir._get_file_mode()

        ui.ui_factory.note(gettext('starting upgrade from format 6 to metadir'))
        self.bzrdir.transport.put_bytes(
                'branch-format',
                "Converting to format 6",
                mode=self.file_mode)
        # its faster to move specific files around than to open and use the apis...
        # first off, nuke ancestry.weave, it was never used.
        try:
            self.step(gettext('Removing ancestry.weave'))
            self.bzrdir.transport.delete('ancestry.weave')
        except errors.NoSuchFile:
            pass
        # find out whats there
        self.step(gettext('Finding branch files'))
        last_revision = self.bzrdir.open_branch().last_revision()
        bzrcontents = self.bzrdir.transport.list_dir('.')
        for name in bzrcontents:
            if name.startswith('basis-inventory.'):
                self.garbage_inventories.append(name)
        # create new directories for repository, working tree and branch
        repository_names = [('inventory.weave', True),
                            ('revision-store', True),
                            ('weaves', True)]
        self.step(gettext('Upgrading repository') + '  ')
        self.bzrdir.transport.mkdir('repository', mode=self.dir_mode)
        self.make_lock('repository')
        # we hard code the formats here because we are converting into
        # the meta format. The meta format upgrader can take this to a
        # future format within each component.
        self.put_format('repository', RepositoryFormat7())
        for entry in repository_names:
            self.move_entry('repository', entry)

        self.step(gettext('Upgrading branch') + '      ')
        self.bzrdir.transport.mkdir('branch', mode=self.dir_mode)
        self.make_lock('branch')
        self.put_format('branch', BzrBranchFormat5())
        branch_files = [('revision-history', True),
                        ('branch-name', True),
                        ('parent', False)]
        for entry in branch_files:
            self.move_entry('branch', entry)

        checkout_files = [('pending-merges', True),
                          ('inventory', True),
                          ('stat-cache', False)]
        # If a mandatory checkout file is not present, the branch does not have
        # a functional checkout. Do not create a checkout in the converted
        # branch.
        for name, mandatory in checkout_files:
            if mandatory and name not in bzrcontents:
                has_checkout = False
                break
        else:
            has_checkout = True
        if not has_checkout:
            ui.ui_factory.note(gettext('No working tree.'))
            # If some checkout files are there, we may as well get rid of them.
            for name, mandatory in checkout_files:
                if name in bzrcontents:
                    self.bzrdir.transport.delete(name)
        else:
            from bzrlib.workingtree_3 import WorkingTreeFormat3
            self.step(gettext('Upgrading working tree'))
            self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
            self.make_lock('checkout')
            self.put_format(
                'checkout', WorkingTreeFormat3())
            self.bzrdir.transport.delete_multi(
                self.garbage_inventories, self.pb)
            for entry in checkout_files:
                self.move_entry('checkout', entry)
            if last_revision is not None:
                self.bzrdir.transport.put_bytes(
                    'checkout/last-revision', last_revision)
        self.bzrdir.transport.put_bytes(
            'branch-format',
            BzrDirMetaFormat1().get_format_string(),
            mode=self.file_mode)
        self.pb.finished()
        return ControlDir.open(self.bzrdir.user_url)
Esempio n. 38
0
 def open_branch(url):
     dir = ControlDir.open(url, probers=self.probers)
     return dir.open_branch()