Mercurial > kallithea
changeset 4330:773980a93cdd
changesets: simplify calculation of PR comments on changesets
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 10 Dec 2013 19:30:37 +0100 |
parents | f54dca244402 |
children | 2655b2d46055 |
files | kallithea/controllers/changeset.py |
diffstat | 1 files changed, 13 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/changeset.py Tue Dec 10 19:30:37 2013 +0100 +++ b/kallithea/controllers/changeset.py Tue Dec 10 19:30:37 2013 +0100 @@ -219,7 +219,7 @@ c.lines_deleted = 0 # count of lines removes c.changeset_statuses = ChangesetStatus.STATUSES - c.comments = [] + comments = dict() c.statuses = [] c.inline_comments = [] c.inline_cnt = 0 @@ -231,22 +231,18 @@ c.statuses.extend([ChangesetStatusModel().get_status( c.db_repo.repo_id, changeset.raw_id)]) - c.comments.extend(ChangesetCommentsModel()\ - .get_comments(c.db_repo.repo_id, - revision=changeset.raw_id)) + # Changeset comments + comments.update((com.comment_id, com) + for com in ChangesetCommentsModel() + .get_comments(c.db_repo.repo_id, + revision=changeset.raw_id)) - #comments from PR - st = ChangesetStatusModel().get_statuses( - c.db_repo.repo_id, changeset.raw_id, - with_revisions=True) - # from associated statuses, check the pull requests, and - # show comments from them + # Status change comments - mostly from pull requests + comments.update((st.changeset_comment_id, st.comment) + for st in ChangesetStatusModel() + .get_statuses(c.db_repo.repo_id, + changeset.raw_id, with_revisions=True)) - prs = set([x.pull_request for x in - filter(lambda x: x.pull_request is not None, st)]) - - for pr in prs: - c.comments.extend(pr.comments) inlines = ChangesetCommentsModel()\ .get_inline_comments(c.db_repo.repo_id, revision=changeset.raw_id) @@ -287,8 +283,8 @@ cs_changes[''] = [None, None, None, None, diff, None] c.changes[changeset.raw_id] = cs_changes - #sort comments by how they were generated - c.comments = sorted(c.comments, key=lambda x: x.comment_id) + #sort comments in creation order + c.comments = [com for com_id, com in sorted(comments.items())] # count inline comments for __, lines in c.inline_comments: