~mbp/bzr/doc-old

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-12 10:40:01 UTC
  • mfrom: (4127.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090312104001-k2722d61gjdpb91v
check for duplicate file-ids in Inventory.apply_delta (Ian Clatworthy)

Show diffs side-by-side

added added

removed removed

Lines of Context:
806
806
            change regardless. E.g. in the recursive deletion of a directory -
807
807
            the directory's children must be included in the delta, or the
808
808
            final inventory will be invalid.
 
809
 
 
810
            Note that a file_id must only appear once within a given delta.
 
811
            An AssertionError is raised otherwise.
809
812
        """
 
813
        # Check that the delta is legal. It would be nice if this could be
 
814
        # done within the loops below but it's safer to validate the delta
 
815
        # before starting to mutate the inventory.
 
816
        unique_file_ids = set([f for _, _, f, _ in delta])
 
817
        if len(unique_file_ids) != len(delta):
 
818
            raise AssertionError("a file-id appears multiple times in %r"
 
819
                    % (delta,))
 
820
        del unique_file_ids
 
821
 
810
822
        children = {}
811
823
        # Remove all affected items which were in the original inventory,
812
824
        # starting with the longest paths, thus ensuring parents are examined