277
277
current_hunk = [0, 0, 0, []] #start, finish, repl_length, repl_tuples
278
278
inclusions = set(self.get_ancestry(version_id))
279
279
parent_linenum = 0
282
last_parent_line = ''
280
283
for lineno, inserted, deletes, line in self._walk_internal(inclusions):
281
284
parent_active = inserted in parent_inclusions and not (deletes & parent_inclusions)
282
285
version_active = inserted in inclusions and not (deletes & inclusions)
289
292
diff_hunks.append(tuple(current_hunk))
290
293
parent_linenum += 1
291
294
current_hunk = [parent_linenum, parent_linenum, 0, []]
295
if len(line) and line[-1] != '\n':
292
297
elif parent_active and not version_active:
294
299
current_hunk[1] += 1
295
300
parent_linenum += 1
301
last_parent_line = line
296
302
elif not parent_active and version_active:
297
303
# replacement line
299
current_hunk[3].append((inserted, line))
304
# noeol only occurs at the end of a file because we
305
# diff linewise. We want to show noeol changes as a
306
# empty diff unless the actual eol-less content changed.
307
if len(last_parent_line) and last_parent_line[-1] != '\n':
309
if len(line) and line[-1] != '\n':
312
if parent_noeol == noeol:
313
# no noeol toggle, so trust the weave
317
if last_parent_line != line[:-1]:
321
# append a eol so that it looks like
325
if last_parent_line != line:
330
current_hunk[3].append((inserted, line))
332
# last hunk last parent line is not eaten
300
334
# flush last hunk
301
335
if current_hunk != [0, 0, 0, []]:
302
336
diff_hunks.append(tuple(current_hunk))
303
return parent, sha1, diff_hunks
337
return parent, sha1, noeol, diff_hunks
305
339
def get_parents(self, version_id):
306
340
"""See VersionedFile.get_parent."""