/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/inventory.py

  • Committer: Martin Pool
  • Date: 2007-09-25 08:14:12 UTC
  • mto: This revision was merged to the branch mainline in revision 2895.
  • Revision ID: mbp@sourcefrog.net-20070925081412-ta60zj5qxfuokev3
Remove most calls to safe_file_id and safe_revision_id.

The deprecation period for passing unicode objects as revision ids is now over.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1025
1025
            impact if specific_file_ids is None.
1026
1026
        :return: This yields (path, entry) pairs
1027
1027
        """
1028
 
        if specific_file_ids:
1029
 
            safe = osutils.safe_file_id
1030
 
            specific_file_ids = set(safe(fid) for fid in specific_file_ids)
 
1028
        if specific_file_ids and not isinstance(specific_file_ids, set):
 
1029
            specific_file_ids = set(specific_file_ids)
1031
1030
        # TODO? Perhaps this should return the from_dir so that the root is
1032
1031
        # yielded? or maybe an option?
1033
1032
        if from_dir is None:
1134
1133
        >>> '456' in inv
1135
1134
        False
1136
1135
        """
1137
 
        file_id = osutils.safe_file_id(file_id)
1138
1136
        return (file_id in self._byid)
1139
1137
 
1140
1138
    def __getitem__(self, file_id):
1146
1144
        >>> inv['123123'].name
1147
1145
        'hello.c'
1148
1146
        """
1149
 
        file_id = osutils.safe_file_id(file_id)
1150
1147
        try:
1151
1148
            return self._byid[file_id]
1152
1149
        except KeyError:
1154
1151
            raise errors.NoSuchId(self, file_id)
1155
1152
 
1156
1153
    def get_file_kind(self, file_id):
1157
 
        file_id = osutils.safe_file_id(file_id)
1158
1154
        return self._byid[file_id].kind
1159
1155
 
1160
1156
    def get_child(self, parent_id, filename):
1161
 
        parent_id = osutils.safe_file_id(parent_id)
1162
1157
        return self[parent_id].children.get(filename)
1163
1158
 
1164
1159
    def _add_child(self, entry):
1212
1207
        if len(parts) == 0:
1213
1208
            if file_id is None:
1214
1209
                file_id = generate_ids.gen_root_id()
1215
 
            else:
1216
 
                file_id = osutils.safe_file_id(file_id)
1217
1210
            self.root = InventoryDirectory(file_id, '', None)
1218
1211
            self._byid = {self.root.file_id: self.root}
1219
1212
            return self.root
1237
1230
        >>> '123' in inv
1238
1231
        False
1239
1232
        """
1240
 
        file_id = osutils.safe_file_id(file_id)
1241
1233
        ie = self[file_id]
1242
1234
 
1243
1235
        assert ie.parent_id is None or \
1276
1268
 
1277
1269
    def _iter_file_id_parents(self, file_id):
1278
1270
        """Yield the parents of file_id up to the root."""
1279
 
        file_id = osutils.safe_file_id(file_id)
1280
1271
        while file_id is not None:
1281
1272
            try:
1282
1273
                ie = self._byid[file_id]
1293
1284
        is equal to the depth of the file in the tree, counting the
1294
1285
        root directory as depth 1.
1295
1286
        """
1296
 
        file_id = osutils.safe_file_id(file_id)
1297
1287
        p = []
1298
1288
        for parent in self._iter_file_id_parents(file_id):
1299
1289
            p.insert(0, parent.file_id)
1308
1298
        >>> print i.id2path('foo-id')
1309
1299
        src/foo.c
1310
1300
        """
1311
 
        file_id = osutils.safe_file_id(file_id)
1312
1301
        # get all names, skipping root
1313
1302
        return '/'.join(reversed(
1314
1303
            [parent.name for parent in 
1352
1341
        return bool(self.path2id(names))
1353
1342
 
1354
1343
    def has_id(self, file_id):
1355
 
        file_id = osutils.safe_file_id(file_id)
1356
1344
        return (file_id in self._byid)
1357
1345
 
1358
1346
    def remove_recursive_id(self, file_id):
1360
1348
        
1361
1349
        :param file_id: A file_id to remove.
1362
1350
        """
1363
 
        file_id = osutils.safe_file_id(file_id)
1364
1351
        to_find_delete = [self._byid[file_id]]
1365
1352
        to_delete = []
1366
1353
        while to_find_delete:
1383
1370
 
1384
1371
        This does not move the working file.
1385
1372
        """
1386
 
        file_id = osutils.safe_file_id(file_id)
1387
1373
        new_name = ensure_normalized_name(new_name)
1388
1374
        if not is_valid_name(new_name):
1389
1375
            raise BzrError("not an acceptable filename: %r" % new_name)
1409
1395
        file_ie.parent_id = new_parent_id
1410
1396
 
1411
1397
    def is_root(self, file_id):
1412
 
        file_id = osutils.safe_file_id(file_id)
1413
1398
        return self.root is not None and file_id == self.root.file_id
1414
1399
 
1415
1400
 
1430
1415
    """
1431
1416
    if file_id is None:
1432
1417
        file_id = generate_ids.gen_file_id(name)
1433
 
    else:
1434
 
        file_id = osutils.safe_file_id(file_id)
1435
1418
    name = ensure_normalized_name(name)
1436
1419
    try:
1437
1420
        factory = entry_factory[kind]