##// END OF EJS Templates
diffs: don't add a pointless empty first chunk
Mads Kiilerich -
r8649:bf39a5c8 default
parent child Browse files
Show More
@@ -381,13 +381,19 b' class DiffProcessor(object):'
381 # not with the current UI
381 # not with the current UI
382 chunks = []
382 chunks = []
383
383
384 chunks.insert(0, [{
384 # show helpful additional texts for mode change and renaming, but not for plain 'modified file'
385 'old_lineno': '',
385 msgs = [
386 'new_lineno': '',
386 {
387 'action': 'context',
387 'old_lineno': '',
388 'line': msg,
388 'new_lineno': '',
389 } for _op, msg in stats['ops'].items()
389 'action': 'context',
390 if _op not in [MOD_FILENODE]])
390 'line': msg,
391 }
392 for op_, msg in stats['ops'].items()
393 if op_ != MOD_FILENODE
394 ]
395 if msgs:
396 chunks.insert(0, msgs)
391
397
392 _files.append({
398 _files.append({
393 'old_filename': head['a_path'],
399 'old_filename': head['a_path'],
@@ -344,10 +344,10 b' class TestDiffLib(base.TestController):'
344 raw_diff = fixture.load_resource('markuptest.diff', strip=False)
344 raw_diff = fixture.load_resource('markuptest.diff', strip=False)
345 diff_processor = DiffProcessor(raw_diff)
345 diff_processor = DiffProcessor(raw_diff)
346 chunks = diff_processor.parsed[0]['chunks']
346 chunks = diff_processor.parsed[0]['chunks']
347 assert not chunks[0]
347 assert len(chunks) == 1, chunks
348 #from pprint import pprint; pprint(chunks[1])
348 #from pprint import pprint; pprint(chunks[1])
349 l = ['\n']
349 l = ['\n']
350 for d in chunks[1]:
350 for d in chunks[0]:
351 l.append('%(action)-7s %(new_lineno)3s %(old_lineno)3s %(line)r\n' % d)
351 l.append('%(action)-7s %(new_lineno)3s %(old_lineno)3s %(line)r\n' % d)
352 s = ''.join(l)
352 s = ''.join(l)
353 assert s == r'''
353 assert s == r'''
General Comments 0
You need to be logged in to leave comments. Login now