/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: Andrew Bennetts
  • Date: 2007-10-12 05:26:46 UTC
  • mfrom: (2904 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2906.
  • Revision ID: andrew.bennetts@canonical.com-20071012052646-wl95idld3ijjy714
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1018
1018
            impact if specific_file_ids is None.
1019
1019
        :return: This yields (path, entry) pairs
1020
1020
        """
1021
 
        if specific_file_ids:
1022
 
            safe = osutils.safe_file_id
1023
 
            specific_file_ids = set(safe(fid) for fid in specific_file_ids)
 
1021
        if specific_file_ids and not isinstance(specific_file_ids, set):
 
1022
            specific_file_ids = set(specific_file_ids)
1024
1023
        # TODO? Perhaps this should return the from_dir so that the root is
1025
1024
        # yielded? or maybe an option?
1026
1025
        if from_dir is None:
1127
1126
        >>> '456' in inv
1128
1127
        False
1129
1128
        """
1130
 
        file_id = osutils.safe_file_id(file_id)
1131
1129
        return (file_id in self._byid)
1132
1130
 
1133
1131
    def __getitem__(self, file_id):
1139
1137
        >>> inv['123123'].name
1140
1138
        'hello.c'
1141
1139
        """
1142
 
        file_id = osutils.safe_file_id(file_id)
1143
1140
        try:
1144
1141
            return self._byid[file_id]
1145
1142
        except KeyError:
1147
1144
            raise errors.NoSuchId(self, file_id)
1148
1145
 
1149
1146
    def get_file_kind(self, file_id):
1150
 
        file_id = osutils.safe_file_id(file_id)
1151
1147
        return self._byid[file_id].kind
1152
1148
 
1153
1149
    def get_child(self, parent_id, filename):
1154
 
        parent_id = osutils.safe_file_id(parent_id)
1155
1150
        return self[parent_id].children.get(filename)
1156
1151
 
1157
1152
    def _add_child(self, entry):
1205
1200
        if len(parts) == 0:
1206
1201
            if file_id is None:
1207
1202
                file_id = generate_ids.gen_root_id()
1208
 
            else:
1209
 
                file_id = osutils.safe_file_id(file_id)
1210
1203
            self.root = InventoryDirectory(file_id, '', None)
1211
1204
            self._byid = {self.root.file_id: self.root}
1212
1205
            return self.root
1230
1223
        >>> '123' in inv
1231
1224
        False
1232
1225
        """
1233
 
        file_id = osutils.safe_file_id(file_id)
1234
1226
        ie = self[file_id]
1235
1227
 
1236
1228
        assert ie.parent_id is None or \
1269
1261
 
1270
1262
    def _iter_file_id_parents(self, file_id):
1271
1263
        """Yield the parents of file_id up to the root."""
1272
 
        file_id = osutils.safe_file_id(file_id)
1273
1264
        while file_id is not None:
1274
1265
            try:
1275
1266
                ie = self._byid[file_id]
1286
1277
        is equal to the depth of the file in the tree, counting the
1287
1278
        root directory as depth 1.
1288
1279
        """
1289
 
        file_id = osutils.safe_file_id(file_id)
1290
1280
        p = []
1291
1281
        for parent in self._iter_file_id_parents(file_id):
1292
1282
            p.insert(0, parent.file_id)
1301
1291
        >>> print i.id2path('foo-id')
1302
1292
        src/foo.c
1303
1293
        """
1304
 
        file_id = osutils.safe_file_id(file_id)
1305
1294
        # get all names, skipping root
1306
1295
        return '/'.join(reversed(
1307
1296
            [parent.name for parent in 
1345
1334
        return bool(self.path2id(names))
1346
1335
 
1347
1336
    def has_id(self, file_id):
1348
 
        file_id = osutils.safe_file_id(file_id)
1349
1337
        return (file_id in self._byid)
1350
1338
 
1351
1339
    def remove_recursive_id(self, file_id):
1353
1341
        
1354
1342
        :param file_id: A file_id to remove.
1355
1343
        """
1356
 
        file_id = osutils.safe_file_id(file_id)
1357
1344
        to_find_delete = [self._byid[file_id]]
1358
1345
        to_delete = []
1359
1346
        while to_find_delete:
1376
1363
 
1377
1364
        This does not move the working file.
1378
1365
        """
1379
 
        file_id = osutils.safe_file_id(file_id)
1380
1366
        new_name = ensure_normalized_name(new_name)
1381
1367
        if not is_valid_name(new_name):
1382
1368
            raise BzrError("not an acceptable filename: %r" % new_name)
1402
1388
        file_ie.parent_id = new_parent_id
1403
1389
 
1404
1390
    def is_root(self, file_id):
1405
 
        file_id = osutils.safe_file_id(file_id)
1406
1391
        return self.root is not None and file_id == self.root.file_id
1407
1392
 
1408
1393
 
1423
1408
    """
1424
1409
    if file_id is None:
1425
1410
        file_id = generate_ids.gen_file_id(name)
1426
 
    else:
1427
 
        file_id = osutils.safe_file_id(file_id)
1428
1411
    name = ensure_normalized_name(name)
1429
1412
    try:
1430
1413
        factory = entry_factory[kind]