Review Board

beta

Patch: Allow Mercurial (hg) scmtools back end to utilize repository credentials when accessing HTTP/HTTPS paths

Submitted
Updated 4 months, 1 week ago

Derek Slager Reviewers
reviewboard
536
None Review Board SVN
A relatively simple change that seems to work ... that said, I don't really know Python at all, so it's rather likely that there's something "not quite right" here.
Tested on Debian and Windows, Python 2.5.2. It also seems to work alright with unauthenticated remote servers, though that has only been tested lightly.
Posted 4 months, 1 week ago (July 10th, 2008, 10:54 p.m.)

   

  
trunk/reviewboard/scmtools/hg.py (Diff revision 1)
85
            f = urllib2.urlopen('%s/raw-file/%s/%s' % (self.url, rev, path))
89
            passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
90
            passman.add_password(None, self.url, self.username, self.password)
91
            authhandler = urllib2.HTTPBasicAuthHandler(passman)
92
            opener = urllib2.build_opener(authhandler)
What if the username and/or password are blank? Maybe we should only do this if one or both are set.
  1. Derek Slager 4 months, 1 week ago (July 11th, 2008, 12:14 a.m.)
    I thought that would be problematic as well, but it didn't complain on the add_password call when they were blank in my testing. For unauthenticated repositories, the password manager is never consulted, so it appears to be harmless.
Ship it!
Posted 4 months, 1 week ago (July 13th, 2008, 5:28 p.m.)
In that case, this looks good.  Committed as r1401.  Thanks!