~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Martin von Gagern
  • Date: 2011-06-01 12:53:56 UTC
  • mto: This revision was merged to the branch mainline in revision 6009.
  • Revision ID: martin.vgagern@gmx.net-20110601125356-lwozv2vecea6hxfz
Change from no_decorate to classify as name for the argument.

The command line switch remains as --no-classify, to keep backwards
compatibility.  Users are free to include --no-classify in an alias, and
still use --classify to change back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    )
49
49
 
50
50
from bzrlib.static_tuple import StaticTuple
51
 
from bzrlib.symbol_versioning import (
52
 
    deprecated_in,
53
 
    deprecated_method,
54
 
    )
55
51
 
56
52
 
57
53
class InventoryEntry(object):
104
100
    InventoryDirectory('2325', 'wibble', parent_id='123', revision=None)
105
101
    >>> i.path2id('src/wibble')
106
102
    '2325'
 
103
    >>> '2325' in i
 
104
    True
107
105
    >>> i.add(InventoryFile('2326', 'wibble.c', '2325'))
108
106
    InventoryFile('2326', 'wibble.c', parent_id='2325', sha1=None, len=None, revision=None)
109
107
    >>> i['2326']
172
170
        candidates = {}
173
171
        # identify candidate head revision ids.
174
172
        for inv in previous_inventories:
175
 
            if inv.has_id(self.file_id):
 
173
            if self.file_id in inv:
176
174
                ie = inv[self.file_id]
177
175
                if ie.revision in candidates:
178
176
                    # same revision value in two different inventories:
631
629
    inserted, other than through the Inventory API.
632
630
    """
633
631
 
634
 
    @deprecated_method(deprecated_in((2, 4, 0)))
635
632
    def __contains__(self, file_id):
636
633
        """True if this entry contains a file with given id.
637
634
 
638
635
        >>> inv = Inventory()
639
636
        >>> inv.add(InventoryFile('123', 'foo.c', ROOT_ID))
640
637
        InventoryFile('123', 'foo.c', parent_id='TREE_ROOT', sha1=None, len=None, revision=None)
641
 
        >>> inv.has_id('123')
 
638
        >>> '123' in inv
642
639
        True
643
 
        >>> inv.has_id('456')
 
640
        >>> '456' in inv
644
641
        False
645
642
 
646
643
        Note that this method along with __iter__ are not encouraged for use as
759
756
            if (not yield_parents and specific_file_ids is not None and
760
757
                len(specific_file_ids) == 1):
761
758
                file_id = list(specific_file_ids)[0]
762
 
                if self.has_id(file_id):
 
759
                if file_id in self:
763
760
                    yield self.id2path(file_id), self[file_id]
764
761
                return
765
762
            from_dir = self.root
775
772
            parents = set()
776
773
            byid = self
777
774
            def add_ancestors(file_id):
778
 
                if not byid.has_id(file_id):
 
775
                if file_id not in byid:
779
776
                    return
780
777
                parent_id = byid[file_id].parent_id
781
778
                if parent_id is None:
965
962
 
966
963
    >>> inv.path2id('hello.c')
967
964
    '123-123'
968
 
    >>> inv.has_id('123-123')
 
965
    >>> '123-123' in inv
969
966
    True
970
967
 
971
968
    There are iterators over the contents:
1234
1231
        >>> inv = Inventory()
1235
1232
        >>> inv.add(InventoryFile('123', 'foo.c', ROOT_ID))
1236
1233
        InventoryFile('123', 'foo.c', parent_id='TREE_ROOT', sha1=None, len=None, revision=None)
1237
 
        >>> inv.has_id('123')
 
1234
        >>> '123' in inv
1238
1235
        True
1239
1236
        >>> del inv['123']
1240
 
        >>> inv.has_id('123')
 
1237
        >>> '123' in inv
1241
1238
        False
1242
1239
        """
1243
1240
        ie = self[file_id]
1490
1487
            if entry.kind == 'directory':
1491
1488
                directories_to_expand.add(entry.file_id)
1492
1489
            interesting.add(entry.parent_id)
1493
 
            children_of_parent_id.setdefault(entry.parent_id, set()
1494
 
                                             ).add(entry.file_id)
 
1490
            children_of_parent_id.setdefault(entry.parent_id, []
 
1491
                                             ).append(entry.file_id)
1495
1492
 
1496
1493
        # Now, interesting has all of the direct parents, but not the
1497
1494
        # parents of those parents. It also may have some duplicates with
1505
1502
            next_parents = set()
1506
1503
            for entry in self._getitems(remaining_parents):
1507
1504
                next_parents.add(entry.parent_id)
1508
 
                children_of_parent_id.setdefault(entry.parent_id, set()
1509
 
                                                 ).add(entry.file_id)
 
1505
                children_of_parent_id.setdefault(entry.parent_id, []
 
1506
                                                 ).append(entry.file_id)
1510
1507
            # Remove any search tips we've already processed
1511
1508
            remaining_parents = next_parents.difference(interesting)
1512
1509
            interesting.update(remaining_parents)
1525
1522
            for entry in self._getitems(next_file_ids):
1526
1523
                if entry.kind == 'directory':
1527
1524
                    directories_to_expand.add(entry.file_id)
1528
 
                children_of_parent_id.setdefault(entry.parent_id, set()
1529
 
                                                 ).add(entry.file_id)
 
1525
                children_of_parent_id.setdefault(entry.parent_id, []
 
1526
                                                 ).append(entry.file_id)
1530
1527
        return interesting, children_of_parent_id
1531
1528
 
1532
1529
    def filter(self, specific_fileids):