Mercurial > kallithea
comparison kallithea/controllers/pullrequests.py @ 5374:d69aa464f373
cleanup: consistently use 'except ... as ...:'
Use the Python 2.6+ syntax instead of the old confusing 'except ..., ...'
syntax.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Sun, 09 Aug 2015 02:17:14 +0200 |
parents | 68bdd7646187 |
children | 0210d0b769d4 |
comparison
equal
deleted
inserted
replaced
5373:e84c2738fbd8 | 5374:d69aa464f373 |
---|---|
242 def index(self): | 242 def index(self): |
243 org_repo = c.db_repo | 243 org_repo = c.db_repo |
244 org_scm_instance = org_repo.scm_instance | 244 org_scm_instance = org_repo.scm_instance |
245 try: | 245 try: |
246 org_scm_instance.get_changeset() | 246 org_scm_instance.get_changeset() |
247 except EmptyRepositoryError, e: | 247 except EmptyRepositoryError as e: |
248 h.flash(h.literal(_('There are no changesets yet')), | 248 h.flash(h.literal(_('There are no changesets yet')), |
249 category='warning') | 249 category='warning') |
250 redirect(url('summary_home', repo_name=org_repo.repo_name)) | 250 redirect(url('summary_home', repo_name=org_repo.repo_name)) |
251 | 251 |
252 org_rev = request.GET.get('rev_end') | 252 org_rev = request.GET.get('rev_end') |
305 'repository.admin') | 305 'repository.admin') |
306 def create(self, repo_name): | 306 def create(self, repo_name): |
307 repo = RepoModel()._get_repo(repo_name) | 307 repo = RepoModel()._get_repo(repo_name) |
308 try: | 308 try: |
309 _form = PullRequestForm(repo.repo_id)().to_python(request.POST) | 309 _form = PullRequestForm(repo.repo_id)().to_python(request.POST) |
310 except formencode.Invalid, errors: | 310 except formencode.Invalid as errors: |
311 log.error(traceback.format_exc()) | 311 log.error(traceback.format_exc()) |
312 log.error(str(errors)) | 312 log.error(str(errors)) |
313 msg = _('Error creating pull request: %s') % errors.msg | 313 msg = _('Error creating pull request: %s') % errors.msg |
314 h.flash(msg, 'error') | 314 h.flash(msg, 'error') |
315 raise HTTPBadRequest | 315 raise HTTPBadRequest |
363 other_ref, revisions, reviewers, title, description | 363 other_ref, revisions, reviewers, title, description |
364 ) | 364 ) |
365 Session().commit() | 365 Session().commit() |
366 h.flash(_('Successfully opened new pull request'), | 366 h.flash(_('Successfully opened new pull request'), |
367 category='success') | 367 category='success') |
368 except UserInvalidException, u: | 368 except UserInvalidException as u: |
369 h.flash(_('Invalid reviewer "%s" specified') % u, category='error') | 369 h.flash(_('Invalid reviewer "%s" specified') % u, category='error') |
370 raise HTTPBadRequest() | 370 raise HTTPBadRequest() |
371 except Exception: | 371 except Exception: |
372 h.flash(_('Error occurred while creating pull request'), | 372 h.flash(_('Error occurred while creating pull request'), |
373 category='error') | 373 category='error') |
450 self.authuser.user_id, | 450 self.authuser.user_id, |
451 old_pull_request.org_repo.repo_name, new_org_ref, | 451 old_pull_request.org_repo.repo_name, new_org_ref, |
452 old_pull_request.other_repo.repo_name, new_other_ref, | 452 old_pull_request.other_repo.repo_name, new_other_ref, |
453 revisions, reviewers_ids, title, description | 453 revisions, reviewers_ids, title, description |
454 ) | 454 ) |
455 except UserInvalidException, u: | 455 except UserInvalidException as u: |
456 h.flash(_('Invalid reviewer "%s" specified') % u, category='error') | 456 h.flash(_('Invalid reviewer "%s" specified') % u, category='error') |
457 raise HTTPBadRequest() | 457 raise HTTPBadRequest() |
458 except Exception: | 458 except Exception: |
459 h.flash(_('Error occurred while creating pull request'), | 459 h.flash(_('Error occurred while creating pull request'), |
460 category='error') | 460 category='error') |
505 pull_request.title = _form['pullrequest_title'] | 505 pull_request.title = _form['pullrequest_title'] |
506 pull_request.description = _form['pullrequest_desc'].strip() or _('No description') | 506 pull_request.description = _form['pullrequest_desc'].strip() or _('No description') |
507 try: | 507 try: |
508 PullRequestModel().mention_from_description(pull_request, old_description) | 508 PullRequestModel().mention_from_description(pull_request, old_description) |
509 PullRequestModel().update_reviewers(pull_request_id, reviewers_ids) | 509 PullRequestModel().update_reviewers(pull_request_id, reviewers_ids) |
510 except UserInvalidException, u: | 510 except UserInvalidException as u: |
511 h.flash(_('Invalid reviewer "%s" specified') % u, category='error') | 511 h.flash(_('Invalid reviewer "%s" specified') % u, category='error') |
512 raise HTTPBadRequest() | 512 raise HTTPBadRequest() |
513 | 513 |
514 Session().commit() | 514 Session().commit() |
515 h.flash(_('Pull request updated'), category='success') | 515 h.flash(_('Pull request updated'), category='success') |