143
143
def show_diff(b, revision, file_list):
144
import difflib, sys, types
146
146
if revision == None:
147
147
old_tree = b.basis_tree()
245
245
fromfile=old_label + old_name + idlabel,
246
246
tofile=new_label + new_name)
248
bailout("can't represent state %s {%s}" % (file_state, fid))
248
raise BzrError("can't represent state %s {%s}" % (file_state, fid))
253
"""Describes changes from one tree to another.
262
(oldpath, newpath, id)
266
A path may occur in more than one list if it was e.g. deleted
267
under an old id and renamed into place in a new id.
269
Files are listed in either modified or renamed, not both. In
270
other words, renamed files may also be modified.
279
def compare_inventories(old_inv, new_inv):
280
"""Return a TreeDelta object describing changes between inventories.
282
This only describes changes in the shape of the tree, not the
285
This is an alternative to diff_trees() and should probably
286
eventually replace it.
288
old_ids = old_inv.id_set()
289
new_ids = new_inv.id_set()
292
delta.removed = [(old_inv.id2path(fid), fid) for fid in (old_ids - new_ids)]
295
delta.added = [(new_inv.id2path(fid), fid) for fid in (new_ids - old_ids)]
298
for fid in old_ids & new_ids:
299
old_ie = old_inv[fid]
300
new_ie = new_inv[fid]
301
old_path = old_inv.id2path(fid)
302
new_path = new_inv.id2path(fid)
304
if old_path != new_path:
305
delta.renamed.append((old_path, new_path, fid))
306
elif old_ie.text_sha1 != new_ie.text_sha1:
307
delta.modified.append((new_path, fid))
309
delta.modified.sort()