Mercurial > hg > mercurial-source
comparison tests/test-commandserver.t @ 41375:054d0fcba2c4
commandserver: add experimental option to use separate message channel
This is loosely based on the idea of the TortoiseHg's pipeui extension,
which attaches ui.label to message text so the command-server client can
capture prompt text, for example.
https://bitbucket.org/tortoisehg/thg/src/4.7.2/tortoisehg/util/pipeui.py
I was thinking that this functionality could be generalized to templating,
but changed mind as doing template stuff would be unnecessarily complex.
It's merely a status message, a simple serialization option should suffice.
Since this slightly changes the command-server protocol, it's gated by a
config knob. If the config is enabled, and if it's supported by the server,
"message-encoding: <name>" is advertised so the client can stop parsing
'o'/'e' channel data and read encoded messages from the 'm' channel. As we
might add new message encodings in future releases, client can specify a list
of encoding names in preferred order.
This patch includes 'cbor' encoding as example. Perhaps, 'json' should be
supported as well.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 18 Jan 2015 18:49:59 +0900 |
parents | d6b6f1b441cf |
children | 83dd8c63a0c6 |
comparison
equal
deleted
inserted
replaced
41374:9683dfb6f13a | 41375:054d0fcba2c4 |
---|---|
722 abort: repository ../nonexistent not found! | 722 abort: repository ../nonexistent not found! |
723 [255] | 723 [255] |
724 $ cd .. | 724 $ cd .. |
725 | 725 |
726 | 726 |
727 structured message channel: | |
728 | |
729 $ cat <<'EOF' >> repo2/.hg/hgrc | |
730 > [ui] | |
731 > # server --config should precede repository option | |
732 > message-output = stdio | |
733 > EOF | |
734 | |
735 >>> from hgclient import bprint, checkwith, readchannel, runcommand | |
736 >>> @checkwith(extraargs=[b'--config', b'ui.message-output=channel', | |
737 ... b'--config', b'cmdserver.message-encodings=foo cbor']) | |
738 ... def verify(server): | |
739 ... _ch, data = readchannel(server) | |
740 ... bprint(data) | |
741 ... runcommand(server, [b'-R', b'repo2', b'verify']) | |
742 capabilities: getencoding runcommand | |
743 encoding: ascii | |
744 message-encoding: cbor | |
745 pid: * (glob) | |
746 pgid: * (glob) | |
747 *** runcommand -R repo2 verify | |
748 message: '\xa2DdataTchecking changesets\nElabelJ ui.status' | |
749 message: '\xa2DdataSchecking manifests\nElabelJ ui.status' | |
750 message: '\xa2DdataX0crosschecking files in changesets and manifests\nElabelJ ui.status' | |
751 message: '\xa2DdataOchecking files\nElabelJ ui.status' | |
752 message: '\xa2DdataX/checked 0 changesets with 0 changes to 0 files\nElabelJ ui.status' | |
753 | |
754 bad message encoding: | |
755 | |
756 $ hg serve --cmdserver pipe --config ui.message-output=channel | |
757 abort: no supported message encodings: | |
758 [255] | |
759 $ hg serve --cmdserver pipe --config ui.message-output=channel \ | |
760 > --config cmdserver.message-encodings='foo bar' | |
761 abort: no supported message encodings: foo bar | |
762 [255] | |
763 | |
727 unix domain socket: | 764 unix domain socket: |
728 | 765 |
729 $ cd repo | 766 $ cd repo |
730 $ hg update -q | 767 $ hg update -q |
731 | 768 |