~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2011-09-04 21:43:45 UTC
  • mto: This revision was merged to the branch mainline in revision 6127.
  • Revision ID: jelmer@samba.org-20110904214345-8bnxpdq78mdvdroi
Factor out resolve_format method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2620
2620
        repo = self.make_repository(relpath, format=format)
2621
2621
        return repo.bzrdir.create_branch()
2622
2622
 
 
2623
    def resolve_format(self, format):
 
2624
        """Resolve an object to a ControlDir format object.
 
2625
 
 
2626
        The initial format object can either already be
 
2627
        a ControlDirFormat, None (for the default format),
 
2628
        or a string with the name of the control dir format.
 
2629
 
 
2630
        :param format: Object to resolve
 
2631
        :return A ControlDirFormat instance
 
2632
        """
 
2633
        if format is None:
 
2634
            format = 'default'
 
2635
        if isinstance(format, basestring):
 
2636
            format = bzrdir.format_registry.make_bzrdir(format)
 
2637
        return format
 
2638
 
2623
2639
    def make_bzrdir(self, relpath, format=None):
2624
2640
        try:
2625
2641
            # might be a relative or absolute path
2628
2644
            t = _mod_transport.get_transport(maybe_a_url)
2629
2645
            if len(segments) > 1 and segments[-1] not in ('', '.'):
2630
2646
                t.ensure_base()
2631
 
            if format is None:
2632
 
                format = 'default'
2633
 
            if isinstance(format, basestring):
2634
 
                format = bzrdir.format_registry.make_bzrdir(format)
 
2647
            format = self.resolve_format(format)
2635
2648
            return format.initialize_on_transport(t)
2636
2649
        except errors.UninitializableFormat:
2637
2650
            raise TestSkipped("Format %s is not initializable." % format)