45
44
ud = difflib.unified_diff(oldlines, newlines,
46
45
fromfile=old_label, tofile=new_label)
48
48
# work-around for difflib being too smart for its own good
49
49
# if /dev/null is "1,0", patch won't recognize it as /dev/null
52
51
ud[2] = ud[2].replace('-1,0', '-0,0')
55
53
ud[2] = ud[2].replace('+1,0', '+0,0')
54
# work around for difflib emitting random spaces after the label
55
ud[0] = ud[0][:-2] + '\n'
56
ud[1] = ud[1][:-2] + '\n'
58
59
to_file.write(line)
157
158
output = sys.stdout
160
161
old_tree = b.basis_tree()
162
old_tree = b.revision_tree(b.lookup_revision(revision))
163
old_tree = b.revision_tree(revision.in_history(b).rev_id)
164
if revision2 == None:
165
if revision2 is None:
165
166
new_tree = b.working_tree()
167
new_tree = b.revision_tree(b.lookup_revision(revision2))
168
new_tree = b.revision_tree(revision2.in_history(b).rev_id)
169
170
show_diff_trees(old_tree, new_tree, output, specific_files,
170
171
external_diff_options)
207
208
specific_files=specific_files)
209
210
for path, file_id, kind in delta.removed:
210
print >>to_file, '*** removed %s %r' % (kind, path)
211
print >>to_file, '=== removed %s %r' % (kind, path)
211
212
if kind == 'file':
212
213
diff_file(old_label + path,
213
214
old_tree.get_file(file_id).readlines(),
218
218
for path, file_id, kind in delta.added:
219
print >>to_file, '*** added %s %r' % (kind, path)
219
print >>to_file, '=== added %s %r' % (kind, path)
220
220
if kind == 'file':
221
221
diff_file(DEVNULL,
223
223
new_label + path,
224
224
new_tree.get_file(file_id).readlines(),
227
226
for old_path, new_path, file_id, kind, text_modified in delta.renamed:
228
print >>to_file, '*** renamed %s %r => %r' % (kind, old_path, new_path)
227
print >>to_file, '=== renamed %s %r => %r' % (kind, old_path, new_path)
229
228
_maybe_diff_file_or_symlink(old_label, old_path, old_tree, file_id,
230
229
new_label, new_path, new_tree,
231
230
text_modified, kind, to_file, diff_file)
233
231
for path, file_id, kind in delta.modified:
234
print >>to_file, '*** modified %s %r' % (kind, path)
232
print >>to_file, '=== modified %s %r' % (kind, path)
235
233
_maybe_diff_file_or_symlink(old_label, path, old_tree, file_id,
236
234
new_label, path, new_tree,
237
235
True, kind, to_file, diff_file)
239
238
def _maybe_diff_file_or_symlink(old_label, old_path, old_tree, file_id,
240
239
new_label, new_path, new_tree, text_modified,
252
251
def _diff_symlink(old_tree, new_tree, file_id, to_file):
253
252
t1 = old_tree.get_symlink_target(file_id)
254
253
t2 = new_tree.get_symlink_target(file_id)
255
print >>to_file, '*** *** target changed %r => %r' % (t1, t2)
254
print >>to_file, '=== target changed %r => %r' % (t1, t2)