# HG changeset patch # User Marcin Kuzminski # Date 2020-02-11 13:34:49 # Node ID 95c3d86784faa791c89ff3ecb4c09ab25151c8bb # Parent 60646747d33e1dc8876b0aed600969f9951dbec7 pull-requests: allow super-admins to force change state of locked PRs. - because we still get into that state in some cases, we just create a helper to unlock it easier. just for super-admins. diff --git a/rhodecode/apps/repository/views/repo_pull_requests.py b/rhodecode/apps/repository/views/repo_pull_requests.py --- a/rhodecode/apps/repository/views/repo_pull_requests.py +++ b/rhodecode/apps/repository/views/repo_pull_requests.py @@ -275,6 +275,20 @@ class RepoPullRequestsView(RepoAppView, c.state_progressing = pull_request.is_state_changing() + _new_state = { + 'created': PullRequest.STATE_CREATED, + }.get(self.request.GET.get('force_state')) + if c.is_super_admin and _new_state: + with pull_request.set_state(PullRequest.STATE_UPDATING, final_state=_new_state): + h.flash( + _('Pull Request state was force changed to `{}`').format(_new_state), + category='success') + Session().commit() + + raise HTTPFound(h.route_path( + 'pullrequest_show', repo_name=self.db_repo_name, + pull_request_id=pull_request_id)) + version = self.request.GET.get('version') from_version = self.request.GET.get('from_version') or version merge_checks = self.request.GET.get('merge_checks') diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -3901,8 +3901,8 @@ class _SetState(object): self._current_state = None def __enter__(self): - log.debug('StateLock: entering set state context, setting state to: `%s`', - self._pr_state) + log.debug('StateLock: entering set state context of pr %s, setting state to: `%s`', + self._pr, self._pr_state) self.set_pr_state(self._pr_state) return self @@ -3912,8 +3912,9 @@ class _SetState(object): return None self.set_pr_state(self._org_state) - log.debug('StateLock: exiting set state context, setting state to: `%s`', - self._org_state) + log.debug('StateLock: exiting set state context of pr %s, setting state to: `%s`', + self._pr, self._org_state) + @property def state(self): return self._current_state diff --git a/rhodecode/templates/pullrequests/pullrequest_show.mako b/rhodecode/templates/pullrequests/pullrequest_show.mako --- a/rhodecode/templates/pullrequests/pullrequest_show.mako +++ b/rhodecode/templates/pullrequests/pullrequest_show.mako @@ -438,6 +438,11 @@

${_('Cannot show diff when pull request state is changing. Current progress state')}: ${c.pull_request.state} + + % if c.is_super_admin: +
+ If you think this is an error try forced state reset to created state. + % endif

% else: