aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2013-01-19 20:57:19 +0100
committerMarcin Kuzminski <marcin@python-works.com>2013-01-19 20:57:19 +0100
commite7207c6f77f8db035bfad394b5e983f23ce4b467 (patch)
tree6a35e6e4a7fbfabfdd9aceddf26a784d460d1e36
parent64548fb6e54a9fcdf853cc462a1f8deba29bf24f (diff)
show comments from pull requests into associated changesets
--HG-- branch : beta
-rw-r--r--rhodecode/controllers/changeset.py23
-rw-r--r--rhodecode/controllers/pullrequests.py1
-rw-r--r--rhodecode/model/changeset_status.py14
-rw-r--r--rhodecode/templates/changeset/changeset_file_comment.html5
4 files changed, 31 insertions, 12 deletions
diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py
index 32076a00..f982f04f 100644
--- a/rhodecode/controllers/changeset.py
+++ b/rhodecode/controllers/changeset.py
@@ -221,13 +221,25 @@ class ChangesetController(BaseRepoController):
for changeset in c.cs_ranges:
inlines = []
if method == 'show':
- c.statuses.extend([ChangesetStatusModel()\
- .get_status(c.rhodecode_db_repo.repo_id,
- changeset.raw_id)])
+ c.statuses.extend([ChangesetStatusModel().get_status(
+ c.rhodecode_db_repo.repo_id, changeset.raw_id)])
c.comments.extend(ChangesetCommentsModel()\
.get_comments(c.rhodecode_db_repo.repo_id,
revision=changeset.raw_id))
+
+ #comments from PR
+ st = ChangesetStatusModel().get_statuses(
+ c.rhodecode_db_repo.repo_id, changeset.raw_id,
+ with_revisions=True)
+ # from associated statuses, check the pull requests, and
+ # show comments from them
+
+ prs = set([x.pull_request for x in
+ filter(lambda x: x.pull_request != None, st)])
+
+ for pr in prs:
+ c.comments.extend(pr.comments)
inlines = ChangesetCommentsModel()\
.get_inline_comments(c.rhodecode_db_repo.repo_id,
revision=changeset.raw_id)
@@ -269,6 +281,9 @@ class ChangesetController(BaseRepoController):
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)
+
# count inline comments
for __, lines in c.inline_comments:
for comments in lines.values():
@@ -342,7 +357,7 @@ class ChangesetController(BaseRepoController):
)
except StatusChangeOnClosedPullRequestError:
log.error(traceback.format_exc())
- msg = _('Changing status on a changeset associated with'
+ msg = _('Changing status on a changeset associated with '
'a closed pull request is not allowed')
h.flash(msg, category='warning')
return redirect(h.url('changeset_home', repo_name=repo_name,
diff --git a/rhodecode/controllers/pullrequests.py b/rhodecode/controllers/pullrequests.py
index 368d06a6..fa08b632 100644
--- a/rhodecode/controllers/pullrequests.py
+++ b/rhodecode/controllers/pullrequests.py
@@ -224,7 +224,6 @@ class PullrequestsController(BaseRepoController):
h.flash(_('Successfully opened new pull request'),
category='success')
except Exception:
- raise
h.flash(_('Error occurred during sending pull request'),
category='error')
log.error(traceback.format_exc())
diff --git a/rhodecode/model/changeset_status.py b/rhodecode/model/changeset_status.py
index 3e8d0efd..a7e0efcf 100644
--- a/rhodecode/model/changeset_status.py
+++ b/rhodecode/model/changeset_status.py
@@ -89,27 +89,27 @@ class ChangesetStatusModel(BaseModel):
with_revisions)
return q.all()
- def get_status(self, repo, revision=None, pull_request=None):
+ def get_status(self, repo, revision=None, pull_request=None, as_str=True):
"""
Returns latest status of changeset for given revision or for given
pull request. Statuses are versioned inside a table itself and
version == 0 is always the current one
:param repo:
- :type repo:
:param revision: 40char hash or None
- :type revision: str
:param pull_request: pull_request reference
- :type:
+ :param as_str: return status as string not object
"""
q = self._get_status_query(repo, revision, pull_request)
# need to use first here since there can be multiple statuses
# returned from pull_request
status = q.first()
- status = status.status if status else status
- st = status or ChangesetStatus.DEFAULT
- return str(st)
+ if as_str:
+ status = status.status if status else status
+ st = status or ChangesetStatus.DEFAULT
+ return str(st)
+ return status
def set_status(self, repo, status, user, comment=None, revision=None,
pull_request=None, dont_allow_on_closed_pull_request=False):
diff --git a/rhodecode/templates/changeset/changeset_file_comment.html b/rhodecode/templates/changeset/changeset_file_comment.html
index c9aa552f..edbce729 100644
--- a/rhodecode/templates/changeset/changeset_file_comment.html
+++ b/rhodecode/templates/changeset/changeset_file_comment.html
@@ -19,6 +19,11 @@
<div style="float:left;padding:0px 2px 0px 2px"><span style="font-size: 18px;">&rsaquo;</span></div>
<div title="${_('Changeset status')}" class="changeset-status-lbl"> ${co.status_change[0].status_lbl}</div>
<div class="changeset-status-ico"><img src="${h.url(str('/images/icons/flag_status_%s.png' % co.status_change[0].status))}" /></div>
+ <div style="float:left;padding:3px 0px 0px 5px"> <span class="">
+ %if co.pull_request:
+ <a href="${h.url('pullrequest_show',repo_name=co.pull_request.other_repo.repo_name,pull_request_id=co.pull_request.pull_request_id)}">${_('Status from pull request %s') % co.pull_request.pull_request_id}</a>
+ %endif
+ </span> </div>
</div>
%endif
%if h.HasPermissionAny('hg.admin', 'repository.admin')() or co.author.user_id == c.rhodecode_user.user_id: