util.stringio is an alias to io.BytesIO. Let's just use io.BytesIO
directly.
I'm doing this because I noticed pytype was confused about types due to
the indirection.
Alphare |
hg-reviewers |
util.stringio is an alias to io.BytesIO. Let's just use io.BytesIO
directly.
I'm doing this because I noticed pytype was confused about types due to
the indirection.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/archival.py (7 lines) | |||
M | mercurial/cmdutil.py (7 lines) | |||
M | mercurial/crecord.py (9 lines) | |||
M | mercurial/patch.py (21 lines) | |||
M | mercurial/profiling.py (3 lines) | |||
M | mercurial/pure/mpatch.py (5 lines) | |||
M | mercurial/pure/parsers.py (4 lines) | |||
M | mercurial/url.py (4 lines) | |||
M | mercurial/wireprotoserver.py (5 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
b25ee83d60f9 | ad6f6ffced66 | Gregory Szorc | Mar 9 2022, 7:48 PM |
# archival.py - revision archival for mercurial | # archival.py - revision archival for mercurial | ||||
# | # | ||||
# Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> | # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
import gzip | import gzip | ||||
import io | |||||
import os | import os | ||||
import struct | import struct | ||||
import tarfile | import tarfile | ||||
import time | import time | ||||
import zipfile | import zipfile | ||||
import zlib | import zlib | ||||
from .i18n import _ | from .i18n import _ | ||||
from .node import nullrev | from .node import nullrev | ||||
from .pycompat import open | from .pycompat import open | ||||
from . import ( | from . import ( | ||||
error, | error, | ||||
formatter, | formatter, | ||||
match as matchmod, | match as matchmod, | ||||
pycompat, | pycompat, | ||||
scmutil, | scmutil, | ||||
util, | util, | ||||
vfs as vfsmod, | vfs as vfsmod, | ||||
) | ) | ||||
from .utils import stringutil | from .utils import stringutil | ||||
stringio = util.stringio | |||||
# from unzip source code: | # from unzip source code: | ||||
_UNX_IFREG = 0x8000 | _UNX_IFREG = 0x8000 | ||||
_UNX_IFLNK = 0xA000 | _UNX_IFLNK = 0xA000 | ||||
def tidyprefix(dest, kind, prefix): | def tidyprefix(dest, kind, prefix): | ||||
"""choose prefix to use for names in archive. make sure prefix is | """choose prefix to use for names in archive. make sure prefix is | ||||
safe for consumers.""" | safe for consumers.""" | ||||
repo = ctx.repo() | repo = ctx.repo() | ||||
opts = { | opts = { | ||||
b'template': repo.ui.config( | b'template': repo.ui.config( | ||||
b'experimental', b'archivemetatemplate', _defaultmetatemplate | b'experimental', b'archivemetatemplate', _defaultmetatemplate | ||||
) | ) | ||||
} | } | ||||
out = util.stringio() | out = io.BytesIO() | ||||
fm = formatter.formatter(repo.ui, out, b'archive', opts) | fm = formatter.formatter(repo.ui, out, b'archive', opts) | ||||
fm.startitem() | fm.startitem() | ||||
fm.context(ctx=ctx) | fm.context(ctx=ctx) | ||||
fm.data(root=_rootctx(repo).hex()) | fm.data(root=_rootctx(repo).hex()) | ||||
if ctx.rev() is None: | if ctx.rev() is None: | ||||
dirty = b'' | dirty = b'' | ||||
if islink: | if islink: | ||||
i.type = tarfile.SYMTYPE | i.type = tarfile.SYMTYPE | ||||
i.mode = 0o777 | i.mode = 0o777 | ||||
i.linkname = pycompat.fsdecode(data) | i.linkname = pycompat.fsdecode(data) | ||||
data = None | data = None | ||||
i.size = 0 | i.size = 0 | ||||
else: | else: | ||||
i.mode = mode | i.mode = mode | ||||
data = stringio(data) | data = io.BytesIO(data) | ||||
self.z.addfile(i, data) | self.z.addfile(i, data) | ||||
def done(self): | def done(self): | ||||
self.z.close() | self.z.close() | ||||
if self.fileobj: | if self.fileobj: | ||||
self.fileobj.close() | self.fileobj.close() | ||||
# cmdutil.py - help for command processing in mercurial | # cmdutil.py - help for command processing in mercurial | ||||
# | # | ||||
# Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> | # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
import copy as copymod | import copy as copymod | ||||
import errno | import errno | ||||
import io | |||||
import os | import os | ||||
import re | import re | ||||
from .i18n import _ | from .i18n import _ | ||||
from .node import ( | from .node import ( | ||||
hex, | hex, | ||||
nullrev, | nullrev, | ||||
short, | short, | ||||
from typing import ( | from typing import ( | ||||
Any, | Any, | ||||
Dict, | Dict, | ||||
) | ) | ||||
for t in (Any, Dict): | for t in (Any, Dict): | ||||
assert t | assert t | ||||
stringio = util.stringio | |||||
# templates of common command options | # templates of common command options | ||||
dryrunopts = [ | dryrunopts = [ | ||||
(b'n', b'dry-run', None, _(b'do not perform actions, just print output')), | (b'n', b'dry-run', None, _(b'do not perform actions, just print output')), | ||||
] | ] | ||||
confirmopts = [ | confirmopts = [ | ||||
(b'', b'confirm', None, _(b'ask before applying actions')), | (b'', b'confirm', None, _(b'ask before applying actions')), | ||||
fd, tmpname = pycompat.mkstemp( | fd, tmpname = pycompat.mkstemp( | ||||
prefix=os.path.basename(f) + b'.', dir=backupdir | prefix=os.path.basename(f) + b'.', dir=backupdir | ||||
) | ) | ||||
os.close(fd) | os.close(fd) | ||||
ui.debug(b'backup %r as %r\n' % (f, tmpname)) | ui.debug(b'backup %r as %r\n' % (f, tmpname)) | ||||
util.copyfile(repo.wjoin(f), tmpname, copystat=True) | util.copyfile(repo.wjoin(f), tmpname, copystat=True) | ||||
backups[f] = tmpname | backups[f] = tmpname | ||||
fp = stringio() | fp = io.BytesIO() | ||||
for c in chunks: | for c in chunks: | ||||
fname = c.filename() | fname = c.filename() | ||||
if fname in backups: | if fname in backups: | ||||
c.write(fp) | c.write(fp) | ||||
dopatch = fp.tell() | dopatch = fp.tell() | ||||
fp.seek(0) | fp.seek(0) | ||||
# 2.5 optionally review / modify patch in text editor | # 2.5 optionally review / modify patch in text editor | ||||
# performing a partial revert of the added file, the only option is | # performing a partial revert of the added file, the only option is | ||||
# "remove added file <name> (Yn)?", so we don't need to worry about the | # "remove added file <name> (Yn)?", so we don't need to worry about the | ||||
# alsorestore value. Ideally we'd be able to partially revert | # alsorestore value. Ideally we'd be able to partially revert | ||||
# copied/renamed files. | # copied/renamed files. | ||||
newlyaddedandmodifiedfiles, unusedalsorestore = newandmodified(chunks) | newlyaddedandmodifiedfiles, unusedalsorestore = newandmodified(chunks) | ||||
if tobackup is None: | if tobackup is None: | ||||
tobackup = set() | tobackup = set() | ||||
# Apply changes | # Apply changes | ||||
fp = stringio() | fp = io.BytesIO() | ||||
# chunks are serialized per file, but files aren't sorted | # chunks are serialized per file, but files aren't sorted | ||||
for f in sorted({c.header.filename() for c in chunks if ishunk(c)}): | for f in sorted({c.header.filename() for c in chunks if ishunk(c)}): | ||||
prntstatusmsg(b'revert', f) | prntstatusmsg(b'revert', f) | ||||
files = set() | files = set() | ||||
for c in chunks: | for c in chunks: | ||||
if ishunk(c): | if ishunk(c): | ||||
abs = c.header.filename() | abs = c.header.filename() | ||||
# Create a backup file only if this hunk should be backed up | # Create a backup file only if this hunk should be backed up |
# stuff related specifically to patch manipulation / parsing | # stuff related specifically to patch manipulation / parsing | ||||
# | # | ||||
# Copyright 2008 Mark Edgington <edgimar@gmail.com> | # Copyright 2008 Mark Edgington <edgimar@gmail.com> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
# | # | ||||
# This code is based on the Mark Edgington's crecord extension. | # This code is based on the Mark Edgington's crecord extension. | ||||
# (Itself based on Bryan O'Sullivan's record extension.) | # (Itself based on Bryan O'Sullivan's record extension.) | ||||
import io | |||||
import os | import os | ||||
import re | import re | ||||
import signal | import signal | ||||
from .i18n import _ | from .i18n import _ | ||||
from .pycompat import ( | from .pycompat import ( | ||||
getattr, | getattr, | ||||
open, | open, | ||||
) | ) | ||||
from . import ( | from . import ( | ||||
diffhelper, | diffhelper, | ||||
encoding, | encoding, | ||||
error, | error, | ||||
patch as patchmod, | patch as patchmod, | ||||
pycompat, | pycompat, | ||||
scmutil, | scmutil, | ||||
util, | util, | ||||
) | ) | ||||
from .utils import stringutil | from .utils import stringutil | ||||
stringio = util.stringio | |||||
# patch comments based on the git one | # patch comments based on the git one | ||||
diffhelptext = _( | diffhelptext = _( | ||||
b"""# To remove '-' lines, make them ' ' lines (context). | b"""# To remove '-' lines, make them ' ' lines (context). | ||||
# To remove '+' lines, delete them. | # To remove '+' lines, delete them. | ||||
# Lines starting with # will be removed from the patch. | # Lines starting with # will be removed from the patch. | ||||
""" | """ | ||||
) | ) | ||||
# list of all headers in patch | # list of all headers in patch | ||||
self.patch = None | self.patch = None | ||||
# flag is False if this header was ever unfolded from initial state | # flag is False if this header was ever unfolded from initial state | ||||
self.neverunfolded = True | self.neverunfolded = True | ||||
self.hunks = [uihunk(h, self) for h in self.hunks] | self.hunks = [uihunk(h, self) for h in self.hunks] | ||||
def prettystr(self): | def prettystr(self): | ||||
x = stringio() | x = io.BytesIO() | ||||
self.pretty(x) | self.pretty(x) | ||||
return x.getvalue() | return x.getvalue() | ||||
def nextsibling(self): | def nextsibling(self): | ||||
numheadersinpatch = len(self.patch) | numheadersinpatch = len(self.patch) | ||||
indexofthisheader = self.patch.index(self) | indexofthisheader = self.patch.index(self) | ||||
if indexofthisheader < numheadersinpatch - 1: | if indexofthisheader < numheadersinpatch - 1: | ||||
elif changedlinestr.startswith(b"-"): | elif changedlinestr.startswith(b"-"): | ||||
hunklinelist.append(b" " + changedlinestr[1:]) | hunklinelist.append(b" " + changedlinestr[1:]) | ||||
fp.write(b''.join(self.before + hunklinelist + self.after)) | fp.write(b''.join(self.before + hunklinelist + self.after)) | ||||
pretty = write | pretty = write | ||||
def prettystr(self): | def prettystr(self): | ||||
x = stringio() | x = io.BytesIO() | ||||
self.pretty(x) | self.pretty(x) | ||||
return x.getvalue() | return x.getvalue() | ||||
def reversehunk(self): | def reversehunk(self): | ||||
"""return a recordhunk which is the reverse of the hunk | """return a recordhunk which is the reverse of the hunk | ||||
Assuming the displayed patch is diff(A, B) result. The returned hunk is | Assuming the displayed patch is diff(A, B) result. The returned hunk is | ||||
intended to be applied to B, instead of A. | intended to be applied to B, instead of A. | ||||
self.ui.write(b"\n") | self.ui.write(b"\n") | ||||
return None | return None | ||||
if chunk.header.binary(): | if chunk.header.binary(): | ||||
self.ui.write(_(b'cannot edit patch for binary file')) | self.ui.write(_(b'cannot edit patch for binary file')) | ||||
self.ui.write(b"\n") | self.ui.write(b"\n") | ||||
return None | return None | ||||
# write the initial patch | # write the initial patch | ||||
patch = stringio() | patch = io.BytesIO() | ||||
patch.write(diffhelptext + hunkhelptext) | patch.write(diffhelptext + hunkhelptext) | ||||
chunk.header.write(patch) | chunk.header.write(patch) | ||||
chunk.write(patch) | chunk.write(patch) | ||||
# start the editor and wait for it to complete | # start the editor and wait for it to complete | ||||
try: | try: | ||||
patch = self.ui.edit(patch.getvalue(), b"", action=b"diff") | patch = self.ui.edit(patch.getvalue(), b"", action=b"diff") | ||||
except error.Abort as exc: | except error.Abort as exc: |
# profiling.py - profiling functions | # profiling.py - profiling functions | ||||
# | # | ||||
# Copyright 2016 Gregory Szorc <gregory.szorc@gmail.com> | # Copyright 2016 Gregory Szorc <gregory.szorc@gmail.com> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
import contextlib | import contextlib | ||||
import io | |||||
from .i18n import _ | from .i18n import _ | ||||
from .pycompat import ( | from .pycompat import ( | ||||
getattr, | getattr, | ||||
open, | open, | ||||
) | ) | ||||
from . import ( | from . import ( | ||||
encoding, | encoding, | ||||
_(b"unrecognized profiler '%s' - ignored\n") % profiler | _(b"unrecognized profiler '%s' - ignored\n") % profiler | ||||
) | ) | ||||
profiler = b'stat' | profiler = b'stat' | ||||
self._output = self._ui.config(b'profiling', b'output') | self._output = self._ui.config(b'profiling', b'output') | ||||
try: | try: | ||||
if self._output == b'blackbox': | if self._output == b'blackbox': | ||||
self._fp = util.stringio() | self._fp = io.BytesIO() | ||||
elif self._output: | elif self._output: | ||||
path = util.expandpath(self._output) | path = util.expandpath(self._output) | ||||
self._fp = open(path, b'wb') | self._fp = open(path, b'wb') | ||||
elif pycompat.iswindows: | elif pycompat.iswindows: | ||||
# parse escape sequence by win32print() | # parse escape sequence by win32print() | ||||
class uifp: | class uifp: | ||||
def __init__(self, ui): | def __init__(self, ui): | ||||
self._ui = ui | self._ui = ui |
# mpatch.py - Python implementation of mpatch.c | # mpatch.py - Python implementation of mpatch.c | ||||
# | # | ||||
# Copyright 2009 Olivia Mackall <olivia@selenic.com> and others | # Copyright 2009 Olivia Mackall <olivia@selenic.com> and others | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
import io | import io | ||||
import struct | import struct | ||||
stringio = io.BytesIO | |||||
class mpatchError(Exception): | class mpatchError(Exception): | ||||
"""error raised when a delta cannot be decoded""" | """error raised when a delta cannot be decoded""" | ||||
# This attempts to apply a series of patches in time proportional to | # This attempts to apply a series of patches in time proportional to | ||||
# the total size of the patches, rather than patches * len(text). This | # the total size of the patches, rather than patches * len(text). This | ||||
# means rather than shuffling strings around, we shuffle around | # means rather than shuffling strings around, we shuffle around | ||||
# pointers to fragments with fragment lists. | # pointers to fragments with fragment lists. | ||||
pl = sum(plens) | pl = sum(plens) | ||||
bl = len(a) + pl | bl = len(a) + pl | ||||
tl = bl + bl + pl # enough for the patches and two working texts | tl = bl + bl + pl # enough for the patches and two working texts | ||||
b1, b2 = 0, bl | b1, b2 = 0, bl | ||||
if not tl: | if not tl: | ||||
return a | return a | ||||
m = stringio() | m = io.BytesIO() | ||||
# load our original text | # load our original text | ||||
m.write(a) | m.write(a) | ||||
frags = [(len(a), b1)] | frags = [(len(a), b1)] | ||||
# copy all the patches into our segment so we can memmove from them | # copy all the patches into our segment so we can memmove from them | ||||
pos = b2 + bl | pos = b2 + bl | ||||
m.seek(pos) | m.seek(pos) |
error, | error, | ||||
revlogutils, | revlogutils, | ||||
util, | util, | ||||
) | ) | ||||
from ..revlogutils import nodemap as nodemaputil | from ..revlogutils import nodemap as nodemaputil | ||||
from ..revlogutils import constants as revlog_constants | from ..revlogutils import constants as revlog_constants | ||||
stringio = io.BytesIO | |||||
_pack = struct.pack | _pack = struct.pack | ||||
_unpack = struct.unpack | _unpack = struct.unpack | ||||
_compress = zlib.compress | _compress = zlib.compress | ||||
_decompress = zlib.decompress | _decompress = zlib.decompress | ||||
# a special value used internally for `size` if the file come from the other parent | # a special value used internally for `size` if the file come from the other parent | ||||
if b'\0' in f: | if b'\0' in f: | ||||
f, c = f.split(b'\0') | f, c = f.split(b'\0') | ||||
copymap[f] = c | copymap[f] = c | ||||
dmap[f] = DirstateItem.from_v1_data(*e[:4]) | dmap[f] = DirstateItem.from_v1_data(*e[:4]) | ||||
return parents | return parents | ||||
def pack_dirstate(dmap, copymap, pl): | def pack_dirstate(dmap, copymap, pl): | ||||
cs = stringio() | cs = io.BytesIO() | ||||
write = cs.write | write = cs.write | ||||
write(b"".join(pl)) | write(b"".join(pl)) | ||||
for f, e in dmap.items(): | for f, e in dmap.items(): | ||||
if f in copymap: | if f in copymap: | ||||
f = b"%s\0%s" % (f, copymap[f]) | f = b"%s\0%s" % (f, copymap[f]) | ||||
e = _pack( | e = _pack( | ||||
b">cllll", | b">cllll", | ||||
e.v1_state(), | e.v1_state(), | ||||
e.v1_mode(), | e.v1_mode(), | ||||
e.v1_size(), | e.v1_size(), | ||||
e.v1_mtime(), | e.v1_mtime(), | ||||
len(f), | len(f), | ||||
) | ) | ||||
write(e) | write(e) | ||||
write(f) | write(f) | ||||
return cs.getvalue() | return cs.getvalue() |
# url.py - HTTP handling for mercurial | # url.py - HTTP handling for mercurial | ||||
# | # | ||||
# Copyright 2005, 2006, 2007, 2008 Olivia Mackall <olivia@selenic.com> | # Copyright 2005, 2006, 2007, 2008 Olivia Mackall <olivia@selenic.com> | ||||
# Copyright 2006, 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br> | # Copyright 2006, 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br> | ||||
# Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> | # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
import base64 | import base64 | ||||
import io | |||||
import socket | import socket | ||||
from .i18n import _ | from .i18n import _ | ||||
from .pycompat import getattr | from .pycompat import getattr | ||||
from . import ( | from . import ( | ||||
encoding, | encoding, | ||||
error, | error, | ||||
httpconnection as httpconnectionmod, | httpconnection as httpconnectionmod, | ||||
keepalive, | keepalive, | ||||
pycompat, | pycompat, | ||||
sslutil, | sslutil, | ||||
urllibcompat, | urllibcompat, | ||||
util, | util, | ||||
) | ) | ||||
from .utils import ( | from .utils import ( | ||||
stringutil, | stringutil, | ||||
urlutil, | urlutil, | ||||
) | ) | ||||
httplib = util.httplib | httplib = util.httplib | ||||
stringio = util.stringio | |||||
urlerr = util.urlerr | urlerr = util.urlerr | ||||
urlreq = util.urlreq | urlreq = util.urlreq | ||||
def escape(s, quote=None): | def escape(s, quote=None): | ||||
"""Replace special characters "&", "<" and ">" to HTML-safe sequences. | """Replace special characters "&", "<" and ">" to HTML-safe sequences. | ||||
If the optional flag quote is true, the quotation mark character (") | If the optional flag quote is true, the quotation mark character (") | ||||
is also translated. | is also translated. | ||||
res.version = 9 | res.version = 9 | ||||
else: | else: | ||||
raise httplib.UnknownProtocol(version) | raise httplib.UnknownProtocol(version) | ||||
if res.version == 9: | if res.version == 9: | ||||
res.length = None | res.length = None | ||||
res.chunked = 0 | res.chunked = 0 | ||||
res.will_close = 1 | res.will_close = 1 | ||||
res.msg = httplib.HTTPMessage(stringio()) | res.msg = httplib.HTTPMessage(io.BytesIO()) | ||||
return False | return False | ||||
res.msg = httplib.HTTPMessage(res.fp) | res.msg = httplib.HTTPMessage(res.fp) | ||||
res.msg.fp = None | res.msg.fp = None | ||||
# are we using the chunked-style of transfer encoding? | # are we using the chunked-style of transfer encoding? | ||||
trenc = res.msg.getheader(b'transfer-encoding') | trenc = res.msg.getheader(b'transfer-encoding') | ||||
if trenc and trenc.lower() == b"chunked": | if trenc and trenc.lower() == b"chunked": |
# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> | # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> | ||||
# Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> | # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
import contextlib | import contextlib | ||||
import io | |||||
import struct | import struct | ||||
import threading | import threading | ||||
from .i18n import _ | from .i18n import _ | ||||
from . import ( | from . import ( | ||||
encoding, | encoding, | ||||
error, | error, | ||||
pycompat, | pycompat, | ||||
util, | util, | ||||
wireprototypes, | wireprototypes, | ||||
wireprotov1server, | wireprotov1server, | ||||
) | ) | ||||
from .interfaces import util as interfaceutil | from .interfaces import util as interfaceutil | ||||
from .utils import ( | from .utils import ( | ||||
compression, | compression, | ||||
stringutil, | stringutil, | ||||
) | ) | ||||
stringio = util.stringio | |||||
urlerr = util.urlerr | urlerr = util.urlerr | ||||
urlreq = util.urlreq | urlreq = util.urlreq | ||||
HTTP_OK = 200 | HTTP_OK = 200 | ||||
HGTYPE = b'application/mercurial-0.1' | HGTYPE = b'application/mercurial-0.1' | ||||
HGTYPE2 = b'application/mercurial-0.2' | HGTYPE2 = b'application/mercurial-0.2' | ||||
HGERRTYPE = b'application/hg-error' | HGERRTYPE = b'application/hg-error' | ||||
length -= int(self._req.headers.get(b'X-HgArgs-Post', 0)) | length -= int(self._req.headers.get(b'X-HgArgs-Post', 0)) | ||||
return util.filechunkiter(self._req.bodyfh, limit=length) | return util.filechunkiter(self._req.bodyfh, limit=length) | ||||
@contextlib.contextmanager | @contextlib.contextmanager | ||||
def mayberedirectstdio(self): | def mayberedirectstdio(self): | ||||
oldout = self._ui.fout | oldout = self._ui.fout | ||||
olderr = self._ui.ferr | olderr = self._ui.ferr | ||||
out = util.stringio() | out = io.BytesIO() | ||||
try: | try: | ||||
self._ui.fout = out | self._ui.fout = out | ||||
self._ui.ferr = out | self._ui.ferr = out | ||||
yield out | yield out | ||||
finally: | finally: | ||||
self._ui.fout = oldout | self._ui.fout = oldout | ||||
self._ui.ferr = olderr | self._ui.ferr = olderr |
This is unrelated and will probably break the current version of the CI (now that I think of it, I was supposed to figure out how to properly fix this annoyance last week and got sidetracked. I'll try to get to it this week.)