diff --git a/kallithea/config/routing.py b/kallithea/config/routing.py
--- a/kallithea/config/routing.py
+++ b/kallithea/config/routing.py
@@ -699,7 +699,7 @@ def make_map(config):
method=["POST"]))
rmap.connect('pullrequest_show',
- '/{repo_name:.*?}/pull-request/{pull_request_id}',
+ '/{repo_name:.*?}/pull-request/{pull_request_id:\\d+}{extra:(/.*)?}', extra='',
controller='pullrequests',
action='show', conditions=dict(function=check_repo,
method=["GET"]))
diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py
--- a/kallithea/controllers/pullrequests.py
+++ b/kallithea/controllers/pullrequests.py
@@ -460,8 +460,7 @@ class PullrequestsController(BaseRepoCon
log.error(traceback.format_exc())
return redirect(url('pullrequest_home', repo_name=repo_name))
- return redirect(url('pullrequest_show', repo_name=other_repo_name,
- pull_request_id=pull_request.pull_request_id))
+ return redirect(pull_request.url())
@LoginRequired()
@NotAnonymous()
@@ -639,7 +638,7 @@ class PullrequestsController(BaseRepoCon
@LoginRequired()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
- def show(self, repo_name, pull_request_id):
+ def show(self, repo_name, pull_request_id, extra=None):
repo_model = RepoModel()
c.users_array = repo_model.get_users_js()
c.user_groups_array = repo_model.get_user_groups_js()
diff --git a/kallithea/lib/utils2.py b/kallithea/lib/utils2.py
--- a/kallithea/lib/utils2.py
+++ b/kallithea/lib/utils2.py
@@ -756,3 +756,6 @@ class Optional(object):
if isinstance(val, cls):
return val.getval()
return val
+
+def urlreadable(s, _cleanstringsub=re.compile('[^-a-zA-Z0-9./]+').sub):
+ return _cleanstringsub('_', safe_str(s)).rstrip('_')
diff --git a/kallithea/model/comment.py b/kallithea/model/comment.py
--- a/kallithea/model/comment.py
+++ b/kallithea/model/comment.py
@@ -127,9 +127,7 @@ class ChangesetCommentsModel(BaseModel):
threading.append('%s-pr-%s-line-%s@%s' % (pull_request.other_repo.repo_name,
pull_request.pull_request_id, line_no,
h.canonical_hostname()))
- comment_url = h.canonical_url('pullrequest_show',
- repo_name=pull_request.other_repo.repo_name,
- pull_request_id=pull_request.pull_request_id,
+ comment_url = pull_request.url(canonical=True,
anchor='comment-%s' % comment.comment_id)
subj = safe_unicode(
h.link_to('Re pull request #%(pr_id)s: %(desc)s %(line)s' % \
diff --git a/kallithea/model/db.py b/kallithea/model/db.py
--- a/kallithea/model/db.py
+++ b/kallithea/model/db.py
@@ -51,7 +51,7 @@ from kallithea.lib.vcs.backends.base imp
from kallithea.lib.utils2 import str2bool, safe_str, get_changeset_safe, \
safe_unicode, remove_prefix, time_to_datetime, aslist, Optional, safe_int, \
- get_clone_url
+ get_clone_url, urlreadable
from kallithea.lib.compat import json
from kallithea.lib.caching_query import FromCache
@@ -2306,6 +2306,19 @@ class PullRequest(Base, BaseModel):
revisions=self.revisions
)
+ def url(self, **kwargs):
+ canonical = kwargs.pop('canonical', None)
+ import kallithea.lib.helpers as h
+ s = '/' + self.title
+ b = self.org_ref_parts[1]
+ if b not in s and b != self.other_ref_parts[1]:
+ s = '/_%s_%s' % (b, s)
+ kwargs['extra'] = urlreadable(s)
+ if canonical:
+ return h.canonical_url('pullrequest_show', repo_name=self.other_repo.repo_name,
+ pull_request_id=self.pull_request_id, **kwargs)
+ return h.url('pullrequest_show', repo_name=self.other_repo.repo_name,
+ pull_request_id=self.pull_request_id, **kwargs)
class PullRequestReviewers(Base, BaseModel):
__tablename__ = 'pull_request_reviewers'
diff --git a/kallithea/model/pull_request.py b/kallithea/model/pull_request.py
--- a/kallithea/model/pull_request.py
+++ b/kallithea/model/pull_request.py
@@ -124,8 +124,7 @@ class PullRequestModel(BaseModel):
for x in map(pr.org_repo.get_changeset, pr.revisions)]
#notification to reviewers
- pr_url = h.canonical_url('pullrequest_show', repo_name=pr.other_repo.repo_name,
- pull_request_id=pr.pull_request_id)
+ pr_url = pr.url(canonical=True)
threading = [h.canonical_url('pullrequest_show', repo_name=pr.other_repo.repo_name,
pull_request_id=pr.pull_request_id)]
subject = safe_unicode(
diff --git a/kallithea/templates/changeset/changeset_file_comment.html b/kallithea/templates/changeset/changeset_file_comment.html
--- a/kallithea/templates/changeset/changeset_file_comment.html
+++ b/kallithea/templates/changeset/changeset_file_comment.html
@@ -20,10 +20,10 @@
%if co.pull_request:
%if co.status_change:
${_('Status change from pull request')}
- "${co.pull_request.title or _("No title")}":
+ "${co.pull_request.title or _("No title")}":
%else:
${_('Comment from pull request')}
- "${co.pull_request.title or _("No title")}"
+ "${co.pull_request.title or _("No title")}"
%endif
%else:
%if co.status_change:
diff --git a/kallithea/templates/pullrequests/pullrequest_data.html b/kallithea/templates/pullrequests/pullrequest_data.html
--- a/kallithea/templates/pullrequests/pullrequest_data.html
+++ b/kallithea/templates/pullrequests/pullrequest_data.html
@@ -8,7 +8,7 @@
%else:
%endif
-
+
${pr.title or _("(no title)")}
%if pr.is_closed():
${_('Closed')}
diff --git a/kallithea/templates/pullrequests/pullrequest_show_my_data.html b/kallithea/templates/pullrequests/pullrequest_show_my_data.html
--- a/kallithea/templates/pullrequests/pullrequest_show_my_data.html
+++ b/kallithea/templates/pullrequests/pullrequest_show_my_data.html
@@ -10,7 +10,7 @@ ${h.checkbox('show_closed',checked="chec
%else:
%endif
-
+
${pull_request.title or _("(no title)")}
${_('opened on %s from') % (h.fmt_date(pull_request.created_on))}
@@ -43,7 +43,7 @@ ${h.checkbox('show_closed',checked="chec
%else:
%endif
-
+
${pull_request.title or _("(no title)")}
${_('from')}