800
800
return self.get_file(self._inventory.path2id(path), path)
803
######################################################################
806
# TODO: Merge these two functions into a single one that can operate
807
# on either a whole tree or a set of files.
809
# TODO: Return the diff in order by filename, not by category or in
810
# random order. Can probably be done by lock-stepping through the
811
# filenames from both trees.
814
def file_status(filename, old_tree, new_tree):
815
"""Return single-letter status, old and new names for a file.
817
The complexity here is in deciding how to represent renames;
818
many complex cases are possible.
820
old_inv = old_tree.inventory
821
new_inv = new_tree.inventory
822
new_id = new_inv.path2id(filename)
823
old_id = old_inv.path2id(filename)
825
if not new_id and not old_id:
826
# easy: doesn't exist in either; not versioned at all
827
if new_tree.is_ignored(filename):
828
return 'I', None, None
830
return '?', None, None
832
# There is now a file of this name, great.
835
# There is no longer a file of this name, but we can describe
836
# what happened to the file that used to have
837
# this name. There are two possibilities: either it was
838
# deleted entirely, or renamed.
839
if new_inv.has_id(old_id):
840
return 'X', old_inv.id2path(old_id), new_inv.id2path(old_id)
842
return 'D', old_inv.id2path(old_id), None
844
# if the file_id is new in this revision, it is added
845
if new_id and not old_inv.has_id(new_id):
848
# if there used to be a file of this name, but that ID has now
849
# disappeared, it is deleted
850
if old_id and not new_inv.has_id(old_id):
856
803
def find_ids_across_trees(filenames, trees, require_versioned=True):
857
804
"""Find the ids corresponding to specified filenames.