~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Vincent Ladeuil
  • Date: 2012-03-09 11:01:58 UTC
  • mto: This revision was merged to the branch mainline in revision 6489.
  • Revision ID: v.ladeuil+lp@free.fr-20120309110158-62om0ttqa0ooeuw5
Fix the forgotten reference to what's new as part of the 2.6 series initialization.

Show diffs side-by-side

added added

removed removed

Lines of Context:
633
633
    inserted, other than through the Inventory API.
634
634
    """
635
635
 
 
636
    @deprecated_method(deprecated_in((2, 4, 0)))
 
637
    def __contains__(self, file_id):
 
638
        """True if this entry contains a file with given id.
 
639
 
 
640
        >>> inv = Inventory()
 
641
        >>> inv.add(InventoryFile('123', 'foo.c', ROOT_ID))
 
642
        InventoryFile('123', 'foo.c', parent_id='TREE_ROOT', sha1=None, len=None, revision=None)
 
643
        >>> inv.has_id('123')
 
644
        True
 
645
        >>> inv.has_id('456')
 
646
        False
 
647
 
 
648
        Note that this method along with __iter__ are not encouraged for use as
 
649
        they are less clear than specific query methods - they may be rmeoved
 
650
        in the future.
 
651
        """
 
652
        return self.has_id(file_id)
 
653
 
636
654
    def has_filename(self, filename):
637
655
        return bool(self.path2id(filename))
638
656
 
2093
2111
    def path2id(self, relpath):
2094
2112
        """See CommonInventory.path2id()."""
2095
2113
        # TODO: perhaps support negative hits?
2096
 
        if isinstance(relpath, basestring):
2097
 
            names = osutils.splitpath(relpath)
2098
 
        else:
2099
 
            names = relpath
2100
 
            if relpath == []:
2101
 
                relpath = [""]
2102
 
            relpath = osutils.pathjoin(*relpath)
2103
2114
        result = self._path_to_fileid_cache.get(relpath, None)
2104
2115
        if result is not None:
2105
2116
            return result
 
2117
        if isinstance(relpath, basestring):
 
2118
            names = osutils.splitpath(relpath)
 
2119
        else:
 
2120
            names = relpath
2106
2121
        current_id = self.root_id
2107
2122
        if current_id is None:
2108
2123
            return None