Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHG126998dcfb08: url: some bytes/str cleanup where we interface with stdlib funcs
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
indygreg |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/url.py (5 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 |
self.cookiejar = None | self.cookiejar = None | ||||
cookiefile = ui.config('auth', 'cookiefile') | cookiefile = ui.config('auth', 'cookiefile') | ||||
if not cookiefile: | if not cookiefile: | ||||
return | return | ||||
cookiefile = util.expandpath(cookiefile) | cookiefile = util.expandpath(cookiefile) | ||||
try: | try: | ||||
cookiejar = util.cookielib.MozillaCookieJar(cookiefile) | cookiejar = util.cookielib.MozillaCookieJar( | ||||
pycompat.fsdecode(cookiefile)) | |||||
cookiejar.load() | cookiejar.load() | ||||
self.cookiejar = cookiejar | self.cookiejar = cookiejar | ||||
except util.cookielib.LoadError as e: | except util.cookielib.LoadError as e: | ||||
ui.warn(_('(error loading cookie file %s: %s; continuing without ' | ui.warn(_('(error loading cookie file %s: %s; continuing without ' | ||||
'cookies)\n') % (cookiefile, stringutil.forcebytestr(e))) | 'cookies)\n') % (cookiefile, stringutil.forcebytestr(e))) | ||||
def http_request(self, request): | def http_request(self, request): | ||||
if self.cookiejar: | if self.cookiejar: | ||||
def open(ui, url_, data=None): | def open(ui, url_, data=None): | ||||
u = util.url(url_) | u = util.url(url_) | ||||
if u.scheme: | if u.scheme: | ||||
u.scheme = u.scheme.lower() | u.scheme = u.scheme.lower() | ||||
url_, authinfo = u.authinfo() | url_, authinfo = u.authinfo() | ||||
else: | else: | ||||
path = util.normpath(os.path.abspath(url_)) | path = util.normpath(os.path.abspath(url_)) | ||||
url_ = 'file://' + urlreq.pathname2url(path) | url_ = 'file://' + pycompat.bytesurl(urlreq.pathname2url(path)) | ||||
authinfo = None | authinfo = None | ||||
return opener(ui, authinfo).open(pycompat.strurl(url_), data) | return opener(ui, authinfo).open(pycompat.strurl(url_), data) |