D887: httppeer: use native strings for headers

2017-10-14 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6db536bed7ec: httppeer: use native strings for headers 
(authored by durin42, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D887?vs=2738=2752#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D887?vs=2738=2752

REVISION DETAIL
  https://phab.mercurial-scm.org/D887

AFFECTED FILES
  mercurial/httppeer.py

CHANGE DETAILS

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -221,7 +221,7 @@
 argsio = io.BytesIO(strargs)
 argsio.length = len(strargs)
 data = _multifile(argsio, data)
-headers['X-HgArgs-Post'] = len(strargs)
+headers[r'X-HgArgs-Post'] = len(strargs)
 else:
 if len(args) > 0:
 httpheader = self.capable('httpheader')
@@ -244,10 +244,10 @@
 elif data is not None:
 size = len(data)
 if size and self.ui.configbool('ui', 'usehttp2'):
-headers['Expect'] = '100-Continue'
-headers['X-HgHttp2'] = '1'
-if data is not None and 'Content-Type' not in headers:
-headers['Content-Type'] = 'application/mercurial-0.1'
+headers[r'Expect'] = r'100-Continue'
+headers[r'X-HgHttp2'] = r'1'
+if data is not None and r'Content-Type' not in headers:
+headers[r'Content-Type'] = r'application/mercurial-0.1'
 
 # Tell the server we accept application/mercurial-0.2 and multiple
 # compression formats if the server is capable of emitting those
@@ -281,7 +281,7 @@
 varyheaders.append(header)
 
 if varyheaders:
-headers['Vary'] = ','.join(varyheaders)
+headers[r'Vary'] = r','.join(varyheaders)
 
 req = self._requestbuilder(pycompat.strurl(cu), data, headers)
 



To: durin42, #hg-reviewers, yuja, indygreg
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D887: httppeer: use native strings for headers

2017-10-14 Thread durin42 (Augie Fackler)
durin42 marked an inline comment as done.
durin42 added a comment.


  Good catch. I've now got things wired up so that (after another ~17 patches 
after this) some basic wireproto stuff is starting to work!
  
  There's a templater bug I can't figure out, which I'll point out when the 
requisite patches to get that far land.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D887

To: durin42, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D887: httppeer: use native strings for headers

2017-10-14 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 2737.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D887?vs=2720=2737

REVISION DETAIL
  https://phab.mercurial-scm.org/D887

AFFECTED FILES
  mercurial/httppeer.py

CHANGE DETAILS

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -221,7 +221,7 @@
 argsio = io.BytesIO(strargs)
 argsio.length = len(strargs)
 data = _multifile(argsio, data)
-headers['X-HgArgs-Post'] = len(strargs)
+headers[r'X-HgArgs-Post'] = len(strargs)
 else:
 if len(args) > 0:
 httpheader = self.capable('httpheader')
@@ -237,17 +237,17 @@
 else:
 q += sorted(args.items())
 qs = '?%s' % urlreq.urlencode(q)
-cu = "%s%s" % (self._url, qs)
+cu = pycompat.strurl(self._url + qs)
 size = 0
 if util.safehasattr(data, 'length'):
 size = data.length
 elif data is not None:
 size = len(data)
 if size and self.ui.configbool('ui', 'usehttp2'):
-headers['Expect'] = '100-Continue'
-headers['X-HgHttp2'] = '1'
-if data is not None and 'Content-Type' not in headers:
-headers['Content-Type'] = 'application/mercurial-0.1'
+headers[r'Expect'] = r'100-Continue'
+headers[r'X-HgHttp2'] = r'1'
+if data is not None and r'Content-Type' not in headers:
+headers[r'Content-Type'] = r'application/mercurial-0.1'
 
 # Tell the server we accept application/mercurial-0.2 and multiple
 # compression formats if the server is capable of emitting those
@@ -281,7 +281,7 @@
 varyheaders.append(header)
 
 if varyheaders:
-headers['Vary'] = ','.join(varyheaders)
+headers[r'Vary'] = r','.join(varyheaders)
 
 req = self._requestbuilder(cu, data, headers)
 



To: durin42, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D887: httppeer: use native strings for headers

2017-10-14 Thread yuja (Yuya Nishihara)
yuja added inline comments.

INLINE COMMENTS

> durin42 wrote in httppeer.py:240
> Turns out urlencode already copes with bytes input even on Python 3. A small 
> victory.

Nice. So we have to concatenate bytes url and bytes qs, then covert the result 
to unicode.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D887

To: durin42, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D887: httppeer: use native strings for headers

2017-10-14 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 2720.
durin42 marked 2 inline comments as done.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D887?vs=2299=2720

REVISION DETAIL
  https://phab.mercurial-scm.org/D887

AFFECTED FILES
  mercurial/httppeer.py

CHANGE DETAILS

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -221,7 +221,7 @@
 argsio = io.BytesIO(strargs)
 argsio.length = len(strargs)
 data = _multifile(argsio, data)
-headers['X-HgArgs-Post'] = len(strargs)
+headers[r'X-HgArgs-Post'] = len(strargs)
 else:
 if len(args) > 0:
 httpheader = self.capable('httpheader')
@@ -237,17 +237,17 @@
 else:
 q += sorted(args.items())
 qs = '?%s' % urlreq.urlencode(q)
-cu = "%s%s" % (self._url, qs)
+cu = r"%s%s" % (pycompat.strurl(self._url), qs)
 size = 0
 if util.safehasattr(data, 'length'):
 size = data.length
 elif data is not None:
 size = len(data)
 if size and self.ui.configbool('ui', 'usehttp2'):
-headers['Expect'] = '100-Continue'
-headers['X-HgHttp2'] = '1'
-if data is not None and 'Content-Type' not in headers:
-headers['Content-Type'] = 'application/mercurial-0.1'
+headers[r'Expect'] = r'100-Continue'
+headers[r'X-HgHttp2'] = r'1'
+if data is not None and r'Content-Type' not in headers:
+headers[r'Content-Type'] = r'application/mercurial-0.1'
 
 # Tell the server we accept application/mercurial-0.2 and multiple
 # compression formats if the server is capable of emitting those
@@ -281,7 +281,7 @@
 varyheaders.append(header)
 
 if varyheaders:
-headers['Vary'] = ','.join(varyheaders)
+headers[r'Vary'] = r','.join(varyheaders)
 
 req = self._requestbuilder(cu, data, headers)
 



To: durin42, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D887: httppeer: use native strings for headers

2017-10-14 Thread durin42 (Augie Fackler)
durin42 added inline comments.

INLINE COMMENTS

> yuja wrote in httppeer.py:233
> Appears that encodevalueinheaders() takes bytes.
> 
> I don't know which would be better to pass unicodes around or convert them
> at one place.

I'm going to go ahead and not mess with this until I hit some test coverage for 
it. I think we should probably just leave encodevalueinheaders() as bytes-in 
but make it native-str-out, but we'll see when we get there.

> yuja wrote in httppeer.py:240
> Perhaps this should be handled in urlencode() because it converts the output
> from str to bytes.

Turns out urlencode already copes with bytes input even on Python 3. A small 
victory.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D887

To: durin42, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D887: httppeer: use native strings for headers

2017-10-02 Thread yuja (Yuya Nishihara)
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> httppeer.py:233
>  encargs = urlreq.urlencode(sorted(args.items()))
> -for header, value in encodevalueinheaders(encargs, 'X-HgArg',
> +for header, value in encodevalueinheaders(encargs, 
> r'X-HgArg',
>headersize):

Appears that encodevalueinheaders() takes bytes.

I don't know which would be better to pass unicodes around or convert them
at one place.

> httppeer.py:240
> +qs = '?%s' % urlreq.urlencode([
> +(pycompat.strurl(qq[0]), pycompat.strurl(qq[1])) for qq in q])
> +cu = r"%s%s" % (pycompat.strurl(self._url), qs)

Perhaps this should be handled in urlencode() because it converts the output
from str to bytes.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D887

To: durin42, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D887: httppeer: use native strings for headers

2017-10-01 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  On Python 3, we need to use unicodes, rather than bytes. This lets
  test-pull.t get a lot further along.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D887

AFFECTED FILES
  mercurial/httppeer.py

CHANGE DETAILS

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -221,33 +221,34 @@
 argsio = io.BytesIO(strargs)
 argsio.length = len(strargs)
 data = _multifile(argsio, data)
-headers['X-HgArgs-Post'] = len(strargs)
+headers[r'X-HgArgs-Post'] = len(strargs)
 else:
 if len(args) > 0:
 httpheader = self.capable('httpheader')
 if httpheader:
 headersize = int(httpheader.split(',', 1)[0])
 if headersize > 0:
 # The headers can typically carry more data than the URL.
 encargs = urlreq.urlencode(sorted(args.items()))
-for header, value in encodevalueinheaders(encargs, 'X-HgArg',
+for header, value in encodevalueinheaders(encargs, r'X-HgArg',
   headersize):
 headers[header] = value
 varyheaders.append(header)
 else:
 q += sorted(args.items())
-qs = '?%s' % urlreq.urlencode(q)
-cu = "%s%s" % (self._url, qs)
+qs = '?%s' % urlreq.urlencode([
+(pycompat.strurl(qq[0]), pycompat.strurl(qq[1])) for qq in q])
+cu = r"%s%s" % (pycompat.strurl(self._url), qs)
 size = 0
 if util.safehasattr(data, 'length'):
 size = data.length
 elif data is not None:
 size = len(data)
 if size and self.ui.configbool('ui', 'usehttp2'):
-headers['Expect'] = '100-Continue'
-headers['X-HgHttp2'] = '1'
-if data is not None and 'Content-Type' not in headers:
-headers['Content-Type'] = 'application/mercurial-0.1'
+headers[r'Expect'] = r'100-Continue'
+headers[r'X-HgHttp2'] = r'1'
+if data is not None and r'Content-Type' not in headers:
+headers[r'Content-Type'] = r'application/mercurial-0.1'
 
 # Tell the server we accept application/mercurial-0.2 and multiple
 # compression formats if the server is capable of emitting those
@@ -281,7 +282,7 @@
 varyheaders.append(header)
 
 if varyheaders:
-headers['Vary'] = ','.join(varyheaders)
+headers[r'Vary'] = r','.join(varyheaders)
 
 req = self._requestbuilder(cu, data, headers)
 



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel