781: missing exception in NewReviewRequestForm().create

marc****@gmai***** (Google Code) (Is this you? Claim this profile.)
July 26, 2009
What's the URL of the page this enhancement relates to, if any?
The part of the code is used when creating a new review request

Describe the enhancement and the motivation for it.
This is just to avoid a future bug, two cases will delete the review 
request instance and a few lines later, the function will try to save it.


to sum-up, the code  below may be executed:
review_request.delete()
review_request.save() # will raise an exception.


You should raise a new exception for instance:
(from http://code.google.com/p/reviewboard/source/browse/trunk/reviewboard/review
s/forms.py)

        try:
            diff_form.create(diff_file, parent_diff_file,
                             review_request.diffset_history)
            if 'path' in diff_form.errors:
                review_request.delete()
                self.errors['diff_path'] = diff_form.errors['path']
                raise NewExceptionError # here
            elif 'base_diff_path' in diff_form.errors:
                review_request.delete()
                self.errors['base_diff_path'] = 
diff_form.errors['base_diff_path']
                raise NewExceptionError # and here
        except EmptyDiffError:
            review_request.delete()
            self.errors['diff_path'] = forms.util.ErrorList([
                'The selected file does not appear to be a diff.'])
            raise
        except Exception, e:
            review_request.delete()
            self.errors['diff_path'] = forms.util.ErrorList([e])
            raise

        review_request.add_default_reviewers()
        review_request.save()
        return review_request
david
#1 david
Fixed in SVN r2062. Thanks!
  • +Fixed