25
25
format_highres_date, unpack_highres_date)
26
26
from bzrlib.changeset.common import testament_sha1
27
from bzrlib.changeset.serializer import binary_diff
27
28
from bzrlib.delta import compare_trees
28
29
from bzrlib.diff import internal_diff
29
30
import bzrlib.errors as errors
31
32
from bzrlib.revision import NULL_REVISION
32
33
from bzrlib.rio import RioWriter, read_stanzas
35
from bzrlib.textfile import text_file
35
37
bool_text = {True: 'yes', False: 'no'}
170
172
def do_diff(old_path, file_id, new_path, kind):
171
new_entry = new_tree.inventory[file_id]
172
old_tree.inventory[file_id].diff(internal_diff,
173
pathjoin(old_label, old_path), old_tree,
174
pathjoin(new_label, new_path), new_entry, new_tree,
173
def tree_lines(tree, require_text=False):
175
tree_file = tree.get_file(file_id)
176
if require_text is True:
177
tree_file = text_file(tree_file)
178
return tree_file.readlines()
183
old_lines = tree_lines(old_tree, require_text=True)
184
new_lines = tree_lines(new_tree, require_text=True)
185
self.to_file.write('\n')
186
internal_diff(old_path, old_lines, new_path, new_lines,
188
except errors.BinaryFile:
189
old_lines = tree_lines(old_tree, require_text=False)
190
new_lines = tree_lines(new_tree, require_text=False)
191
self.to_file.write(' // encoding:base64\n')
192
binary_diff(old_path, old_lines, new_path, new_lines,
176
195
def do_meta(file_id):
177
196
ie = new_tree.inventory[file_id]
178
197
w(' // executable:%s' % bool_text[ie.executable])
201
220
if kind == 'symlink':
202
221
do_target(new_tree.inventory[file_id].symlink_target)
204
222
if kind == 'file':
205
new_tree.inventory[file_id].diff(internal_diff,
206
pathjoin(new_label, path), new_tree,
208
self.to_file, reverse=True)
223
do_diff(DEVNULL, file_id, path, kind)
210
228
for (old_path, new_path, file_id, kind,
211
229
text_modified, meta_modified) in delta.renamed:
216
234
if text_modified and kind == "symlink":
217
235
do_target(new_tree.inventory[file_id].symlink_target)
219
236
if text_modified and kind == "file":
220
237
do_diff(old_path, file_id, new_path, text_modified)
222
241
for (path, file_id, kind,
223
242
text_modified, meta_modified) in delta.modified:
230
249
if text_modified and kind == "symlink":
231
250
do_target(new_tree.inventory[file_id].symlink_target)
233
251
if text_modified and kind == "file":
234
252
do_diff(path, file_id, path, kind)