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