wireprotoserver: define and use parse_qs from urllib
The cgi module is deprecated since Python 2.6. Let's replace uses
of it in wireprotoserver with a similar function from urllib.
Differential Revision: https://phab.mercurial-scm.org/D2094
--- a/mercurial/urllibcompat.py Wed Feb 07 17:18:27 2018 -0800
+++ b/mercurial/urllibcompat.py Tue Feb 06 18:13:15 2018 -0800
@@ -47,6 +47,7 @@
"urlparse",
"urlunparse",
))
+ urlreq._registeralias(urllib.parse, "parse_qs", "parseqs")
urlreq._registeralias(urllib.parse, "unquote_to_bytes", "unquote")
import urllib.request
urlreq._registeraliases(urllib.request, (
@@ -157,6 +158,7 @@
"urlparse",
"urlunparse",
))
+ urlreq._registeralias(urlparse, "parse_qs", "parseqs")
urlerr._registeraliases(urllib2, (
"HTTPError",
"URLError",
--- a/mercurial/wireprotoserver.py Wed Feb 07 17:18:27 2018 -0800
+++ b/mercurial/wireprotoserver.py Tue Feb 06 18:13:15 2018 -0800
@@ -7,7 +7,6 @@
from __future__ import absolute_import
import abc
-import cgi
import contextlib
import struct
import sys
@@ -134,12 +133,12 @@
args = util.rapply(pycompat.bytesurl, self._req.form.copy())
postlen = int(self._req.env.get(r'HTTP_X_HGARGS_POST', 0))
if postlen:
- args.update(cgi.parse_qs(
+ args.update(urlreq.parseqs(
self._req.read(postlen), keep_blank_values=True))
return args
argvalue = decodevaluefromheaders(self._req, r'X-HgArg')
- args.update(cgi.parse_qs(argvalue, keep_blank_values=True))
+ args.update(urlreq.parseqs(argvalue, keep_blank_values=True))
return args
def forwardpayload(self, fp):