~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Robert Collins
  • Date: 2009-07-20 05:19:53 UTC
  • mto: This revision was merged to the branch mainline in revision 4553.
  • Revision ID: robertc@robertcollins.net-20090720051953-rohq200jtq2vyhhj
Check fileids in inventory deltas are not None and are strings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1132
1132
        # facility.
1133
1133
        list(_check_delta_unique_ids(_check_delta_unique_new_paths(
1134
1134
            _check_delta_unique_old_paths(_check_delta_ids_match_entry(
 
1135
            _check_delta_ids_are_valid(
1135
1136
            _check_delta_new_path_entry_both_or_None(
1136
 
            delta))))))
 
1137
            delta)))))))
1137
1138
 
1138
1139
        children = {}
1139
1140
        # Remove all affected items which were in the original inventory,
1646
1647
        inventory_delta = _check_delta_unique_new_paths(inventory_delta)
1647
1648
        # Check for entries that don't match the fileid
1648
1649
        inventory_delta = _check_delta_ids_match_entry(inventory_delta)
 
1650
        # Check for nonsense fileids
 
1651
        inventory_delta = _check_delta_ids_are_valid(inventory_delta)
1649
1652
        # Check for new_path <-> entry consistency
1650
1653
        inventory_delta = _check_delta_new_path_entry_both_or_None(
1651
1654
            inventory_delta)
2231
2234
        yield item
2232
2235
 
2233
2236
 
 
2237
def _check_delta_ids_are_valid(delta):
 
2238
    """Decorate a delta and check that the ids in it are valid.
 
2239
 
 
2240
    :return: A generator over delta.
 
2241
    """
 
2242
    for item in delta:
 
2243
        entry = item[3]
 
2244
        if item[2] is None:
 
2245
            raise errors.InconsistentDelta(item[0] or item[1], item[2],
 
2246
                "entry with file_id None %r" % entry)
 
2247
        if type(item[2]) != str:
 
2248
            raise errors.InconsistentDelta(item[0] or item[1], item[2],
 
2249
                "entry with non bytes file_id %r" % entry)
 
2250
        yield item
 
2251
 
 
2252
 
2234
2253
def _check_delta_ids_match_entry(delta):
2235
2254
    """Decorate a delta and check that the ids in it match the entry.file_id.
2236
2255