D890: urllibcompat: new library to help abstract out some python3 urllib2 stuff

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Sun Oct 1 16:43:42 UTC 2017


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Doing a new file instead of pycompat because I'm starting to feel like
  pycompat is getting a little enormous in terms of scope.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/urllibcompat.py

CHANGE DETAILS

diff --git a/mercurial/urllibcompat.py b/mercurial/urllibcompat.py
new file mode 100644
--- /dev/null
+++ b/mercurial/urllibcompat.py
@@ -0,0 +1,36 @@
+from __future__ import absolute_import
+
+from . import pycompat
+
+if pycompat.ispy3:
+
+    def getfullurl(req):
+        return req.full_url
+
+    def gethost(req):
+        return req.host
+
+    def getselector(req):
+        return req.selector
+
+    def getdata(req):
+        return req.data
+
+    def hasdata(req):
+        return req.data is not None
+else:
+
+    def gethost(req):
+        return req.get_host()
+
+    def getselector(req):
+        return req.get_selector()
+
+    def getfullurl(req):
+        return req.get_full_url()
+
+    def getdata(req):
+        return req.get_data()
+
+    def hasdata(req):
+        return req.has_data()



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list