~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-21 19:49:25 UTC
  • mto: This revision was merged to the branch mainline in revision 6182.
  • Revision ID: jelmer@canonical.com-20110921194925-u2djv7hrboxe6cn3
Add hack to support running against branches with a control dir that does not support working trees.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2957
2957
        # this obviously requires a format that supports branch references
2958
2958
        # so check for that by checking bzrdir.BzrDirFormat.get_default_format()
2959
2959
        # RBC 20060208
2960
 
        b = self.make_branch(relpath, format=format)
2961
 
        try:
2962
 
            return b.bzrdir.create_workingtree()
2963
 
        except errors.NotLocalUrl:
2964
 
            # We can only make working trees locally at the moment.  If the
2965
 
            # transport can't support them, then we keep the non-disk-backed
2966
 
            # branch and create a local checkout.
2967
 
            if self.vfs_transport_factory is test_server.LocalURLServer:
2968
 
                # the branch is colocated on disk, we cannot create a checkout.
2969
 
                # hopefully callers will expect this.
2970
 
                local_controldir= bzrdir.BzrDir.open(self.get_vfs_only_url(relpath))
2971
 
                wt = local_controldir.create_workingtree()
2972
 
                if wt.branch._format != b._format:
2973
 
                    wt._branch = b
2974
 
                    # Make sure that assigning to wt._branch fixes wt.branch,
2975
 
                    # in case the implementation details of workingtree objects
2976
 
                    # change.
2977
 
                    self.assertIs(b, wt.branch)
2978
 
                return wt
2979
 
            else:
2980
 
                return b.create_checkout(relpath, lightweight=True)
 
2960
        format = self.resolve_format(format)
 
2961
        if not format.supports_workingtrees:
 
2962
            b = self.make_branch(relpath+".branch", format=format)
 
2963
            return b.create_checkout(relpath, lightweight=True)
 
2964
        else:
 
2965
            b = self.make_branch(relpath, format=format)
 
2966
            try:
 
2967
                return b.bzrdir.create_workingtree()
 
2968
            except errors.NotLocalUrl:
 
2969
                # We can only make working trees locally at the moment.  If the
 
2970
                # transport can't support them, then we keep the non-disk-backed
 
2971
                # branch and create a local checkout.
 
2972
                if self.vfs_transport_factory is test_server.LocalURLServer:
 
2973
                    # the branch is colocated on disk, we cannot create a checkout.
 
2974
                    # hopefully callers will expect this.
 
2975
                    local_controldir = bzrdir.BzrDir.open(self.get_vfs_only_url(relpath))
 
2976
                    wt = local_controldir.create_workingtree()
 
2977
                    if wt.branch._format != b._format:
 
2978
                        wt._branch = b
 
2979
                        # Make sure that assigning to wt._branch fixes wt.branch,
 
2980
                        # in case the implementation details of workingtree objects
 
2981
                        # change.
 
2982
                        self.assertIs(b, wt.branch)
 
2983
                    return wt
 
2984
                else:
 
2985
                    return b.create_checkout(relpath, lightweight=True)
2981
2986
 
2982
2987
    def assertIsDirectory(self, relpath, transport):
2983
2988
        """Assert that relpath within transport is a directory.