/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1209
1209
        return self.__server
1210
1210
 
1211
1211
    def get_url(self, relpath=None):
1212
 
        """Get a URL for the readwrite transport.
 
1212
        """Get a URL (or maybe a path) for the readwrite transport.
1213
1213
 
1214
1214
        This will either be backed by '.' or to an equivalent non-file based
1215
1215
        facility.
1220
1220
        if relpath is not None and relpath != '.':
1221
1221
            if not base.endswith('/'):
1222
1222
                base = base + '/'
1223
 
            base = base + urlutils.escape(relpath)
 
1223
            # XXX: Really base should be a url; we did after all call
 
1224
            # get_url()!  But sometimes it's just a path (from
 
1225
            # LocalAbspathServer), and it'd be wrong to append urlescaped data
 
1226
            # to a non-escaped local path.
 
1227
            if base.startswith('./') or base.startswith('/'):
 
1228
                base += relpath
 
1229
            else:
 
1230
                base += urlutils.escape(relpath)
1224
1231
        return base
1225
1232
 
1226
1233
    def get_transport(self):
1246
1253
 
1247
1254
    def make_bzrdir(self, relpath, format=None):
1248
1255
        try:
1249
 
            url = self.get_url(relpath)
1250
 
            mutter('relpath %r => url %r', relpath, url)
1251
 
            segments = url.split('/')
1252
 
            if segments and segments[-1] not in ('', '.'):
1253
 
                parent = '/'.join(segments[:-1])
1254
 
                t = get_transport(parent)
 
1256
            # might be a relative or absolute path
 
1257
            maybe_a_url = self.get_url(relpath)
 
1258
            segments = maybe_a_url.rsplit('/', 1)
 
1259
            t = get_transport(maybe_a_url)
 
1260
            if len(segments) > 1 and segments[-1] not in ('', '.'):
1255
1261
                try:
1256
 
                    t.mkdir(segments[-1])
 
1262
                    t.mkdir('.')
1257
1263
                except errors.FileExists:
1258
1264
                    pass
1259
1265
            if format is None:
1260
 
                format=bzrlib.bzrdir.BzrDirFormat.get_default_format()
1261
 
            # FIXME: make this use a single transport someday. RBC 20060418
1262
 
            return format.initialize_on_transport(get_transport(relpath))
 
1266
                format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
 
1267
            return format.initialize_on_transport(t)
1263
1268
        except errors.UninitializableFormat:
1264
1269
            raise TestSkipped("Format %s is not initializable." % format)
1265
1270
 
1271
1276
    def make_branch_and_tree(self, relpath, format=None):
1272
1277
        """Create a branch on the transport and a tree locally.
1273
1278
 
1274
 
        Returns the tree.
 
1279
        If the transport is not a LocalTransport, the Tree can't be created on
 
1280
        the transport.  In that case the working tree is created in the local
 
1281
        directory, and the returned tree's branch and repository will also be
 
1282
        accessed locally.
 
1283
 
 
1284
        This will fail if the original default transport for this test
 
1285
        case wasn't backed by the working directory, as the branch won't
 
1286
        be on disk for us to open it.  
 
1287
 
 
1288
        :param format: The BzrDirFormat.
 
1289
        :returns: the WorkingTree.
1275
1290
        """
1276
1291
        # TODO: always use the local disk path for the working tree,
1277
1292
        # this obviously requires a format that supports branch references
1281
1296
        try:
1282
1297
            return b.bzrdir.create_workingtree()
1283
1298
        except errors.NotLocalUrl:
1284
 
            # new formats - catch No tree error and create
1285
 
            # a branch reference and a checkout.
1286
 
            # old formats at that point - raise TestSkipped.
1287
 
            # TODO: rbc 20060208
1288
 
            return WorkingTreeFormat2().initialize(bzrdir.BzrDir.open(relpath))
 
1299
            # We can only make working trees locally at the moment.  If the
 
1300
            # transport can't support them, then reopen the branch on a local
 
1301
            # transport, and create the working tree there.  
 
1302
            #
 
1303
            # Possibly we should instead keep
 
1304
            # the non-disk-backed branch and create a local checkout?
 
1305
            bd = bzrdir.BzrDir.open(relpath)
 
1306
            return bd.create_workingtree()
1289
1307
 
1290
1308
    def assertIsDirectory(self, relpath, transport):
1291
1309
        """Assert that relpath within transport is a directory.