Mercurial > hg
view tests/test-ui-color.py @ 40133:762ef19a07e3
wireprotov2: send protocol settings frame from client
Now that we have client and server reactor support for protocol
settings and encoding frames, we can start to send them out over
the wire!
This commit teaches the client reactor to send out a protocol
settings frame when needed. The httpv2 peer has been taught to
gather a list of supported content encoders and to advertise them
through the client reactor.
Because the client is now sending new frame types by default, this
constitutes a compatibility break in the framing protocol. The
media type version has been bumped accordingly. This will ensure
existing clients won't attempt to send the new frames to old
servers not supporting this explicit media type. I'm not bothering
with the BC annotation because everything wireprotov2 is highly
experimental and nobody should be running a server yet.
Differential Revision: https://phab.mercurial-scm.org/D4922
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 08 Oct 2018 17:00:16 -0700 |
parents | 32bc3815efae |
children | 2372284d9457 |
line wrap: on
line source
from __future__ import absolute_import, print_function import os from mercurial import ( dispatch, ui as uimod, ) from mercurial.utils import ( stringutil, ) # ensure errors aren't buffered testui = uimod.ui() testui.pushbuffer() testui.write((b'buffered\n')) testui.warn((b'warning\n')) testui.write_err(b'error\n') print(stringutil.pprint(testui.popbuffer(), bprefix=True).decode('ascii')) # test dispatch.dispatch with the same ui object hgrc = open(os.environ["HGRCPATH"], 'wb') hgrc.write(b'[extensions]\n') hgrc.write(b'color=\n') hgrc.close() ui_ = uimod.ui.load() ui_.setconfig(b'ui', b'formatted', b'True') # we're not interested in the output, so write that to devnull ui_.fout = open(os.devnull, 'wb') # call some arbitrary command just so we go through # color's wrapped _runcommand twice. def runcmd(): dispatch.dispatch(dispatch.request([b'version', b'-q'], ui_)) runcmd() print("colored? %s" % (ui_._colormode is not None)) runcmd() print("colored? %s" % (ui_._colormode is not None))