/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:
151
151
            from bzrlib.version import _get_bzr_source_tree
152
152
            src_tree = _get_bzr_source_tree()
153
153
            if src_tree:
154
 
                revision_id = src_tree.last_revision()
 
154
                try:
 
155
                    revision_id = src_tree.get_parent_ids()[0]
 
156
                except IndexError:
 
157
                    # XXX: if this is a brand new tree, do the same as if there
 
158
                    # is no branch.
 
159
                    revision_id = ''
155
160
            else:
156
161
                # XXX: If there's no branch, what should we do?
157
162
                revision_id = ''
894
899
                osutils.set_or_unset_env(env_var, value)
895
900
 
896
901
        bzr_path = os.path.dirname(os.path.dirname(bzrlib.__file__))+'/bzr'
 
902
        if not os.path.isfile(bzr_path):
 
903
            # We are probably installed. Assume sys.argv is the right file
 
904
            bzr_path = sys.argv[0]
897
905
        args = list(args)
898
906
 
899
907
        try:
916
924
        retcode = process.wait()
917
925
        supplied_retcode = kwargs.get('retcode', 0)
918
926
        if supplied_retcode is not None:
919
 
            assert supplied_retcode == retcode
 
927
            if supplied_retcode != retcode:
 
928
                mutter('Output of bzr %s:\n%s', args, out)
 
929
                mutter('Error for bzr %s:\n%s', args, err)
 
930
                self.fail('Command bzr %s failed with retcode %s != %s'
 
931
                          % (args, supplied_retcode, retcode))
920
932
        return [out, err]
921
933
 
922
934
    def check_inventory_shape(self, inv, shape):
1198
1210
        return self.__server
1199
1211
 
1200
1212
    def get_url(self, relpath=None):
1201
 
        """Get a URL for the readwrite transport.
 
1213
        """Get a URL (or maybe a path) for the readwrite transport.
1202
1214
 
1203
1215
        This will either be backed by '.' or to an equivalent non-file based
1204
1216
        facility.
1209
1221
        if relpath is not None and relpath != '.':
1210
1222
            if not base.endswith('/'):
1211
1223
                base = base + '/'
1212
 
            base = base + urlutils.escape(relpath)
 
1224
            # XXX: Really base should be a url; we did after all call
 
1225
            # get_url()!  But sometimes it's just a path (from
 
1226
            # LocalAbspathServer), and it'd be wrong to append urlescaped data
 
1227
            # to a non-escaped local path.
 
1228
            if base.startswith('./') or base.startswith('/'):
 
1229
                base += relpath
 
1230
            else:
 
1231
                base += urlutils.escape(relpath)
1213
1232
        return base
1214
1233
 
1215
1234
    def get_transport(self):
1237
1256
        try:
1238
1257
            # might be a relative or absolute path
1239
1258
            maybe_a_url = self.get_url(relpath)
1240
 
            segments = maybe_a_url.split('/')
 
1259
            segments = maybe_a_url.rsplit('/', 1)
1241
1260
            t = get_transport(maybe_a_url)
1242
 
            if segments and segments[-1] not in ('', '.'):
 
1261
            if len(segments) > 1 and segments[-1] not in ('', '.'):
1243
1262
                try:
1244
1263
                    t.mkdir('.')
1245
1264
                except errors.FileExists:
1263
1282
    def make_branch_and_tree(self, relpath, format=None):
1264
1283
        """Create a branch on the transport and a tree locally.
1265
1284
 
1266
 
        Returns the tree.
 
1285
        If the transport is not a LocalTransport, the Tree can't be created on
 
1286
        the transport.  In that case the working tree is created in the local
 
1287
        directory, and the returned tree's branch and repository will also be
 
1288
        accessed locally.
 
1289
 
 
1290
        This will fail if the original default transport for this test
 
1291
        case wasn't backed by the working directory, as the branch won't
 
1292
        be on disk for us to open it.  
 
1293
 
 
1294
        :param format: The BzrDirFormat.
 
1295
        :returns: the WorkingTree.
1267
1296
        """
1268
1297
        # TODO: always use the local disk path for the working tree,
1269
1298
        # this obviously requires a format that supports branch references
1273
1302
        try:
1274
1303
            return b.bzrdir.create_workingtree()
1275
1304
        except errors.NotLocalUrl:
1276
 
            # new formats - catch No tree error and create
1277
 
            # a branch reference and a checkout.
1278
 
            # old formats at that point - raise TestSkipped.
1279
 
            # TODO: rbc 20060208
1280
 
            return WorkingTreeFormat2().initialize(bzrdir.BzrDir.open(relpath))
 
1305
            # We can only make working trees locally at the moment.  If the
 
1306
            # transport can't support them, then reopen the branch on a local
 
1307
            # transport, and create the working tree there.  
 
1308
            #
 
1309
            # Possibly we should instead keep
 
1310
            # the non-disk-backed branch and create a local checkout?
 
1311
            bd = bzrdir.BzrDir.open(relpath)
 
1312
            return bd.create_workingtree()
1281
1313
 
1282
1314
    def assertIsDirectory(self, relpath, transport):
1283
1315
        """Assert that relpath within transport is a directory.
1413
1445
                   'bzrlib.tests.test_ignores',
1414
1446
                   'bzrlib.tests.test_inv',
1415
1447
                   'bzrlib.tests.test_knit',
 
1448
                   'bzrlib.tests.test_lazy_import',
1416
1449
                   'bzrlib.tests.test_lockdir',
1417
1450
                   'bzrlib.tests.test_lockable_files',
1418
1451
                   'bzrlib.tests.test_log',