~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Max Bowsher
  • Date: 2012-08-08 11:44:19 UTC
  • mfrom: (6552 +trunk)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: _@maxb.eu-20120808114419-hes7at3ihv3mwi16
MergeĀ lp:bzr

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
 
 
654
636
    def has_filename(self, filename):
655
637
        return bool(self.path2id(filename))
656
638
 
2111
2093
    def path2id(self, relpath):
2112
2094
        """See CommonInventory.path2id()."""
2113
2095
        # 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)
2114
2103
        result = self._path_to_fileid_cache.get(relpath, None)
2115
2104
        if result is not None:
2116
2105
            return result
2117
 
        if isinstance(relpath, basestring):
2118
 
            names = osutils.splitpath(relpath)
2119
 
        else:
2120
 
            names = relpath
2121
2106
        current_id = self.root_id
2122
2107
        if current_id is None:
2123
2108
            return None