192
192
def diff_cmd_helper(tree, specific_files, external_diff_options,
193
old_revision_spec=None, new_revision_spec=None):
193
old_revision_spec=None, new_revision_spec=None,
194
old_label='a/', new_label='b/'):
194
195
"""Helper for cmd_diff.
229
230
new_tree = spec_tree(new_revision_spec)
231
232
return show_diff_trees(old_tree, new_tree, sys.stdout, specific_files,
232
external_diff_options)
233
external_diff_options,
234
old_label=old_label, new_label=new_label)
235
237
def show_diff_trees(old_tree, new_tree, to_file, specific_files=None,
236
external_diff_options=None):
238
external_diff_options=None,
239
old_label='a/', new_label='b/'):
237
240
"""Show in text form the changes from one tree to another.
247
250
new_tree.lock_read()
249
252
return _show_diff_trees(old_tree, new_tree, to_file,
250
specific_files, external_diff_options)
253
specific_files, external_diff_options,
254
old_label=old_label, new_label=new_label)
252
256
new_tree.unlock()
257
261
def _show_diff_trees(old_tree, new_tree, to_file,
258
specific_files, external_diff_options):
260
# TODO: Options to control putting on a prefix or suffix, perhaps
261
# as a format string?
262
specific_files, external_diff_options,
263
old_label='a/', new_label='b/' ):
265
265
DEVNULL = '/dev/null'
266
266
# Windows users, don't panic about this filename -- it is a
287
287
for path, file_id, kind in delta.removed:
289
print >>to_file, '=== removed %s %r' % (kind, old_label + path)
289
print >>to_file, '=== removed %s %r' % (kind, path)
290
290
old_tree.inventory[file_id].diff(diff_file, old_label + path, old_tree,
291
291
DEVNULL, None, None, to_file)
292
292
for path, file_id, kind in delta.added:
294
print >>to_file, '=== added %s %r' % (kind, new_label + path)
294
print >>to_file, '=== added %s %r' % (kind, path)
295
295
new_tree.inventory[file_id].diff(diff_file, new_label + path, new_tree,
296
296
DEVNULL, None, None, to_file,
301
301
prop_str = get_prop_change(meta_modified)
302
302
print >>to_file, '=== renamed %s %r => %r%s' % (
303
kind, old_label + old_path, new_label + new_path, prop_str)
303
kind, old_path, new_path, prop_str)
304
304
_maybe_diff_file_or_symlink(old_label, old_path, old_tree, file_id,
305
305
new_label, new_path, new_tree,
306
306
text_modified, kind, to_file, diff_file)
307
307
for path, file_id, kind, text_modified, meta_modified in delta.modified:
309
309
prop_str = get_prop_change(meta_modified)
310
print >>to_file, '=== modified %s %r%s' % (kind, old_label + path,
310
print >>to_file, '=== modified %s %r%s' % (kind, path, prop_str)
312
311
if text_modified:
313
312
_maybe_diff_file_or_symlink(old_label, path, old_tree, file_id,
314
313
new_label, path, new_tree,