@@ -207,13 +207,14 @@ class CompareController(BaseRepoControll
if org_repo.scm_instance.alias != other_repo.scm_instance.alias:
msg = 'compare of two different kind of remote repos not available'
log.error(msg)
h.flash(msg, category='error')
return redirect(url('compare_home', repo_name=c.repo_name))
c.a_rev = self._get_ref_rev(org_repo, org_ref_type, org_ref_name)
c.a_rev = self._get_ref_rev(org_repo, org_ref_type, org_ref_name,
returnempty=True)
c.cs_rev = self._get_ref_rev(other_repo, other_ref_type, other_ref_name)
c.compare_home = False
c.a_repo = org_repo
c.a_ref_name = org_ref_name
c.a_ref_type = org_ref_type
@@ -577,13 +577,16 @@ class PullrequestsController(BaseRepoCon
c.update_msg_other = ""
if org_scm_instance.alias == 'hg' and c.a_ref_name != 'ancestor':
if c.cs_ref_type != 'branch':
c.cs_branch_name = org_scm_instance.get_changeset(c.cs_ref_name).branch # use ref_type ?
other_branch_name = c.a_ref_name
if c.a_ref_type != 'branch':
other_branch_name = other_scm_instance.get_changeset(c.a_ref_name).branch # use ref_type ?
try:
except EmptyRepositoryError:
other_branch_name = 'null' # not a branch name ... but close enough
# candidates: descendants of old head that are on the right branch
# and not are the old head itself ...
# and nothing at all if old head is a descendent of target ref name
if other_scm_instance._repo.revs('present(%s)::&%s', c.cs_ranges[-1].raw_id, other_branch_name):
c.update_msg = _('This pull request has already been merged to %s.') % other_branch_name
else: # look for children of PR head on source branch in org repo
@@ -433,20 +433,22 @@ class BaseRepoController(BaseController)
c.repository_forks = self.scm_model.get_forks(dbr)
c.repository_pull_requests = self.scm_model.get_pull_requests(dbr)
c.repository_following = self.scm_model.is_following_repo(
c.repo_name, self.authuser.user_id)
@staticmethod
def _get_ref_rev(repo, ref_type, ref_name):
def _get_ref_rev(repo, ref_type, ref_name, returnempty=False):
"""
Safe way to get changeset. If error occurs show error.
from kallithea.lib import helpers as h
return repo.scm_instance.get_ref_revision(ref_type, ref_name)
except EmptyRepositoryError as e:
if returnempty:
return repo.scm_instance.EMPTY_CHANGESET
h.flash(h.literal(_('There are no changesets yet')),
category='error')
raise webob.exc.HTTPNotFound()
except ChangesetDoesNotExistError as e:
h.flash(h.literal(_('Changeset not found')),
Status change: