# HG changeset patch # User Gregory Szorc # Date 2018-04-13 19:31:34 # Node ID fe8c6f9f29149554da16825989566150b188932f # Parent 950294e2813662fd31468f6530977974f3f502cd 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 diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -3001,7 +3001,9 @@ def debugwireproto(ui, repo, path=None, 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': diff --git a/tests/test-http-protocol.t b/tests/test-http-protocol.t --- a/tests/test-http-protocol.t +++ b/tests/test-http-protocol.t @@ -211,7 +211,7 @@ Test listkeys for listing namespaces 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 @@ Client with HTTPv2 enabled advertises th 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 diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t --- a/tests/test-ssh-proto.t +++ b/tests/test-ssh-proto.t @@ -1367,7 +1367,7 @@ Test listkeys for listing namespaces 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 @@ Test listkeys for listing namespaces 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 @@ With no bookmarks set i> flush() -> None o> bufferedreadline() -> 2: o> 0\n - response: b'' + response: {} testing ssh2 creating ssh peer from handshake results @@ -1470,7 +1470,7 @@ With no bookmarks set i> flush() -> None o> bufferedreadline() -> 2: o> 0\n - response: b'' + response: {} With a single bookmark set @@ -1505,7 +1505,7 @@ With a single bookmark set 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 @@ With a single bookmark set 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 @@ With multiple bookmarks set 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 @@ With multiple bookmarks set 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 @@ Test pushkey for bookmarks 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 @@ Test pushkey for bookmarks 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 @@ Phases on empty repo 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 @@ Phases on empty repo 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 @@ Two draft heads 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 @@ Two draft heads 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 @@ Single draft head 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 @@ Single draft head 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 @@ All public heads 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 @@ All public heads 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 @@ Setting public phase via pushkey 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 @@ Setting public phase via pushkey o> 2\n o> bufferedread(2) -> 2: o> 1\n - response: b'1\n' + response: True $ hg phase . 4: public