import: suppress accept: header
irccloud and others may perform content negotation and reject (406)
if the accept header does not match the mime type of the object
--- a/mercurial/commands.py Fri Apr 12 12:06:13 2019 -0400
+++ b/mercurial/commands.py Fri Apr 12 12:20:38 2019 -0400
@@ -3496,7 +3496,7 @@
else:
patchurl = os.path.join(base, patchurl)
ui.status(_('applying %s\n') % patchurl)
- patchfile = hg.openpath(ui, patchurl)
+ patchfile = hg.openpath(ui, patchurl, sendaccept=False)
haspatch = False
for hunk in patch.split(patchfile):
--- a/mercurial/hg.py Fri Apr 12 12:06:13 2019 -0400
+++ b/mercurial/hg.py Fri Apr 12 12:20:38 2019 -0400
@@ -153,13 +153,13 @@
return False
return repo.local()
-def openpath(ui, path):
+def openpath(ui, path, sendaccept=True):
'''open path with open if local, url.open if remote'''
pathurl = util.url(path, parsequery=False, parsefragment=False)
if pathurl.islocal():
return util.posixfile(pathurl.localpath(), 'rb')
else:
- return url.open(ui, path)
+ return url.open(ui, path, sendaccept=sendaccept)
# a list of (ui, repo) functions called for wire peer initialization
wirepeersetupfuncs = []
--- a/mercurial/url.py Fri Apr 12 12:06:13 2019 -0400
+++ b/mercurial/url.py Fri Apr 12 12:20:38 2019 -0400
@@ -601,7 +601,7 @@
return opener
-def open(ui, url_, data=None):
+def open(ui, url_, data=None, sendaccept=True):
u = util.url(url_)
if u.scheme:
u.scheme = u.scheme.lower()
@@ -610,7 +610,9 @@
path = util.normpath(os.path.abspath(url_))
url_ = 'file://' + pycompat.bytesurl(urlreq.pathname2url(path))
authinfo = None
- return opener(ui, authinfo).open(pycompat.strurl(url_), data)
+ return opener(ui, authinfo,
+ sendaccept=sendaccept).open(pycompat.strurl(url_),
+ data)
def wrapresponse(resp):
"""Wrap a response object with common error handlers.