@@ -293,96 +293,98 @@ class PullrequestsController(BaseRepoCon
def repo_info(self, repo_name):
repo = RepoModel()._get_repo(repo_name)
refs, selected_ref = self._get_repo_refs(repo.scm_instance)
return {
'description': repo.description.split('\n', 1)[0],
'selected_ref': selected_ref,
'refs': refs,
}
@LoginRequired()
@NotAnonymous()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
def create(self, repo_name):
try:
_form = PullRequestForm(repo.repo_id)().to_python(request.POST)
except formencode.Invalid, errors:
log.error(traceback.format_exc())
log.error(str(errors))
msg = _('Error creating pull request: %s') % errors.msg
h.flash(msg, 'error')
raise HTTPBadRequest
# heads up: org and other might seem backward here ...
org_repo_name = _form['org_repo']
org_ref = _form['org_ref'] # will have merge_rev as rev but symbolic name
org_repo = RepoModel()._get_repo(org_repo_name)
(org_ref_type,
org_ref_name,
org_rev) = org_ref.split(':')
if org_ref_type == 'rev':
org_ref_type = 'branch'
cs = org_repo.scm_instance.get_changeset(org_rev)
org_ref = '%s:%s:%s' % (org_ref_type, cs.branch, cs.raw_id)
other_repo_name = _form['other_repo']
other_ref = _form['other_ref'] # will have symbolic name and head revision
other_repo = RepoModel()._get_repo(other_repo_name)
(other_ref_type,
other_ref_name,
other_rev) = other_ref.split(':')
cs_ranges, _cs_ranges_not, ancestor_rev = \
CompareController._get_changesets(org_repo.scm_instance.alias,
other_repo.scm_instance, other_rev, # org and other "swapped"
org_repo.scm_instance, org_rev,
)
if ancestor_rev is None:
ancestor_rev = org_repo.scm_instance.EMPTY_CHANGESET
revisions = [cs.raw_id for cs in cs_ranges]
# hack: ancestor_rev is not an other_rev but we want to show the
# requested destination and have the exact ancestor
other_ref = '%s:%s:%s' % (other_ref_type, other_ref_name, ancestor_rev)
reviewers = _form['review_members']
title = _form['pullrequest_title']
if not title:
if org_repo_name == other_repo_name:
title = '%s to %s' % (h.short_ref(org_ref_type, org_ref_name),
h.short_ref(other_ref_type, other_ref_name))
else:
title = '%s#%s to %s#%s' % (org_repo_name, h.short_ref(org_ref_type, org_ref_name),
other_repo_name, h.short_ref(other_ref_type, other_ref_name))
description = _form['pullrequest_desc'].strip() or _('No description')
pull_request = PullRequestModel().create(
self.authuser.user_id, org_repo_name, org_ref, other_repo_name,
other_ref, revisions, reviewers, title, description
Session().commit()
h.flash(_('Successfully opened new pull request'),
category='success')
except UserInvalidException, u:
h.flash(_('Invalid reviewer "%s" specified') % u, category='error')
raise HTTPBadRequest()
except Exception:
h.flash(_('Error occurred while creating pull request'),
category='error')
return redirect(url('pullrequest_home', repo_name=repo_name))
return redirect(pull_request.url())
def create_update(self, old_pull_request, updaterev, title, description, reviewers_ids):
org_repo = RepoModel()._get_repo(old_pull_request.org_repo.repo_name)
org_ref_type, org_ref_name, org_rev = old_pull_request.org_ref.split(':')
new_org_rev = self._get_ref_rev(org_repo, 'rev', updaterev)
other_repo = RepoModel()._get_repo(old_pull_request.other_repo.repo_name)
other_ref_type, other_ref_name, other_rev = old_pull_request.other_ref.split(':') # other_rev is ancestor
#assert other_ref_type == 'branch', other_ref_type # TODO: what if not?
new_other_rev = self._get_ref_rev(other_repo, other_ref_type, other_ref_name)
cs_ranges, _cs_ranges_not, ancestor_rev = CompareController._get_changesets(org_repo.scm_instance.alias,
other_repo.scm_instance, new_other_rev, # org and other "swapped"
Status change: