/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

Merged in bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
771
771
        self.revision_id = revision_id
772
772
 
773
773
    def __repr__(self):
774
 
        return "<Inventory object at %x, contents=%r>" % (id(self), self._byid)
 
774
        # More than one page of ouput is not useful anymore to debug
 
775
        max_len = 2048
 
776
        closing = '...}'
 
777
        contents = repr(self._byid)
 
778
        if len(contents) > max_len:
 
779
            contents = contents[:(max_len-len(closing))] + closing
 
780
        return "<Inventory object at %x, contents=%r>" % (id(self), contents)
775
781
 
776
782
    def apply_delta(self, delta):
777
783
        """Apply a delta to this inventory.
806
812
            change regardless. E.g. in the recursive deletion of a directory -
807
813
            the directory's children must be included in the delta, or the
808
814
            final inventory will be invalid.
 
815
 
 
816
            Note that a file_id must only appear once within a given delta.
 
817
            An AssertionError is raised otherwise.
809
818
        """
 
819
        # Check that the delta is legal. It would be nice if this could be
 
820
        # done within the loops below but it's safer to validate the delta
 
821
        # before starting to mutate the inventory.
 
822
        unique_file_ids = set([f for _, _, f, _ in delta])
 
823
        if len(unique_file_ids) != len(delta):
 
824
            raise AssertionError("a file-id appears multiple times in %r"
 
825
                    % (delta,))
 
826
        del unique_file_ids
 
827
 
810
828
        children = {}
811
829
        # Remove all affected items which were in the original inventory,
812
830
        # starting with the longest paths, thus ensuring parents are examined