Mercurial > hg
changeset 37652:fe8c6f9f2914
debugcommands: use command executor for invoking commands
Now that all peers support the command executor interface, we
can use it in place of peer._call() (which isn't part of the public
API).
Tests changed because we are now returning the decoded response
instead of the raw bytes. The raw bytes over the wire are already
logged. So we're not losing any test coverage. In fact, we're adding
test coverage because we're testing decoding of those command
responses as well.
Differential Revision: https://phab.mercurial-scm.org/D3298
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 13 Apr 2018 12:31:34 -0700 |
parents | 950294e28136 |
children | b2fa1591fb44 |
files | mercurial/debugcommands.py tests/test-http-protocol.t tests/test-ssh-proto.t |
diffstat | 3 files changed, 25 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Fri Apr 13 12:30:04 2018 -0700 +++ b/mercurial/debugcommands.py Fri Apr 13 12:31:34 2018 -0700 @@ -3001,7 +3001,9 @@ ui.status(_('remote output: %s\n') % stringutil.escapestr(output)) else: - res = peer._call(command, **pycompat.strkwargs(args)) + with peer.commandexecutor() as e: + res = e.callcommand(command, args).result() + ui.status(_('response: %s\n') % stringutil.pprint(res)) elif action == 'batchbegin':
--- a/tests/test-http-protocol.t Fri Apr 13 12:30:04 2018 -0700 +++ b/tests/test-http-protocol.t Fri Apr 13 12:31:34 2018 -0700 @@ -211,7 +211,7 @@ s> bookmarks\t\n s> namespaces\t\n s> phases\t - response: b'bookmarks\t\nnamespaces\t\nphases\t' + response: {b'bookmarks': b'', b'namespaces': b'', b'phases': b''} Same thing, but with "httprequest" command @@ -277,7 +277,7 @@ s> Content-Length: 41\r\n s> \r\n s> 0000000000000000000000000000000000000000\n - response: b'0000000000000000000000000000000000000000\n' + response: [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'] $ killdaemons.py $ enablehttpv2 empty
--- a/tests/test-ssh-proto.t Fri Apr 13 12:30:04 2018 -0700 +++ b/tests/test-ssh-proto.t Fri Apr 13 12:31:34 2018 -0700 @@ -1367,7 +1367,7 @@ o> bookmarks\t\n o> namespaces\t\n o> phases\t - response: b'bookmarks\t\nnamespaces\t\nphases\t' + response: {b'bookmarks': b'', b'namespaces': b'', b'phases': b''} testing ssh2 creating ssh peer from handshake results @@ -1398,7 +1398,7 @@ o> bookmarks\t\n o> namespaces\t\n o> phases\t - response: b'bookmarks\t\nnamespaces\t\nphases\t' + response: {b'bookmarks': b'', b'namespaces': b'', b'phases': b''} $ cd .. @@ -1443,7 +1443,7 @@ i> flush() -> None o> bufferedreadline() -> 2: o> 0\n - response: b'' + response: {} testing ssh2 creating ssh peer from handshake results @@ -1470,7 +1470,7 @@ i> flush() -> None o> bufferedreadline() -> 2: o> 0\n - response: b'' + response: {} With a single bookmark set @@ -1505,7 +1505,7 @@ o> bufferedreadline() -> 3: o> 46\n o> bufferedread(46) -> 46: bookA\t68986213bd4485ea51533535e3fc9e78007a711f - response: b'bookA\t68986213bd4485ea51533535e3fc9e78007a711f' + response: {b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f'} testing ssh2 creating ssh peer from handshake results @@ -1533,7 +1533,7 @@ o> bufferedreadline() -> 3: o> 46\n o> bufferedread(46) -> 46: bookA\t68986213bd4485ea51533535e3fc9e78007a711f - response: b'bookA\t68986213bd4485ea51533535e3fc9e78007a711f' + response: {b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f'} With multiple bookmarks set @@ -1570,7 +1570,7 @@ o> bufferedread(93) -> 93: o> bookA\t68986213bd4485ea51533535e3fc9e78007a711f\n o> bookB\t1880f3755e2e52e3199e0ee5638128b08642f34d - response: b'bookA\t68986213bd4485ea51533535e3fc9e78007a711f\nbookB\t1880f3755e2e52e3199e0ee5638128b08642f34d' + response: {b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f', b'bookB': b'1880f3755e2e52e3199e0ee5638128b08642f34d'} testing ssh2 creating ssh peer from handshake results @@ -1600,7 +1600,7 @@ o> bufferedread(93) -> 93: o> bookA\t68986213bd4485ea51533535e3fc9e78007a711f\n o> bookB\t1880f3755e2e52e3199e0ee5638128b08642f34d - response: b'bookA\t68986213bd4485ea51533535e3fc9e78007a711f\nbookB\t1880f3755e2e52e3199e0ee5638128b08642f34d' + response: {b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f', b'bookB': b'1880f3755e2e52e3199e0ee5638128b08642f34d'} Test pushkey for bookmarks @@ -1646,7 +1646,7 @@ o> 2\n o> bufferedread(2) -> 2: o> 1\n - response: b'1\n' + response: True testing ssh2 creating ssh peer from handshake results @@ -1683,7 +1683,7 @@ o> 2\n o> bufferedread(2) -> 2: o> 1\n - response: b'1\n' + response: True $ hg bookmarks bookA 0:68986213bd44 @@ -1729,7 +1729,7 @@ o> bufferedreadline() -> 3: o> 15\n o> bufferedread(15) -> 15: publishing\tTrue - response: b'publishing\tTrue' + response: {b'publishing': b'True'} testing ssh2 creating ssh peer from handshake results @@ -1757,7 +1757,7 @@ o> bufferedreadline() -> 3: o> 15\n o> bufferedread(15) -> 15: publishing\tTrue - response: b'publishing\tTrue' + response: {b'publishing': b'True'} Create some commits @@ -1811,7 +1811,7 @@ o> 20b8a89289d80036e6c4e87c2083e3bea1586637\t1\n o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n o> publishing\tTrue - response: b'20b8a89289d80036e6c4e87c2083e3bea1586637\t1\nc4750011d906c18ea2f0527419cbc1a544435150\t1\npublishing\tTrue' + response: {b'20b8a89289d80036e6c4e87c2083e3bea1586637': b'1', b'c4750011d906c18ea2f0527419cbc1a544435150': b'1', b'publishing': b'True'} testing ssh2 creating ssh peer from handshake results @@ -1842,7 +1842,7 @@ o> 20b8a89289d80036e6c4e87c2083e3bea1586637\t1\n o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n o> publishing\tTrue - response: b'20b8a89289d80036e6c4e87c2083e3bea1586637\t1\nc4750011d906c18ea2f0527419cbc1a544435150\t1\npublishing\tTrue' + response: {b'20b8a89289d80036e6c4e87c2083e3bea1586637': b'1', b'c4750011d906c18ea2f0527419cbc1a544435150': b'1', b'publishing': b'True'} Single draft head @@ -1879,7 +1879,7 @@ o> bufferedread(58) -> 58: o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n o> publishing\tTrue - response: b'c4750011d906c18ea2f0527419cbc1a544435150\t1\npublishing\tTrue' + response: {b'c4750011d906c18ea2f0527419cbc1a544435150': b'1', b'publishing': b'True'} testing ssh2 creating ssh peer from handshake results @@ -1909,7 +1909,7 @@ o> bufferedread(58) -> 58: o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n o> publishing\tTrue - response: b'c4750011d906c18ea2f0527419cbc1a544435150\t1\npublishing\tTrue' + response: {b'c4750011d906c18ea2f0527419cbc1a544435150': b'1', b'publishing': b'True'} All public heads @@ -1944,7 +1944,7 @@ o> bufferedreadline() -> 3: o> 15\n o> bufferedread(15) -> 15: publishing\tTrue - response: b'publishing\tTrue' + response: {b'publishing': b'True'} testing ssh2 creating ssh peer from handshake results @@ -1972,7 +1972,7 @@ o> bufferedreadline() -> 3: o> 15\n o> bufferedread(15) -> 15: publishing\tTrue - response: b'publishing\tTrue' + response: {b'publishing': b'True'} Setting public phase via pushkey @@ -2021,7 +2021,7 @@ o> 2\n o> bufferedread(2) -> 2: o> 1\n - response: b'1\n' + response: True testing ssh2 creating ssh peer from handshake results @@ -2059,7 +2059,7 @@ o> 2\n o> bufferedread(2) -> 2: o> 1\n - response: b'1\n' + response: True $ hg phase . 4: public