774
774
inventory = property(_get_inventory,
775
775
doc="Inventory of this Tree")
777
def _unpack_file_id(self, file_id):
778
if isinstance(file_id, tuple):
779
if len(file_id) != 0:
780
raise ValueError("nested trees not yet supported: %r" % file_id)
782
return self.inventory, file_id
778
785
def path2id(self, path):
779
786
"""Return the id for path in this tree."""
780
return self._inventory.path2id(path)
787
return self._path2inv_file_id(path)[1]
789
def _path2inv_file_id(self, path):
791
return self.inventory, self._inventory.path2id(path)
782
793
def id2path(self, file_id):
783
794
"""Return the path for a file id.
785
796
:raises NoSuchId:
787
return self.inventory.id2path(file_id)
798
inventory, file_id = self._unpack_file_id(file_id)
799
return inventory.id2path(file_id)
789
801
def has_id(self, file_id):
790
return self.inventory.has_id(file_id)
802
inventory, file_id = self._unpack_file_id(file_id)
803
return inventory.has_id(file_id)
792
805
def has_or_had_id(self, file_id):
793
return self.inventory.has_id(file_id)
806
inventory, file_id = self._unpack_file_id(file_id)
807
return inventory.has_id(file_id)
795
809
def all_file_ids(self):
796
return set(self.inventory)
810
return set(self.inventory) # for now
798
812
@deprecated_method(deprecated_in((2, 4, 0)))
799
813
def __iter__(self):
800
return iter(self.inventory)
814
return iter(self.inventory) # for now
802
816
def filter_unversioned_files(self, paths):
803
817
"""Filter out paths that are versioned.
807
821
# NB: we specifically *don't* call self.has_filename, because for
808
822
# WorkingTrees that can indicate files that exist on disk but that
809
823
# are not versioned.
810
pred = self.inventory.has_filename
824
pred = self.inventory.has_filename # for now
811
825
return set((p for p in paths if not pred(p)))
823
837
down to specific_file_ids that have been requested. This has no
824
838
impact if specific_file_ids is None.
840
if specific_file_ids is None:
841
inventory_file_ids = None
843
inventory_file_ids = []
844
for tree_file_id in specific_file_ids:
845
inventory, inv_file_id = self._unpack_file_id(tree_file_id)
846
if not inventory is self.inventory: # for now
847
raise AssertionError("%r != %r" % (inventory, self.inventory))
848
inventory_file_ids.append(inv_file_id)
826
849
return self.inventory.iter_entries_by_dir(
827
specific_file_ids=specific_file_ids, yield_parents=yield_parents)
850
specific_file_ids=inventory_file_ids, yield_parents=yield_parents)
829
852
@deprecated_method(deprecated_in((2, 5, 0)))
830
853
def get_file_by_path(self, path):