diff --git a/hgext/absorb.py b/hgext/absorb.py --- a/hgext/absorb.py +++ b/hgext/absorb.py @@ -33,6 +33,7 @@ import collections +import io from mercurial.i18n import _ from mercurial.node import ( @@ -968,7 +969,7 @@ a1 = hunk.fromline + len(hunk.before) - 1 # remove before and after context hunk.before = hunk.after = [] - buf = util.stringio() + buf = io.BytesIO() hunk.write(buf) patchlines = mdiff.splitnewlines(buf.getvalue()) # hunk.prettystr() will update hunk.removed diff --git a/hgext/convert/cvs.py b/hgext/convert/cvs.py --- a/hgext/convert/cvs.py +++ b/hgext/convert/cvs.py @@ -6,6 +6,7 @@ # GNU General Public License version 2 or any later version. import errno +import io import os import re import socket @@ -30,7 +31,6 @@ cvsps, ) -stringio = util.stringio checktool = common.checktool commit = common.commit converter_source = common.converter_source @@ -260,7 +260,7 @@ # file-objects returned by socket.makefile() do not handle # large read() requests very well. chunksize = 65536 - output = stringio() + output = io.BytesIO() while count > 0: data = fp.read(min(count, chunksize)) if not data: diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py --- a/hgext/convert/hg.py +++ b/hgext/convert/hg.py @@ -17,6 +17,7 @@ # the converted revision to have a different identity than the # source. +import io import os import re import time @@ -43,8 +44,6 @@ ) from mercurial.utils import dateutil -stringio = util.stringio - from . import common mapfile = common.mapfile @@ -149,7 +148,7 @@ self.before() def _rewritetags(self, source, revmap, data): - fp = stringio() + fp = io.BytesIO() for line in data.splitlines(): s = line.split(b' ', 1) if len(s) != 2: @@ -169,7 +168,7 @@ return fp.getvalue() def _rewritesubstate(self, source, data): - fp = stringio() + fp = io.BytesIO() for line in data.splitlines(): s = line.split(b' ', 1) if len(s) != 2: diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -3,6 +3,7 @@ # Copyright(C) 2007 Daniel Holth et al import codecs +import io import locale import os import pickle @@ -26,7 +27,6 @@ from . import common -stringio = util.stringio propertycache = util.propertycache urlerr = util.urlerr urlreq = util.urlreq @@ -1267,12 +1267,12 @@ if self.module != new_module: self.module = new_module self.reparent(self.module) - io = stringio() - info = svn.ra.get_file(self.ra, file, revnum, io) - data = io.getvalue() + bio = io.BytesIO() + info = svn.ra.get_file(self.ra, file, revnum, bio) + data = bio.getvalue() # ra.get_file() seems to keep a reference on the input buffer # preventing collection. Release it explicitly. - io.close() + bio.close() if isinstance(info, list): info = info[-1] mode = (b"svn:executable" in info) and b'x' or b'' diff --git a/hgext/infinitepush/bundleparts.py b/hgext/infinitepush/bundleparts.py --- a/hgext/infinitepush/bundleparts.py +++ b/hgext/infinitepush/bundleparts.py @@ -3,6 +3,7 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. +import io from mercurial.i18n import _ from mercurial.node import hex @@ -114,7 +115,7 @@ self.params = part.params self.mandatorykeys = part.mandatorykeys # copy the buffer - self._io = util.stringio(part.read()) + self._io = io.BytesIO(part.read()) def consume(self): return diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -77,6 +77,7 @@ import email.mime.multipart as emimemultipart import email.utils as eutil import errno +import io import os import socket @@ -104,8 +105,6 @@ urlutil, ) -stringio = util.stringio - cmdtable = {} command = registrar.command(cmdtable) @@ -228,7 +227,7 @@ tmpl = ui.config(b'patchbomb', b'flagtemplate') if not tmpl: return b' '.join(flags) - out = util.stringio() + out = io.BytesIO() spec = formatter.literal_templatespec(templater.unquotestring(tmpl)) with formatter.templateformatter(ui, out, b'patchbombflag', {}, spec) as fm: fm.startitem() @@ -360,7 +359,7 @@ for r in revs: if r == prev and (repo[None].files() or repo[None].deleted()): ui.warn(_(b'warning: working directory has uncommitted changes\n')) - output = stringio() + output = io.BytesIO() cmdutil.exportfile( repo, [r], output, opts=patch.difffeatureopts(ui, opts, git=True) ) @@ -995,7 +994,7 @@ if not mbox: # Exim does not remove the Bcc field del m['Bcc'] - fp = stringio() + fp = io.BytesIO() generator = mail.Generator(fp, mangle_from_=False) generator.flatten(m, False) alldests = to + bcc + cc diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -660,7 +660,7 @@ def getdiff(basectx, ctx, diffopts): """plain-text diff without header (user, commit message, etc)""" - output = util.stringio() + output = io.BytesIO() for chunk, _label in patch.diffui( ctx.repo(), basectx.p1().node(), ctx.node(), None, opts=diffopts ):