Exemplo n.º 1
0
    def test_info_standalone_no_tree(self):
        # create standalone branch without a working tree
        format = bzrdir.format_registry.make_bzrdir('default')
        branch = self.make_branch('branch')
        repo = branch.repository
        out, err = self.run_bzr('info branch -v')
        self.assertEqualDiff(
"""Standalone branch (format: %s)
Location:
  branch root: branch

Format:
       control: Meta directory format 1
        branch: %s
    repository: %s

Branch history:
         0 revisions
         0 committers

Repository:
         0 revisions
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
       format.get_branch_format().get_format_description(),
       format.repository_format.get_format_description(),
       ), out)
        self.assertEqual('', err)
Exemplo n.º 2
0
 def test_clone_stacking_policy_upgrades(self):
     """Cloning an unstackable branch format to somewhere with a default
     stack-on branch upgrades branch and repo to match the target and honour
     the policy.
     """
     try:
         repo = self.make_repository('repo', shared=True)
     except errors.IncompatibleFormat:
         raise tests.TestNotApplicable('Cannot make a shared repository')
     if repo.bzrdir._format.fixed_components:
         self.knownFailure("pre metadir branches do not upgrade on push "
                           "with stacking policy")
     if isinstance(repo._format,
                   knitpack_repo.RepositoryFormatKnitPack5RichRootBroken):
         raise tests.TestNotApplicable("unsupported format")
     # Make a source branch in 'repo' in an unstackable branch format
     bzrdir_format = self.repository_format._matchingbzrdir
     transport = self.get_transport('repo/branch')
     transport.mkdir('.')
     target_bzrdir = bzrdir_format.initialize_on_transport(transport)
     branch = _mod_branch.BzrBranchFormat6().initialize(target_bzrdir)
     # Ensure that stack_on will be stackable and match the serializer of
     # repo.
     if isinstance(repo, remote.RemoteRepository):
         repo._ensure_real()
         info_repo = repo._real_repository
     else:
         info_repo = repo
     format_description = info.describe_format(info_repo.bzrdir, info_repo,
                                               None, None)
     formats = format_description.split(' or ')
     stack_on_format = formats[0]
     if stack_on_format in ["pack-0.92", "dirstate", "metaweave"]:
         stack_on_format = "1.9"
     elif stack_on_format in [
             "dirstate-with-subtree", "rich-root", "rich-root-pack",
             "pack-0.92-subtree"
     ]:
         stack_on_format = "1.9-rich-root"
     # formats not tested for above are already stackable, so we can use the
     # format as-is.
     stack_on = self.make_branch('stack-on-me', format=stack_on_format)
     self.make_bzrdir('.').get_config().set_default_stack_on('stack-on-me')
     target = branch.bzrdir.clone(self.get_url('target'))
     # The target branch supports stacking.
     self.assertTrue(target.open_branch()._format.supports_stacking())
     if isinstance(repo, remote.RemoteRepository):
         repo._ensure_real()
         repo = repo._real_repository
     target_repo = target.open_repository()
     if isinstance(target_repo, remote.RemoteRepository):
         target_repo._ensure_real()
         target_repo = target_repo._real_repository
     # The repository format is unchanged if it could already stack, or the
     # same as the stack on.
     if repo._format.supports_external_lookups:
         self.assertEqual(repo._format, target_repo._format)
     else:
         self.assertEqual(stack_on.repository._format, target_repo._format)
Exemplo n.º 3
0
 def assertRepoDescription(self, format, expected=None):
     """Assert repository's format description matches expectations"""
     if expected is None:
         expected = format
     self.make_repository('%s_repo' % format, format=format)
     repo = _mod_repository.Repository.open('%s_repo' % format)
     self.assertEqual(expected, info.describe_format(repo.bzrdir,
         repo, None, None))
Exemplo n.º 4
0
 def assertBranchDescription(self, format, expected=None):
     """Assert branch's format description matches expectations"""
     if expected is None:
         expected = format
     self.make_branch('%s_branch' % format, format=format)
     branch = _mod_branch.Branch.open('%s_branch' % format)
     self.assertEqual(expected, info.describe_format(branch.bzrdir,
         branch.repository, branch, None))
Exemplo n.º 5
0
 def assertRepoDescription(self, format, expected=None):
     """Assert repository's format description matches expectations"""
     if expected is None:
         expected = format
     self.make_repository('%s_repo' % format, format=format)
     repo = _mod_repository.Repository.open('%s_repo' % format)
     self.assertEqual(expected, info.describe_format(repo.bzrdir,
         repo, None, None))
Exemplo n.º 6
0
 def assertBranchDescription(self, format, expected=None):
     """Assert branch's format description matches expectations"""
     if expected is None:
         expected = format
     self.make_branch('%s_branch' % format, format=format)
     branch = _mod_branch.Branch.open('%s_branch' % format)
     self.assertEqual(expected, info.describe_format(branch.bzrdir,
         branch.repository, branch, None))
Exemplo n.º 7
0
 def assertTreeDescription(self, format):
     """Assert a tree's format description matches expectations"""
     self.make_branch_and_tree('%s_tree' % format, format=format)
     tree = workingtree.WorkingTree.open('%s_tree' % format)
     self.assertEqual(
         format,
         info.describe_format(tree.bzrdir, tree.branch.repository,
                              tree.branch, tree))
Exemplo n.º 8
0
 def test_clone_stacking_policy_upgrades(self):
     """Cloning an unstackable branch format to somewhere with a default
     stack-on branch upgrades branch and repo to match the target and honour
     the policy.
     """
     try:
         repo = self.make_repository('repo', shared=True)
     except errors.IncompatibleFormat:
         raise tests.TestNotApplicable('Cannot make a shared repository')
     if repo.bzrdir._format.fixed_components:
         self.knownFailure(
             "pre metadir branches do not upgrade on push "
             "with stacking policy")
     if isinstance(repo._format,
                   knitpack_repo.RepositoryFormatKnitPack5RichRootBroken):
         raise tests.TestNotApplicable("unsupported format")
     # Make a source branch in 'repo' in an unstackable branch format
     bzrdir_format = self.repository_format._matchingbzrdir
     transport = self.get_transport('repo/branch')
     transport.mkdir('.')
     target_bzrdir = bzrdir_format.initialize_on_transport(transport)
     branch = _mod_branch.BzrBranchFormat6().initialize(target_bzrdir)
     # Ensure that stack_on will be stackable and match the serializer of
     # repo.
     if isinstance(repo, remote.RemoteRepository):
         repo._ensure_real()
         info_repo = repo._real_repository
     else:
         info_repo = repo
     format_description = info.describe_format(info_repo.bzrdir,
         info_repo, None, None)
     formats = format_description.split(' or ')
     stack_on_format = formats[0]
     if stack_on_format in ["pack-0.92", "dirstate", "metaweave"]:
         stack_on_format = "1.9"
     elif stack_on_format in ["dirstate-with-subtree", "rich-root",
         "rich-root-pack", "pack-0.92-subtree"]:
         stack_on_format = "1.9-rich-root"
     # formats not tested for above are already stackable, so we can use the
     # format as-is.
     stack_on = self.make_branch('stack-on-me', format=stack_on_format)
     self.make_bzrdir('.').get_config().set_default_stack_on('stack-on-me')
     target = branch.bzrdir.clone(self.get_url('target'))
     # The target branch supports stacking.
     self.assertTrue(target.open_branch()._format.supports_stacking())
     if isinstance(repo, remote.RemoteRepository):
         repo._ensure_real()
         repo = repo._real_repository
     target_repo = target.open_repository()
     if isinstance(target_repo, remote.RemoteRepository):
         target_repo._ensure_real()
         target_repo = target_repo._real_repository
     # The repository format is unchanged if it could already stack, or the
     # same as the stack on.
     if repo._format.supports_external_lookups:
         self.assertEqual(repo._format, target_repo._format)
     else:
         self.assertEqual(stack_on.repository._format, target_repo._format)
Exemplo n.º 9
0
    def test_describe_repo_format(self):
        for key in bzrdir.format_registry.keys():
            if key in bzrdir.format_registry.aliases():
                continue
            expected = None
            if key in ('dirstate', 'knit', 'dirstate-tags'):
                expected = 'dirstate or dirstate-tags or knit'
            self.assertRepoDescription(key, expected)

        format = bzrdir.format_registry.make_bzrdir('metaweave')
        format.set_branch_format(_mod_branch.BzrBranchFormat6())
        tree = self.make_branch_and_tree('unknown', format=format)
        self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
            tree.branch.repository, tree.branch, tree))
Exemplo n.º 10
0
    def test_describe_repo_format(self):
        for key in controldir.format_registry.keys():
            if key in controldir.format_registry.aliases():
                continue
            if controldir.format_registry.get_info(key).hidden:
                continue
            expected = None
            if key in ('dirstate', 'knit', 'dirstate-tags'):
                expected = 'dirstate or dirstate-tags or knit'
            elif key in ('1.14',):
                expected = '1.14'
            elif key in ('1.14-rich-root',):
                expected = '1.14-rich-root'
            self.assertRepoDescription(key, expected)

        format = controldir.format_registry.make_bzrdir('knit')
        format.set_branch_format(_mod_branch.BzrBranchFormat6())
        tree = self.make_branch_and_tree('unknown', format=format)
        self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
            tree.branch.repository, tree.branch, tree))
Exemplo n.º 11
0
def show_component_info_xml(control, repository, branch=None,
                            working=None, verbose=1, outfile=None):
    """Write info about all bzrdir components to stdout"""
    if outfile is None:
        outfile = sys.stdout
    if verbose is False:
        verbose = 1
    if verbose is True:
        verbose = 2
    layout = info.describe_layout(repository, branch, working, control)
    formats = info.describe_format(control, repository,
                                   branch, working).split(' or ')
    outfile.write('<layout>%s</layout>' % layout)
    outfile.write('<formats>')
    if len(formats) > 1:
        for format in formats:
            outfile.write('<format>%s</format>' % format)
    else:
        outfile.write('<format>%s</format>' % formats[0])
    outfile.write('</formats>')
    _show_location_info_xml(info.gather_location_info(repository, branch,
                            working), outfile)
    if branch is not None:
        _show_related_info_xml(branch, outfile)
    if verbose == 0:
        return
    _show_format_info_xml(control, repository, branch, working, outfile)
    _show_locking_info_xml(repository, branch, working, outfile)
    if branch is not None:
        _show_missing_revisions_branch_xml(branch, outfile)
    if working is not None:
        _show_working_stats_xml(working, outfile)
    elif branch is not None:
        _show_missing_revisions_branch_xml(branch, outfile)
    if branch is not None:
        stats = _show_branch_stats_xml(branch, verbose==2, outfile)
    else:
        stats = repository.gather_stats()
    if branch is None and working is None:
        _show_repository_info_xml(repository, outfile)
    _show_repository_stats_xml(stats, outfile)
Exemplo n.º 12
0
 def assertCheckoutDescription(self, format, expected=None):
     """Assert a checkout's format description matches expectations"""
     if expected is None:
         expected = format
     branch = self.make_branch('%s_cobranch' % format, format=format)
     # this ought to be easier...
     branch.create_checkout('%s_co' % format,
         lightweight=True).bzrdir.destroy_workingtree()
     control = bzrdir.BzrDir.open('%s_co' % format)
     old_format = control._format.workingtree_format
     try:
         control._format.workingtree_format = \
             bzrdir.format_registry.make_bzrdir(format).workingtree_format
         control.create_workingtree()
         tree = workingtree.WorkingTree.open('%s_co' % format)
         format_description = info.describe_format(tree.bzrdir,
                 tree.branch.repository, tree.branch, tree)
         self.assertEqual(expected, format_description,
             "checkout of format called %r was described as %r" %
             (expected, format_description))
     finally:
         control._format.workingtree_format = old_format
Exemplo n.º 13
0
 def assertCheckoutDescription(self, format, expected=None):
     """Assert a checkout's format description matches expectations"""
     if expected is None:
         expected = format
     branch = self.make_branch('%s_cobranch' % format, format=format)
     # this ought to be easier...
     branch.create_checkout('%s_co' % format,
         lightweight=True).bzrdir.destroy_workingtree()
     control = controldir.ControlDir.open('%s_co' % format)
     old_format = control._format.workingtree_format
     try:
         control._format.workingtree_format = \
             controldir.format_registry.make_bzrdir(format).workingtree_format
         control.create_workingtree()
         tree = workingtree.WorkingTree.open('%s_co' % format)
         format_description = info.describe_format(tree.bzrdir,
                 tree.branch.repository, tree.branch, tree)
         self.assertEqual(expected, format_description,
             "checkout of format called %r was described as %r" %
             (expected, format_description))
     finally:
         control._format.workingtree_format = old_format
Exemplo n.º 14
0
 def assertTreeDescription(self, format):
     """Assert a tree's format description matches expectations"""
     self.make_branch_and_tree('%s_tree' % format, format=format)
     tree = workingtree.WorkingTree.open('%s_tree' % format)
     self.assertEqual(format, info.describe_format(tree.bzrdir,
         tree.branch.repository, tree.branch, tree))