##// END OF EJS Templates
diff parser: show multiple messages ... and fix stats for non-git chunks
Mads Kiilerich -
r3819:46d58112 beta
parent child Browse files
Show More
@@ -358,39 +358,43 b' class DiffProcessor(object):'
358
358
359 op = None
359 op = None
360 stats = None
360 stats = None
361 msg = None
361 msgs = []
362
362
363 if not head['a_file'] and head['b_file']:
363 if not head['a_file'] and head['b_file']:
364 op = 'A'
364 op = 'A'
365 stats = ['b', NEW_FILENODE]
366 msgs.append('new file')
365 elif head['a_file'] and head['b_file']:
367 elif head['a_file'] and head['b_file']:
366 op = 'M'
368 op = 'M'
369 stats = ['b', MOD_FILENODE]
367 elif head['a_file'] and not head['b_file']:
370 elif head['a_file'] and not head['b_file']:
368 op = 'D'
371 op = 'D'
372 stats = ['b', DEL_FILENODE]
373 msgs.append('deleted file')
369 else:
374 else:
370 if head['deleted_file_mode']:
375 if head['deleted_file_mode']:
371 op = 'D'
376 op = 'D'
372 stats = ['b', DEL_FILENODE]
377 stats = ['b', DEL_FILENODE]
373 msg = 'deleted file'
378 msgs.append('deleted file')
374 elif head['new_file_mode']:
379 elif head['new_file_mode']:
375 op = 'A'
380 op = 'A'
376 stats = ['b', NEW_FILENODE]
381 stats = ['b', NEW_FILENODE]
377 msg = 'new file %s' % head['new_file_mode']
382 msgs.append('new file %s' % head['new_file_mode'])
378 else:
383 else:
379 if head['new_mode'] and head['old_mode']:
384 if head['new_mode'] and head['old_mode']:
385 op = 'M'
380 stats = ['b', CHMOD_FILENODE]
386 stats = ['b', CHMOD_FILENODE]
381 op = 'M'
387 msgs.append('modified file chmod %s => %s'
382 msg = ('modified file chmod %s => %s'
383 % (head['old_mode'], head['new_mode']))
388 % (head['old_mode'], head['new_mode']))
384 elif (head['rename_from'] and head['rename_to']
389 if (head['rename_from'] and head['rename_to']
385 and head['rename_from'] != head['rename_to']):
390 and head['rename_from'] != head['rename_to']):
386 stats = ['b', RENAMED_FILENODE]
387 op = 'M'
391 op = 'M'
388 msg = ('file renamed from %s to %s'
392 stats = ['b', RENAMED_FILENODE] # might overwrite CHMOD_FILENODE
393 msgs.append('file renamed from %s to %s'
389 % (head['rename_from'], head['rename_to']))
394 % (head['rename_from'], head['rename_to']))
390 else:
395 if op is None:
396 op = 'M'
391 stats = ['b', MOD_FILENODE]
397 stats = ['b', MOD_FILENODE]
392 op = 'M'
393 msg = 'modified file'
394
398
395 if head['a_file'] or head['b_file']: # a real diff
399 if head['a_file'] or head['b_file']: # a real diff
396 try:
400 try:
@@ -403,16 +407,15 b' class DiffProcessor(object):'
403 break
407 break
404 else: # GIT binary patch (or empty diff)
408 else: # GIT binary patch (or empty diff)
405 chunks = []
409 chunks = []
406 if not msg: # don't overwrite more important message
410 msgs.append('binary diff not shown') # or no diff because it was a rename or chmod or add/remove of empty file
407 msg = 'binary diff not shown'
408
411
409 if msg:
412 if msgs:
410 chunks.insert(0, [{
413 chunks.insert(0, [{
411 'old_lineno': '',
414 'old_lineno': '',
412 'new_lineno': '',
415 'new_lineno': '',
413 'action': 'binary',
416 'action': 'binary',
414 'line': msg,
417 'line': msg,
415 }])
418 } for msg in msgs])
416
419
417 _files.append({
420 _files.append({
418 'filename': head['b_path'],
421 'filename': head['b_path'],
General Comments 0
You need to be logged in to leave comments. Login now