291
293
for path, file_id, kind in delta.removed:
293
print >>to_file, '=== removed %s %r' % (kind, path)
294
old_tree.inventory[file_id].diff(diff_file, old_label + path, old_tree,
295
DEVNULL, None, None, to_file)
295
print >>to_file, '=== removed %s %r' % (kind, path.encode('utf8'))
296
old_name = '%s%s\t%s' % (old_label, path,
297
_patch_header_date(old_tree, file_id, path))
298
new_name = '%s%s\t%s' % (new_label, path, EPOCH_DATE)
299
old_tree.inventory[file_id].diff(diff_file, old_name, old_tree,
300
new_name, None, None, to_file)
296
301
for path, file_id, kind in delta.added:
298
print >>to_file, '=== added %s %r' % (kind, path)
299
new_tree.inventory[file_id].diff(diff_file, new_label + path, new_tree,
300
DEVNULL, None, None, to_file,
303
print >>to_file, '=== added %s %r' % (kind, path.encode('utf8'))
304
old_name = '%s%s\t%s' % (old_label, path, EPOCH_DATE)
305
new_name = '%s%s\t%s' % (new_label, path,
306
_patch_header_date(new_tree, file_id, path))
307
new_tree.inventory[file_id].diff(diff_file, new_name, new_tree,
308
old_name, None, None, to_file,
302
310
for (old_path, new_path, file_id, kind,
303
311
text_modified, meta_modified) in delta.renamed:
305
313
prop_str = get_prop_change(meta_modified)
306
314
print >>to_file, '=== renamed %s %r => %r%s' % (
307
kind, old_path, new_path, prop_str)
308
_maybe_diff_file_or_symlink(old_label, old_path, old_tree, file_id,
309
new_label, new_path, new_tree,
315
kind, old_path.encode('utf8'),
316
new_path.encode('utf8'), prop_str)
317
old_name = '%s%s\t%s' % (old_label, old_path,
318
_patch_header_date(old_tree, file_id,
320
new_name = '%s%s\t%s' % (new_label, new_path,
321
_patch_header_date(new_tree, file_id,
323
_maybe_diff_file_or_symlink(old_name, old_tree, file_id,
310
325
text_modified, kind, to_file, diff_file)
311
326
for path, file_id, kind, text_modified, meta_modified in delta.modified:
313
328
prop_str = get_prop_change(meta_modified)
314
print >>to_file, '=== modified %s %r%s' % (kind, path, prop_str)
329
print >>to_file, '=== modified %s %r%s' % (kind, path.encode('utf8'), prop_str)
330
old_name = '%s%s\t%s' % (old_label, path,
331
_patch_header_date(old_tree, file_id, path))
332
new_name = '%s%s\t%s' % (new_label, path,
333
_patch_header_date(new_tree, file_id, path))
315
334
if text_modified:
316
_maybe_diff_file_or_symlink(old_label, path, old_tree, file_id,
317
new_label, path, new_tree,
335
_maybe_diff_file_or_symlink(old_name, old_tree, file_id,
318
337
True, kind, to_file, diff_file)
320
339
return has_changes
342
def _patch_header_date(tree, file_id, path):
343
"""Returns a timestamp suitable for use in a patch header."""
344
tm = time.gmtime(tree.get_file_mtime(file_id, path))
345
return time.strftime('%Y-%m-%d %H:%M:%S +0000', tm)
323
348
def _raise_if_doubly_unversioned(specific_files, old_tree, new_tree):
324
349
"""Complain if paths are not versioned in either tree."""
325
350
if not specific_files:
360
def _maybe_diff_file_or_symlink(old_label, old_path, old_tree, file_id,
361
new_label, new_path, new_tree, text_modified,
385
def _maybe_diff_file_or_symlink(old_path, old_tree, file_id,
386
new_path, new_tree, text_modified,
362
387
kind, to_file, diff_file):
363
388
if text_modified:
364
389
new_entry = new_tree.inventory[file_id]
365
390
old_tree.inventory[file_id].diff(diff_file,
366
old_label + old_path, old_tree,
367
new_label + new_path, new_entry,
368
393
new_tree, to_file)