127
127
def has_id(self, file_id):
128
128
raise NotImplementedError(self.has_id)
130
@deprecated_method(deprecated_in((2, 4, 0)))
131
130
def __contains__(self, file_id):
132
131
return self.has_id(file_id)
177
176
The yield order (ignoring root) would be::
179
177
a, f, a/b, a/d, a/b/c, a/d/e, f/g
181
179
:param yield_parents: If True, yield the parents from the root leading
292
290
:param file_id: The file_id of the file.
293
291
:param path: The path of the file.
295
292
If both file_id and path are supplied, an implementation may use
298
295
return osutils.split_lines(self.get_file_text(file_id, path))
300
def get_file_sha1(self, file_id, path=None, stat_value=None):
297
def get_file_sha1(self, file_id, path=None):
301
298
"""Return the SHA1 file for a file.
303
300
:param file_id: The handle for this file.
304
301
:param path: The path that this file can be found at.
305
302
These must point to the same object.
306
:param stat_value: Optional stat value for the object
308
304
raise NotImplementedError(self.get_file_sha1)
801
797
return self.get_file(self._inventory.path2id(path), path)
800
######################################################################
803
# TODO: Merge these two functions into a single one that can operate
804
# on either a whole tree or a set of files.
806
# TODO: Return the diff in order by filename, not by category or in
807
# random order. Can probably be done by lock-stepping through the
808
# filenames from both trees.
811
def file_status(filename, old_tree, new_tree):
812
"""Return single-letter status, old and new names for a file.
814
The complexity here is in deciding how to represent renames;
815
many complex cases are possible.
817
old_inv = old_tree.inventory
818
new_inv = new_tree.inventory
819
new_id = new_inv.path2id(filename)
820
old_id = old_inv.path2id(filename)
822
if not new_id and not old_id:
823
# easy: doesn't exist in either; not versioned at all
824
if new_tree.is_ignored(filename):
825
return 'I', None, None
827
return '?', None, None
829
# There is now a file of this name, great.
832
# There is no longer a file of this name, but we can describe
833
# what happened to the file that used to have
834
# this name. There are two possibilities: either it was
835
# deleted entirely, or renamed.
836
if new_inv.has_id(old_id):
837
return 'X', old_inv.id2path(old_id), new_inv.id2path(old_id)
839
return 'D', old_inv.id2path(old_id), None
841
# if the file_id is new in this revision, it is added
842
if new_id and not old_inv.has_id(new_id):
845
# if there used to be a file of this name, but that ID has now
846
# disappeared, it is deleted
847
if old_id and not new_inv.has_id(old_id):
804
853
def find_ids_across_trees(filenames, trees, require_versioned=True):
805
854
"""Find the ids corresponding to specified filenames.