Fix some diff comment display errors

Change-Id: I0106e302feb6d3c02faa3fa7b6faf7907e833d5f
This commit is contained in:
James E. Blair 2014-04-29 20:22:14 -07:00
parent 5585ba6786
commit d924789cf9
3 changed files with 19 additions and 7 deletions

View File

@ -43,15 +43,18 @@ palette=[('reversed', 'default,standout', ''),
('reversed-added-word', 'light green,standout', ''),
('reversed-nonexistent', 'default,standout', ''),
('draft-comment', 'default', 'dark gray'),
('comment', 'white', 'dark gray'),
('comment', 'light gray', 'dark gray'),
('comment-name', 'white', 'dark gray'),
# Change view
('change-data', 'light cyan', ''),
('change-header', 'light blue', ''),
('revision-name', 'light blue', ''),
('revision-commit', 'dark blue', ''),
('revision-comments', 'default', ''),
('revision-drafts', 'dark red', ''),
('reversed-revision-name', 'light blue,standout', ''),
('reversed-revision-commit', 'dark blue,standout', ''),
('reversed-revision-comments', 'default,standout', ''),
('reversed-revision-drafts', 'dark red,standout', ''),
('change-message-name', 'light blue', ''),
('change-message-header', 'dark blue', ''),

View File

@ -150,6 +150,7 @@ class RevisionRow(urwid.WidgetWrap):
revision_focus_map = {
'revision-name': 'reversed-revision-name',
'revision-commit': 'reversed-revision-commit',
'revision-comments': 'reversed-revision-comments',
'revision-drafts': 'reversed-revision-drafts',
}
@ -164,6 +165,8 @@ class RevisionRow(urwid.WidgetWrap):
('revision-commit', revision.commit)]
if len(revision.pending_comments):
line.append(('revision-drafts', ' (%s drafts)' % len(revision.pending_comments)))
if len(revision.comments):
line.append(('revision-comments', ' (%s inline comments)' % len(revision.comments)))
self.title = mywid.TextButton(line, on_press = self.expandContract)
stats = repo.diffstat(revision.parent, revision.commit)
rows = []

View File

@ -59,12 +59,16 @@ class DiffComment(urwid.Columns):
def __init__(self, context, old, new):
super(DiffComment, self).__init__([])
self.context = context
self.old = urwid.AttrMap(urwid.Text(old), 'comment')
self.new = urwid.AttrMap(urwid.Text(new), 'comment')
oldt = urwid.Text(old)
newt = urwid.Text(new)
if old:
oldt = urwid.AttrMap(oldt, 'comment')
if new:
newt = urwid.AttrMap(newt, 'comment')
self.contents.append((urwid.Text(u''), ('given', 4, False)))
self.contents.append((self.old, ('weight', 1, False)))
self.contents.append((oldt, ('weight', 1, False)))
self.contents.append((urwid.Text(u''), ('given', 4, False)))
self.contents.append((self.new, ('weight', 1, False)))
self.contents.append((newt, ('weight', 1, False)))
class DiffLine(urwid.Button):
def selectable(self):
@ -129,7 +133,9 @@ class DiffView(urwid.WidgetWrap):
key += '-' + str(comment.line)
key += '-' + str(comment.file)
comment_list = comment_lists.get(key, [])
comment_list.append((comment.key, comment.message))
message = [('comment-name', comment.name),
('comment', u': '+comment.message)]
comment_list.append((comment.key, message))
comment_lists[key] = comment_list
repo = self.app.getRepo(self.project_name)
self._w.contents.append((app.header, ('pack', 1)))
@ -154,7 +160,7 @@ class DiffView(urwid.WidgetWrap):
# see if there are any comments for this line
key = 'old-%s-%s' % (old[0], diff.oldname)
old_list = comment_lists.get(key, [])
key = 'new-%s-%s' % (old[0], diff.oldname)
key = 'new-%s-%s' % (new[0], diff.newname)
new_list = comment_lists.get(key, [])
while old_list or new_list:
old_comment_key = new_comment_key = None