D1555: py3: add pycompat.basestring and use it

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Nov 29 18:10:19 EST 2017


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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/httppeer.py
  mercurial/pycompat.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -47,6 +47,7 @@
     from . import scmposix as scmplatform
 
 termsize = scmplatform.termsize
+basestring = pycompat.basestring
 
 class status(tuple):
     '''Named tuple with a list of files per status. The 'deleted', 'unknown'
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -45,6 +45,7 @@
     import io
     import struct
 
+    basestring = (str, bytes)
     fsencode = os.fsencode
     fsdecode = os.fsdecode
     oslinesep = os.linesep.encode('ascii')
@@ -260,6 +261,7 @@
 else:
     import cStringIO
 
+    basestring = basestring
     bytechr = chr
     bytestr = str
     iterbytestr = iter
diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -31,6 +31,7 @@
 httplib = util.httplib
 urlerr = util.urlerr
 urlreq = util.urlreq
+basestring = pycompat.basestring
 
 def encodevalueinheaders(value, header, limit):
     """Encode a string value into multiple HTTP headers.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -50,6 +50,8 @@
 )
 stringio = util.stringio
 
+basestring = pycompat.basestring
+
 # templates of common command options
 
 dryrunopts = [



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


More information about the Mercurial-devel mailing list