221
221
specific_files, extra_trees=extra_trees,
222
222
want_unversioned=want_unversioned):
223
223
if versioned == (False, False):
224
delta.unversioned.append((path, None, kind[1]))
224
delta.unversioned.append((path[1], None, kind[1]))
226
226
if not include_root and (None, None) == parent_id:
230
230
if fully_present[0] != fully_present[1]:
231
231
if fully_present[1] is True:
232
delta.added.append((path, file_id, kind[1]))
232
delta.added.append((path[1], file_id, kind[1]))
234
234
assert fully_present[0] is True
235
old_path = old_tree.id2path(file_id)
236
delta.removed.append((old_path, file_id, kind[0]))
235
delta.removed.append((path[0], file_id, kind[0]))
237
236
elif fully_present[0] is False:
239
238
elif name[0] != name[1] or parent_id[0] != parent_id[1]:
240
239
# If the name changes, or the parent_id changes, we have a rename
241
240
# (if we move a parent, that doesn't count as a rename for the
243
old_path = old_tree.id2path(file_id)
244
delta.renamed.append((old_path,
242
delta.renamed.append((path[0],
249
247
(executable[0] != executable[1])))
250
248
elif kind[0] != kind[1]:
251
delta.kind_changed.append((path, file_id, kind[0], kind[1]))
249
delta.kind_changed.append((path[1], file_id, kind[0], kind[1]))
252
250
elif content_change is True or executable[0] != executable[1]:
253
delta.modified.append((path, file_id, kind[1],
251
delta.modified.append((path[1], file_id, kind[1],
255
253
(executable[0] != executable[1])))
257
delta.unchanged.append((path, file_id, kind[1]))
255
delta.unchanged.append((path[1], file_id, kind[1]))
259
257
delta.removed.sort()
260
258
delta.added.sort()
270
268
class ChangeReporter(object):
271
269
"""Report changes between two trees"""
273
def __init__(self, old_inventory, output=None, suppress_root_add=True,
271
def __init__(self, output=None, suppress_root_add=True,
274
272
output_file=None):
277
:param old_inventory: The inventory of the old tree
278
275
:param output: a function with the signature of trace.note, i.e.
279
276
accepts a format and parameters.
280
277
:param supress_root_add: If true, adding the root will be ignored
282
279
:param output_file: If supplied, a file-like object to write to.
283
280
Only one of output and output_file may be supplied.
285
self.old_inventory = old_inventory
286
282
if output_file is not None:
287
283
if output is not None:
288
284
raise BzrError('Cannot specify both output and output_file')
293
289
from bzrlib import trace
294
290
self.output = trace.note
295
291
self.suppress_root_add = suppress_root_add
292
self.modified_map = {'kind changed': 'K',
297
self.versioned_map = {'added': '+',
297
def report(self, file_id, path, versioned, renamed, modified, exe_change,
301
def report(self, file_id, paths, versioned, renamed, modified, exe_change,
299
303
"""Report one change to a file
301
305
:param file_id: The file_id of the file
302
:param path: The path the file has (or would have) in the tree (as
303
generated by Tree._iter_changes)
306
:param path: The old and new paths as generated by Tree._iter_changes.
304
307
:param versioned: may be 'added', 'removed', or 'unchanged'
305
308
:param renamed: may be True or False
306
309
:param modified: may be 'created', 'deleted', 'kind changed',
309
312
:param kind: A pair of file kinds, as generated by Tree._iter_changes.
310
313
None indicates no file present.
312
if path == '' and versioned == 'added' and self.suppress_root_add:
315
if paths[1] == '' and versioned == 'added' and self.suppress_root_add:
314
modified_map = {'kind changed': 'K',
319
versioned_map = {'added': '+',
317
# we show both paths in the following situations:
318
# the file versioning is unchanged AND
319
# ( the path is different OR
320
# the kind is different)
321
if (versioned == 'unchanged' and
322
(renamed or modified == 'kind changed')):
324
# on a rename, we show old and new
325
old_path, path = paths
327
# if its not renamed, we're showing both for kind changes
328
# so only show the new path
329
old_path, path = paths[1], paths[1]
330
# if the file is not missing in the source, we show its kind
331
# when we show two paths.
332
if kind[0] is not None:
333
old_path += osutils.kind_marker(kind[0])
324
old_path = self.old_inventory.id2path(file_id)
327
rename = versioned_map[versioned]
328
if modified == 'kind changed':
341
rename = self.versioned_map[versioned]
342
# we show the old kind on the new path when the content is deleted.
331
343
if modified == 'deleted':
332
344
path += osutils.kind_marker(kind[0])
345
# otherwise we always show the current kind when there is one
333
346
elif kind[1] is not None:
334
347
path += osutils.kind_marker(kind[1])
336
if kind[0] is not None:
337
old_path += osutils.kind_marker(kind[0])
343
self.output("%s%s%s %s%s", rename, modified_map[modified], exe,
352
self.output("%s%s%s %s%s", rename, self.modified_map[modified], exe,