283: Changes to post-review python script (diff attached)

rasmus.m********@gmai***** (Google Code) (Is this you? Claim this profile.)
chipx86
chipx86
Dec. 26, 2007
We found some minor issues in the post-review python script found in
trunk\reviewboard\contrib\tools. We fixed these errors to fit our own
needs. We attached the diff.
You might want to edit our changes and only  select a subset of the
changes, but that's up to you.

Changes:
31.  Ignore any proxy settings
221. There seem to be a problem with urljoin regarding IP addresses
220. Reuse created URL
448. Handle overlayed perforce client specs
488-495. Our diff tool (Cygwin v.2.8.7) output didn't match the what was in
the script regarding binary files.
520-523. The script removed all line endings wrongly (may be our diff version)
668. Again the urljoin problem
669-800. We implemented the feature on windows

Take what you can use ;O)
Index: post-review
===================================================================
--- post-review	(revision 993)
+++ post-review	(working copy)
@@ -1,776 +1,805 @@
-#!/usr/bin/env python
-
-import cookielib
-import httplib
-import mimetools
-import mimetypes
-import os
-import getpass
-import re
-import simplejson
-import socket
-import sys
-import urllib2
-from optparse import OptionParser
-from tempfile import mkstemp
-from urlparse import urljoin
-
-VERSION = "0.6"
-
-# Who stole the cookies from the cookie jar?
-# Was it you?
-# >:(
-if 'USERPROFILE' in os.environ:
-    homepath = os.path.join(os.environ["USERPROFILE"], "UserData")
-else:
-    homepath = os.environ["HOME"]
-
-cj = cookielib.MozillaCookieJar()
-cookiefile = os.path.join(homepath, ".post-review-cookies.txt")
-
-opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
-opener.addheaders = [('User-agent', 'post-review/' + VERSION)]
-urllib2.install_opener(opener)
-
-user_config = None
-tempfiles = []
-o
chipx86
#1 chipx86
  • -Type-Defect
    +Type-Enhancement
    +Component-Scripts
chipx86
#2 chipx86
Thanks, the changes sound good.

The attached diff appears to basically do a delete of all existing content and then
an insert of new content. Can you generate a working diff and then put it up on
reviews.review-board.org?

It would also help if you could group these into separate diffs somehow, but I
realize that might be more difficult.
  • +chipx86
david
#3 david
Fixed the diff.  I'll be pulling some of these changes into SVN, but I'm attaching it
just for future reference.
  • +
    --- post-review-old	2007-12-25 21:01:12.000000000 -0700
    +++ post-review-new	2007-12-25 21:01:59.000000000 -0700
    @@ -1,5 +1,6 @@
     #!/usr/bin/env python
     
    +
     import cookielib
     import httplib
     import mimetools
    @@ -28,7 +29,7 @@
     cj = cookielib.MozillaCookieJar()
     cookiefile = os.path.join(homepath, ".post-review-cookies.txt")
     
    -opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    +opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), urllib2.ProxyHandler({}))
     opener.addheaders = [('User-agent', 'post-review/' + VERSION)]
     urllib2.install_opener(opener)
     
    @@ -207,7 +208,8 @@
                 debug_fields["password"] = "**************"
             debug('HTTP POSTing to %s: %s' % (path, debug_fields))
     
    -        url = urljoin(self.url, path)
    +        url = 'http://%s%s' % (self.url, path)
    +
             content_type, body = self._encode_multipart_formdata(fields, files)
             headers = {
                 'Content-Type': content_type,
    @@ -215,7 +217,7 @@
             }
     
             try:
    -
david
#4 david
Having looked at these changes, I have a couple questions about these:

31.  Ignore any proxy settings
    Why?

448. Handle overlayed perforce client specs
    Not knowing what an overlayed client spec is, I can't decide if this is good. 
Can you explain?

david
#5 david
Having looked at this more, I've pulled all but a couple parts of the diff into
trunk.  Thanks!
  • +Fixed