@@ -253,6 +253,7 @@ def show_bug_info(bug, settings):
253253 'priority' : 'Priority' ,
254254 'severity' : 'Severity' ,
255255 'target_milestone' : 'TargetMilestone' ,
256+ 'assigned_to' : 'AssignedTo' ,
256257 'assigned_to_detail' : 'AssignedTo' ,
257258 'url' : 'URL' ,
258259 'whiteboard' : 'Whiteboard' ,
@@ -315,30 +316,70 @@ def show_bug_info(bug, settings):
315316 params = {'ids' : [bug ['id' ]]}
316317 bug_comments = settings .call_bz (settings .bz .Bug .comments , params )
317318 bug_comments = bug_comments ['bugs' ]['%s' % bug ['id' ]]['comments' ]
319+ for comment in bug_comments :
320+ comment ['when' ] = parsetime (comment ['time' ])
321+ del comment ['time' ]
322+ comment ['who' ] = comment ['creator' ]
323+ del comment ['creator' ]
324+ bug_history = settings .call_bz (settings .bz .Bug .history , params )
325+ assert (bug_history ['bugs' ][0 ]['id' ] == bug ['id' ])
326+ bug_history = bug_history ['bugs' ][0 ]['history' ]
327+ for change in bug_history :
328+ change ['when' ] = parsetime (change ['when' ])
329+ bug_comments += bug_history
330+ bug_comments .sort (key = lambda c : (c ['when' ], 'changes' in c ))
318331 print ()
319332 i = 0
320333 wrapper = textwrap .TextWrapper (width = settings .columns ,
321334 break_long_words = False ,
322335 break_on_hyphens = False )
323336 for comment in bug_comments :
324- if comment ['creator' ] in user_detail :
325- who = '%s <%s>' % (
326- user_detail [comment ['creator' ]]['real_name' ],
327- comment ['creator' ])
328- else :
329- who = comment ['creator' ]
330- when = parsetime (comment ['time' ])
331- header_left = '%s %s' % (who , printtime (when , settings ))
332- if i == 0 :
333- header_right = 'Description'
334- else :
335- header_right = '[Comment %d]' % i
336- space = settings .columns - len (header_left ) - len (header_right ) - 3
337- if space < 0 :
338- space = 0
339- print (header_left , ' ' * space , header_right )
340- print ('-' * (settings .columns - 1 ))
337+ # Header, who & when
338+ if comment == bug_comments [0 ] or \
339+ prev ['when' ] != comment ['when' ] or \
340+ prev ['who' ] != comment ['who' ]:
341+ if comment ['who' ] in user_detail :
342+ who = '%s <%s>' % (
343+ user_detail [comment ['who' ]]['real_name' ],
344+ comment ['who' ])
345+ else :
346+ who = comment ['who' ]
347+ when = comment ['when' ]
348+ header_left = '%s %s' % (who , printtime (when , settings ))
349+ if i == 0 :
350+ header_right = 'Description'
351+ elif 'changes' in comment :
352+ header_right = ''
353+ else :
354+ header_right = '[Comment %d]' % i
355+ space = settings .columns - len (header_left ) - \
356+ len (header_right ) - 3
357+ if space < 0 :
358+ space = 0
359+ print (header_left , ' ' * space , header_right )
360+ print ('-' * (settings .columns - 1 ))
361+
362+ # A change from Bug.history
363+ if 'changes' in comment :
364+ for change in comment ['changes' ]:
365+ if change ['field_name' ] in FieldMap :
366+ desc = FieldMap [change ['field_name' ]]
367+ else :
368+ desc = change ['field_name' ]
369+ if change ['removed' ] and change ['added' ]:
370+ print ('%s: %s → %s' % (desc , change ['removed' ],
371+ change ['added' ]))
372+ elif change ['added' ]:
373+ print ('%s: %s' % (desc , change ['added' ]))
374+ elif change ['removed' ]:
375+ print ('REMOVED %s: %s ' % (desc , change ['removed' ]))
376+ else :
377+ print (change )
378+ prev = comment
379+ print ()
380+ continue
341381
382+ # A comment from Bug.comments
342383 what = comment ['text' ]
343384 if what is None :
344385 what = ''
@@ -351,6 +392,7 @@ def show_bug_info(bug, settings):
351392 for shortline in wrapper .wrap (line ):
352393 print (shortline )
353394 print ()
395+ prev = comment
354396 i += 1
355397
356398
0 commit comments