improve scriptability of post-commit

Review Request #212 — Created Jan. 25, 2008 and discarded

Information

Review Board SVN (deprecated)

Reviewers

 * post_review separated from __main__ to allow importing from other scripts such as post-commit hook; allows any command-line option to be set programatically in call to post_review method 
 * adds --submit-as option
 * adds --repository option; allows empty basedir for repo diffs
 * includes json responses in debug mode
 * consolidates .reviewboardrc loading into one place in __main__
 * allow use of -c (--revision) with svn and removed -c as a weird special case in parse_options; removed --revision-range: reviewing multiple revisions in svn makes as little sense as in p4
 * generalizes and expands request field setting in mutable_request_fields
 * allows any (long-form) command-line option to be set in .reviewboardrc (backwards incompatibility: this means "REVIEWBOARD_URL" in .reviewboardrc should now be just "server"); if also specified on command-line, command-line takes precedence

I've included this as a diff against post-review but the name needs to be changed to make it importable (hyphens are not legal in a module name).  I used the obvious "post_review.py"

 
chipx86
  1. 
      
  2. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
    This is too much work for what is already built into urllib2. We want to do:
    
    opener = urllib2.build_opener(urllib2.ProxyHandler(),
                                  urllib2.UnknownHandler(),
                                  urllib2.HTTPHandler(),
                                  ...)
  3. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
    Can you use more of a sentence form? Casing, complete sentences.
  4. Excess whitespace.
  5. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
     
     
    This would have to be AttrDict, to keep with the syntax, but I'm not really a fan of this. I'd rather we either have a class with these methods or just use a dict.
  6. Sentence form and excess whitespace.
    
    Blank line before the first comment.
  7. Wrap to 80 lines.
  8. Let's be more specific. "JSON response is %s"
  9. This variable is a bit confusing.
  10. Can you use keyword arguments here as well, so it's consistent with the other instances?
  11. Excess whitespace.
  12. Please go back to using super.
  13. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
    The doc block should stay.
  14. Instead of "cwd", please say "the current directory"
  15. Blank line before each of these lines. Any time a block ends, we put a blank line after it.
  16. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
     
     
     
     
    We should be explicit and check that a changenum was passed before trying to use it.
  17. "The current directory is not a working copy and a repository was not specified."
  18. Blank line before this.
  19. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
    Keep the blank line here, please.
  20. This should be wrapped to 80 characters and should be a bit more human-readable.
    
    The error isn't really correct. You can diff by filenames. We just don't support it. The error should be more clear and say that we don't support diffs by filenames.
    
    Blank line after this line.
  21. This should stay sys.exit(1). It's an error code. We're not exiting successfully.
  22. Change "crap" to "stuff" or something.
  23. No need for getattr. This can be options[field]
  24. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
    I'd prefer this to go back to how it was.
    
    Also, You removed the blank line between the text and URL.
  25. This isn't always correct. Maybe something like:
    
    "%prog [changenum|files]"
  26. Excess whitespace.
  27. Excess whitespace.
  28. Excess whitespace.
  29. This change is going to be a problem.
    
    We need to keep the existing method of assuming changenum on Perforce. Otherwise we're going to break a lot of setups.
    
    Also, the revision range stuff cannot change. For the same reasons.
  30. "submit changes for another user (requires special permissions)"
  31. This should be added by the SVNClient.
  32. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
     
    This should be added by the Perforce client.
  33. Excess whitespace.
  34. Excess whitespace.
  35. Wrap to 80 characters.
  36. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
    Yes, it's used. That comment can be removed from here.
    
    Also, blank line before the comment block.
  37. These can be combined to one line.
  38.