##// END OF EJS Templates
pull-reqeusts: added option to force-refresh merge workspace in case of problems.
marcink -
r2780:ac1e4aa6 default
parent child Browse files
Show More
@@ -248,6 +248,7 b' class RepoPullRequestsView(RepoAppView, '
248 from_version = self.request.GET.get('from_version') or version
248 from_version = self.request.GET.get('from_version') or version
249 merge_checks = self.request.GET.get('merge_checks')
249 merge_checks = self.request.GET.get('merge_checks')
250 c.fulldiff = str2bool(self.request.GET.get('fulldiff'))
250 c.fulldiff = str2bool(self.request.GET.get('fulldiff'))
251 force_refresh = str2bool(self.request.GET.get('force_refresh'))
251
252
252 (pull_request_latest,
253 (pull_request_latest,
253 pull_request_at_ver,
254 pull_request_at_ver,
@@ -339,7 +340,7 b' class RepoPullRequestsView(RepoAppView, '
339 # check merge capabilities
340 # check merge capabilities
340 _merge_check = MergeCheck.validate(
341 _merge_check = MergeCheck.validate(
341 pull_request_latest, user=self._rhodecode_user,
342 pull_request_latest, user=self._rhodecode_user,
342 translator=self.request.translate)
343 translator=self.request.translate, force_shadow_repo_refresh=force_refresh)
343 c.pr_merge_errors = _merge_check.error_details
344 c.pr_merge_errors = _merge_check.error_details
344 c.pr_merge_possible = not _merge_check.failed
345 c.pr_merge_possible = not _merge_check.failed
345 c.pr_merge_message = _merge_check.merge_msg
346 c.pr_merge_message = _merge_check.merge_msg
@@ -1211,7 +1211,8 b' class PullRequestModel(BaseModel):'
1211
1211
1212 return comment, status
1212 return comment, status
1213
1213
1214 def merge_status(self, pull_request, translator=None):
1214 def merge_status(self, pull_request, translator=None,
1215 force_shadow_repo_refresh=False):
1215 _ = translator or get_current_request().translate
1216 _ = translator or get_current_request().translate
1216
1217
1217 if not self._is_merge_enabled(pull_request):
1218 if not self._is_merge_enabled(pull_request):
@@ -1225,7 +1226,9 b' class PullRequestModel(BaseModel):'
1225 return merge_possible, msg
1226 return merge_possible, msg
1226
1227
1227 try:
1228 try:
1228 resp = self._try_merge(pull_request)
1229 resp = self._try_merge(
1230 pull_request,
1231 force_shadow_repo_refresh=force_shadow_repo_refresh)
1229 log.debug("Merge response: %s", resp)
1232 log.debug("Merge response: %s", resp)
1230 status = resp.possible, self.merge_status_message(
1233 status = resp.possible, self.merge_status_message(
1231 resp.failure_reason)
1234 resp.failure_reason)
@@ -1262,13 +1265,13 b' class PullRequestModel(BaseModel):'
1262 'extensions', 'largefiles')
1265 'extensions', 'largefiles')
1263 return largefiles_ui and largefiles_ui[0].active
1266 return largefiles_ui and largefiles_ui[0].active
1264
1267
1265 def _try_merge(self, pull_request):
1268 def _try_merge(self, pull_request, force_shadow_repo_refresh=False):
1266 """
1269 """
1267 Try to merge the pull request and return the merge status.
1270 Try to merge the pull request and return the merge status.
1268 """
1271 """
1269 log.debug(
1272 log.debug(
1270 "Trying out if the pull request %s can be merged.",
1273 "Trying out if the pull request %s can be merged. Force_refresh=%s",
1271 pull_request.pull_request_id)
1274 pull_request.pull_request_id, force_shadow_repo_refresh)
1272 target_vcs = pull_request.target_repo.scm_instance()
1275 target_vcs = pull_request.target_repo.scm_instance()
1273
1276
1274 # Refresh the target reference.
1277 # Refresh the target reference.
@@ -1285,7 +1288,8 b' class PullRequestModel(BaseModel):'
1285 log.debug("The target repository is locked.")
1288 log.debug("The target repository is locked.")
1286 merge_state = MergeResponse(
1289 merge_state = MergeResponse(
1287 False, False, None, MergeFailureReason.TARGET_IS_LOCKED)
1290 False, False, None, MergeFailureReason.TARGET_IS_LOCKED)
1288 elif self._needs_merge_state_refresh(pull_request, target_ref):
1291 elif force_shadow_repo_refresh or self._needs_merge_state_refresh(
1292 pull_request, target_ref):
1289 log.debug("Refreshing the merge status of the repository.")
1293 log.debug("Refreshing the merge status of the repository.")
1290 merge_state = self._refresh_merge_state(
1294 merge_state = self._refresh_merge_state(
1291 pull_request, target_vcs, target_ref)
1295 pull_request, target_vcs, target_ref)
@@ -1575,7 +1579,8 b' class MergeCheck(object):'
1575 )
1579 )
1576
1580
1577 @classmethod
1581 @classmethod
1578 def validate(cls, pull_request, user, translator, fail_early=False):
1582 def validate(cls, pull_request, user, translator, fail_early=False,
1583 force_shadow_repo_refresh=False):
1579 _ = translator
1584 _ = translator
1580 merge_check = cls()
1585 merge_check = cls()
1581
1586
@@ -1626,7 +1631,8 b' class MergeCheck(object):'
1626
1631
1627 # merge possible
1632 # merge possible
1628 merge_status, msg = PullRequestModel().merge_status(
1633 merge_status, msg = PullRequestModel().merge_status(
1629 pull_request, translator=translator)
1634 pull_request, translator=translator,
1635 force_shadow_repo_refresh=force_shadow_repo_refresh)
1630 merge_check.merge_possible = merge_status
1636 merge_check.merge_possible = merge_status
1631 merge_check.merge_msg = msg
1637 merge_check.merge_msg = msg
1632 if not merge_status:
1638 if not merge_status:
General Comments 0
You need to be logged in to leave comments. Login now