135
135
return self.inventory.has_id(file_id)
137
def is_ignored(self, filename):
138
"""Check whether the filename is ignored by this tree.
140
:param filename: The relative filename within the tree.
141
:return: True if the filename is ignored.
137
145
def __iter__(self):
138
146
return iter(self.inventory)
140
148
def id2path(self, file_id):
149
"""Return the path for a file id.
141
153
file_id = osutils.safe_file_id(file_id)
142
154
return self.inventory.id2path(file_id)
588
600
"""Generate an iterator of changes between trees.
590
602
A tuple is returned:
591
(file_id, path, changed_content, versioned, parent, name, kind,
603
(file_id, (path_in_source, path_in_target),
604
changed_content, versioned, parent, name, kind,
594
Path is relative to the target tree. changed_content is True if the
595
file's content has changed. This includes changes to its kind, and to
607
Changed_content is True if the file's content has changed. This
608
includes changes to its kind, and to a symlink's target.
598
610
versioned, parent, name, kind, executable are tuples of (from, to).
599
611
If a file is missing in a tree, its kind is None.
650
662
unversioned_path = all_unversioned.popleft()
651
663
to_kind, to_executable, to_stat = \
652
664
self.target._comparison_data(fake_entry, unversioned_path[1])
653
yield (None, unversioned_path[1], True, (False, False),
665
yield (None, (None, unversioned_path[1]), True, (False, False),
655
667
(None, unversioned_path[0][-1]),
704
716
if (changed_content is not False or versioned[0] != versioned[1]
705
717
or parent[0] != parent[1] or name[0] != name[1] or
706
718
executable[0] != executable[1] or include_unchanged):
707
yield (file_id, to_path, changed_content, versioned, parent,
708
name, kind, executable)
719
yield (file_id, (from_path, to_path), changed_content,
720
versioned, parent, name, kind, executable)
709
722
while all_unversioned:
710
723
# yield any trailing unversioned paths
711
724
unversioned_path = all_unversioned.popleft()
712
725
to_kind, to_executable, to_stat = \
713
726
self.target._comparison_data(fake_entry, unversioned_path[1])
714
yield (None, unversioned_path[1], True, (False, False),
727
yield (None, (None, unversioned_path[1]), True, (False, False),
716
729
(None, unversioned_path[0][-1]),
718
731
(None, to_executable))
720
def get_to_path(from_entry):
721
if from_entry.parent_id is None:
733
def get_to_path(to_entry):
734
if to_entry.parent_id is None:
735
to_path = '' # the root
724
if from_entry.parent_id not in to_paths:
725
get_to_path(self.source.inventory[from_entry.parent_id])
726
to_path = osutils.pathjoin(to_paths[from_entry.parent_id],
728
to_paths[from_entry.file_id] = to_path
737
if to_entry.parent_id not in to_paths:
739
return get_to_path(self.target.inventory[to_entry.parent_id])
740
to_path = osutils.pathjoin(to_paths[to_entry.parent_id],
742
to_paths[to_entry.file_id] = to_path
731
745
for path, from_entry in from_entries_by_dir:
732
746
file_id = from_entry.file_id
733
747
if file_id in to_paths:
735
to_path = get_to_path(from_entry)
750
if not file_id in self.target.inventory:
751
# common case - paths we have not emitted are not present in
755
to_path = get_to_path(self.target.inventory[file_id])
737
757
if pb is not None:
738
758
pb.update('comparing files', entry_count, num_entries)
745
765
executable = (from_executable, None)
746
766
changed_content = True
747
767
# the parent's path is necessarily known at this point.
748
yield(file_id, to_path, changed_content, versioned, parent,
768
yield(file_id, (path, to_path), changed_content, versioned, parent,
749
769
name, kind, executable)