D2094: wireprotoserver: define and use parse_qs from urllib
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Thu Feb 8 05:21:21 UTC 2018
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
The cgi module is deprecated since Python 2.6. Let's replace uses
of it in wireprotoserver with a similar function from urllib.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D2094
AFFECTED FILES
mercurial/urllibcompat.py
mercurial/wireprotoserver.py
CHANGE DETAILS
diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -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):
diff --git a/mercurial/urllibcompat.py b/mercurial/urllibcompat.py
--- a/mercurial/urllibcompat.py
+++ b/mercurial/urllibcompat.py
@@ -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",
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list