Patchwork D3298: debugcommands: use command executor for invoking commands

login
register
mail settings
Submitter phabricator
Date April 12, 2018, 8 p.m.
Message ID <differential-rev-PHID-DREV-t4o3fd73kkxnkqc6i3lu-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30832/
State Superseded
Headers show

Comments

phabricator - April 12, 2018, 8 p.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3298

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-http-protocol.t
  tests/test-ssh-proto.t

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

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 @@ 
   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
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 @@ 
   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
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2994,7 +2994,10 @@ 
                     ui.status(_('remote output: %s\n') %
                               stringutil.escapestr(output))
             else:
-                res = peer._call(command, **pycompat.strkwargs(args))
+                with peer.commandexecutor() as e:
+                    f = e.callcommand(command, args)
+
+                res = f.result()
                 ui.status(_('response: %s\n') % stringutil.pprint(res))
 
         elif action == 'batchbegin':