17
17
from bzrlib.delta import compare_trees
18
18
from bzrlib.errors import BzrError
19
import bzrlib.errors as errors
20
19
from bzrlib.symbol_versioning import *
21
20
from bzrlib.trace import mutter
251
251
def _show_diff_trees(old_tree, new_tree, to_file,
252
252
specific_files, external_diff_options):
254
# TODO: Options to control putting on a prefix or suffix, perhaps
255
# as a format string?
254
# TODO: Options to control putting on a prefix or suffix, perhaps as a format string
259
258
DEVNULL = '/dev/null'
260
259
# Windows users, don't panic about this filename -- it is a
264
263
# TODO: Generation of pseudo-diffs for added/deleted files could
265
264
# be usefully made into a much faster special case.
267
_raise_if_doubly_unversioned(specific_files, old_tree, new_tree)
269
266
if external_diff_options:
270
267
assert isinstance(external_diff_options, basestring)
271
268
opts = external_diff_options.split()
275
272
diff_file = internal_diff
277
275
delta = compare_trees(old_tree, new_tree, want_unchanged=False,
278
276
specific_files=specific_files)
281
279
for path, file_id, kind in delta.removed:
283
print >>to_file, '=== removed %s %r' % (kind, old_label + path)
281
print >>to_file, '=== removed %s %r' % (kind, path)
284
282
old_tree.inventory[file_id].diff(diff_file, old_label + path, old_tree,
285
283
DEVNULL, None, None, to_file)
286
284
for path, file_id, kind in delta.added:
288
print >>to_file, '=== added %s %r' % (kind, new_label + path)
286
print >>to_file, '=== added %s %r' % (kind, path)
289
287
new_tree.inventory[file_id].diff(diff_file, new_label + path, new_tree,
290
288
DEVNULL, None, None, to_file,
295
293
prop_str = get_prop_change(meta_modified)
296
294
print >>to_file, '=== renamed %s %r => %r%s' % (
297
kind, old_label + old_path, new_label + new_path, prop_str)
295
kind, old_path, new_path, prop_str)
298
296
_maybe_diff_file_or_symlink(old_label, old_path, old_tree, file_id,
299
297
new_label, new_path, new_tree,
300
298
text_modified, kind, to_file, diff_file)
301
299
for path, file_id, kind, text_modified, meta_modified in delta.modified:
303
301
prop_str = get_prop_change(meta_modified)
304
print >>to_file, '=== modified %s %r%s' % (kind, old_label + path,
302
print >>to_file, '=== modified %s %r%s' % (kind, path, prop_str)
306
303
if text_modified:
307
304
_maybe_diff_file_or_symlink(old_label, path, old_tree, file_id,
308
305
new_label, path, new_tree,
309
306
True, kind, to_file, diff_file)
311
307
return has_changes
314
def _raise_if_doubly_unversioned(specific_files, old_tree, new_tree):
315
"""Complain if paths are not versioned in either tree."""
316
if not specific_files:
318
old_unversioned = old_tree.filter_unversioned_files(specific_files)
319
new_unversioned = new_tree.filter_unversioned_files(specific_files)
320
unversioned = old_unversioned.intersection(new_unversioned)
322
raise errors.PathsNotVersionedError(sorted(unversioned))
325
310
def get_prop_change(meta_modified):