21
21
from bzrlib.inventory import InventoryEntry
22
from bzrlib.trace import mutter
23
from bzrlib.symbol_versioning import deprecated_function, zero_nine
22
from bzrlib.trace import mutter, is_quiet
23
from bzrlib.symbol_versioning import deprecated_function
26
26
class TreeDelta(object):
125
print >>to_file, indent + '%s %-30s %s' % (short_status_letter,
125
to_file.write(indent + '%s %-30s %s\n' % (short_status_letter,
128
print >>to_file, indent + '%s %s' % (short_status_letter, path)
128
to_file.write(indent + '%s %s\n' % (short_status_letter, path))
131
131
if not short_status:
132
print >>to_file, indent + 'removed:'
132
to_file.write(indent + 'removed:\n')
133
133
show_list(self.removed)
135
135
show_list(self.removed, 'D')
138
138
if not short_status:
139
print >>to_file, indent + 'added:'
139
to_file.write(indent + 'added:\n')
140
140
show_list(self.added)
142
142
show_list(self.added, 'A')
147
147
short_status_letter = 'R'
148
148
if not short_status:
149
print >>to_file, indent + 'renamed:'
149
to_file.write(indent + 'renamed:\n')
150
150
short_status_letter = ''
151
151
for (oldpath, newpath, fid, kind,
152
152
text_modified, meta_modified) in self.renamed:
156
156
if meta_modified:
159
print >>to_file, indent + '%s %s => %s %s' % (
160
short_status_letter, oldpath, newpath, fid)
159
to_file.write(indent + '%s %s => %s %s\n' % (
160
short_status_letter, oldpath, newpath, fid))
162
print >>to_file, indent + '%s %s => %s' % (
163
short_status_letter, oldpath, newpath)
162
to_file.write(indent + '%s %s => %s\n' % (
163
short_status_letter, oldpath, newpath))
165
165
if self.kind_changed:
167
167
short_status_letter = 'K'
169
print >>to_file, indent + 'kind changed:'
169
to_file.write(indent + 'kind changed:\n')
170
170
short_status_letter = ''
171
171
for (path, fid, old_kind, new_kind) in self.kind_changed:
176
print >>to_file, indent + '%s %s (%s => %s)%s' % (
177
short_status_letter, path, old_kind, new_kind, suffix)
176
to_file.write(indent + '%s %s (%s => %s)%s\n' % (
177
short_status_letter, path, old_kind, new_kind, suffix))
179
179
if self.modified or extra_modified:
180
180
short_status_letter = 'M'
181
181
if not short_status:
182
print >>to_file, indent + 'modified:'
182
to_file.write(indent + 'modified:\n')
183
183
short_status_letter = ''
184
184
show_list(self.modified, short_status_letter)
185
185
show_list(extra_modified, short_status_letter)
187
187
if show_unchanged and self.unchanged:
188
188
if not short_status:
189
print >>to_file, indent + 'unchanged:'
189
to_file.write(indent + 'unchanged:\n')
190
190
show_list(self.unchanged)
192
192
show_list(self.unchanged, 'S')
194
194
if self.unversioned:
195
print >>to_file, indent + 'unknown:'
195
to_file.write(indent + 'unknown:\n')
196
196
show_list(self.unversioned)
198
198
def get_changes_as_text(self, show_ids=False, show_unchanged=False,
202
202
self.show(output, show_ids, show_unchanged, short_status)
203
203
return output.getvalue()
205
@deprecated_function(zero_nine)
206
def compare_trees(old_tree, new_tree, want_unchanged=False,
207
specific_files=None, extra_trees=None,
208
require_versioned=False):
209
"""compare_trees was deprecated in 0.10. Please see Tree.changes_from."""
210
return new_tree.changes_from(old_tree,
211
want_unchanged=want_unchanged,
212
specific_files=specific_files,
213
extra_trees=extra_trees,
214
require_versioned=require_versioned,
218
206
def _compare_trees(old_tree, new_tree, want_unchanged, specific_files,
219
207
include_root, extra_trees=None,
220
want_unversioned=False):
208
require_versioned=False, want_unversioned=False):
221
209
"""Worker function that implements Tree.changes_from."""
222
210
delta = TreeDelta()
223
211
# mutter('start compare_trees')
225
213
for (file_id, path, content_change, versioned, parent_id, name, kind,
226
executable) in new_tree._iter_changes(old_tree, want_unchanged,
214
executable) in new_tree.iter_changes(old_tree, want_unchanged,
227
215
specific_files, extra_trees=extra_trees,
216
require_versioned=require_versioned,
228
217
want_unversioned=want_unversioned):
229
218
if versioned == (False, False):
230
219
delta.unversioned.append((path[1], None, kind[1]))
237
226
if fully_present[1] is True:
238
227
delta.added.append((path[1], file_id, kind[1]))
240
assert fully_present[0] is True
241
229
delta.removed.append((path[0], file_id, kind[0]))
242
230
elif fully_present[0] is False:
315
303
"""Report one change to a file
317
305
:param file_id: The file_id of the file
318
:param path: The old and new paths as generated by Tree._iter_changes.
306
:param path: The old and new paths as generated by Tree.iter_changes.
319
307
:param versioned: may be 'added', 'removed', 'unchanged', or
321
309
:param renamed: may be True or False
322
310
:param modified: may be 'created', 'deleted', 'kind changed',
323
311
'modified' or 'unchanged'.
324
312
:param exe_change: True if the execute bit has changed
325
:param kind: A pair of file kinds, as generated by Tree._iter_changes.
313
:param kind: A pair of file kinds, as generated by Tree.iter_changes.
326
314
None indicates no file present.
328
318
if paths[1] == '' and versioned == 'added' and self.suppress_root_add:
330
320
if versioned == 'unversioned':
344
334
# on a rename, we show old and new
345
335
old_path, path = paths
347
# if its not renamed, we're showing both for kind changes
337
# if it's not renamed, we're showing both for kind changes
348
338
# so only show the new path
349
339
old_path, path = paths[1], paths[1]
350
340
# if the file is not missing in the source, we show its kind
384
374
Further processing may be required to produce a human-readable output.
385
375
Unfortunately, some tree-changing operations are very complex
386
376
:change_iterator: an iterator or sequence of changes in the format
387
generated by Tree._iter_changes
377
generated by Tree.iter_changes
388
378
:param reporter: The _ChangeReporter that will report the changes.
390
380
versioned_change_map = {