D2987: stringutil: add function to pretty print an object
This revision was automatically updated to reflect the committed changes. Closed by commit rHG2f859ad7ed8c: stringutil: add function to pretty print an object (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2987?vs=7450=7561 REVISION DETAIL https://phab.mercurial-scm.org/D2987 AFFECTED FILES mercurial/debugcommands.py mercurial/utils/stringutil.py tests/test-http-protocol.t tests/test-ssh-proto.t CHANGE DETAILS 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 @@ -1345,7 +1345,7 @@ o> bookmarks \n o> namespaces\n o> phases - response: bookmarks \nnamespaces\nphases + response: b'bookmarks\nnamespaces\nphases' testing ssh2 creating ssh peer from handshake results @@ -1376,7 +1376,7 @@ o> bookmarks \n o> namespaces\n o> phases - response: bookmarks \nnamespaces\nphases + response: b'bookmarks\nnamespaces\nphases' $ cd .. @@ -1421,7 +1421,7 @@ i> flush() -> None o> bufferedreadline() -> 2: o> 0\n - response: + response: b'' testing ssh2 creating ssh peer from handshake results @@ -1448,7 +1448,7 @@ i> flush() -> None o> bufferedreadline() -> 2: o> 0\n - response: + response: b'' With a single bookmark set @@ -1483,7 +1483,7 @@ o> bufferedreadline() -> 3: o> 46\n o> bufferedread(46) -> 46: bookA 68986213bd4485ea51533535e3fc9e78007a711f - response: bookA 68986213bd4485ea51533535e3fc9e78007a711f + response: b'bookA68986213bd4485ea51533535e3fc9e78007a711f' testing ssh2 creating ssh peer from handshake results @@ -1511,7 +1511,7 @@ o> bufferedreadline() -> 3: o> 46\n o> bufferedread(46) -> 46: bookA 68986213bd4485ea51533535e3fc9e78007a711f - response: bookA 68986213bd4485ea51533535e3fc9e78007a711f + response: b'bookA68986213bd4485ea51533535e3fc9e78007a711f' With multiple bookmarks set @@ -1548,7 +1548,7 @@ o> bufferedread(93) -> 93: o> bookA 68986213bd4485ea51533535e3fc9e78007a711f\n o> bookB 1880f3755e2e52e3199e0ee5638128b08642f34d - response: bookA 68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d + response: b'bookA68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d' testing ssh2 creating ssh peer from handshake results @@ -1578,7 +1578,7 @@ o> bufferedread(93) -> 93: o> bookA 68986213bd4485ea51533535e3fc9e78007a711f\n o> bookB 1880f3755e2e52e3199e0ee5638128b08642f34d - response: bookA 68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d + response: b'bookA68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d' Test pushkey for bookmarks @@ -1624,7 +1624,7 @@ o> 2\n o> bufferedread(2) -> 2: o> 1\n - response: 1\n + response: b'1\n' testing ssh2 creating ssh peer from handshake results @@ -1661,7 +1661,7 @@ o> 2\n o> bufferedread(2) -> 2: o> 1\n - response: 1\n + response: b'1\n' $ hg bookmarks bookA 0:68986213bd44 @@ -1707,7 +1707,7 @@ o> bufferedreadline() -> 3: o> 15\n o> bufferedread(15) -> 15: publishingTrue - response: publishing True + response: b'publishing True' testing ssh2 creating ssh peer from handshake results @@ -1735,7 +1735,7 @@ o> bufferedreadline() -> 3: o> 15\n o> bufferedread(15) -> 15: publishingTrue - response: publishing True + response: b'publishing True' Create some commits @@ -1789,7 +1789,7 @@ o> 20b8a89289d80036e6c4e87c2083e3bea1586637 1\n o> c4750011d906c18ea2f0527419cbc1a544435150 1\n o> publishingTrue - response: 20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True + response: b'20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True' testing ssh2 creating ssh peer from handshake results @@ -1820,7 +1820,7 @@ o> 20b8a89289d80036e6c4e87c2083e3bea1586637 1\n o> c4750011d906c18ea2f0527419cbc1a544435150 1\n o> publishingTrue - response: 20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True + response: b'20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True' Single draft head @@ -1857,7 +1857,7 @@ o> bufferedread(58) -> 58: o> c4750011d906c18ea2f0527419cbc1a544435150 1\n o> publishingTrue - response: c4750011d906c18ea2f0527419cbc1a544435150
D2987: stringutil: add function to pretty print an object
durin42 added inline comments. INLINE COMMENTS > indygreg wrote in stringutil.py:39 > Because of differences with `b''` in Python 3 :/ REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2987 To: indygreg, #hg-reviewers Cc: durin42, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2987: stringutil: add function to pretty print an object
indygreg added inline comments. INLINE COMMENTS > durin42 wrote in stringutil.py:39 > Why this instead of pprint.pformat? Because of differences with `b''` in Python 3 :/ REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2987 To: indygreg, #hg-reviewers Cc: durin42, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2987: stringutil: add function to pretty print an object
durin42 added inline comments. INLINE COMMENTS > stringutil.py:39 > > +def pprint(o): > +"""Pretty print an object.""" Why this instead of pprint.pformat? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2987 To: indygreg, #hg-reviewers Cc: durin42, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2987: stringutil: add function to pretty print an object
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This is inspired by the pprint() module/function (which we can't use because the output is different on Python 2 and 3 - namely the use of b'' literals). We hook it up to `hg debugwireproto` for printing the response to a wire protocol command. This foreshadows future peer work, which will support decoding CBOR responses into rich data structures. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2987 AFFECTED FILES mercurial/debugcommands.py mercurial/utils/stringutil.py tests/test-http-protocol.t tests/test-ssh-proto.t CHANGE DETAILS 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 @@ -1345,7 +1345,7 @@ o> bookmarks \n o> namespaces\n o> phases - response: bookmarks \nnamespaces\nphases + response: b'bookmarks\nnamespaces\nphases' testing ssh2 creating ssh peer from handshake results @@ -1376,7 +1376,7 @@ o> bookmarks \n o> namespaces\n o> phases - response: bookmarks \nnamespaces\nphases + response: b'bookmarks\nnamespaces\nphases' $ cd .. @@ -1421,7 +1421,7 @@ i> flush() -> None o> bufferedreadline() -> 2: o> 0\n - response: + response: b'' testing ssh2 creating ssh peer from handshake results @@ -1448,7 +1448,7 @@ i> flush() -> None o> bufferedreadline() -> 2: o> 0\n - response: + response: b'' With a single bookmark set @@ -1483,7 +1483,7 @@ o> bufferedreadline() -> 3: o> 46\n o> bufferedread(46) -> 46: bookA 68986213bd4485ea51533535e3fc9e78007a711f - response: bookA 68986213bd4485ea51533535e3fc9e78007a711f + response: b'bookA68986213bd4485ea51533535e3fc9e78007a711f' testing ssh2 creating ssh peer from handshake results @@ -1511,7 +1511,7 @@ o> bufferedreadline() -> 3: o> 46\n o> bufferedread(46) -> 46: bookA 68986213bd4485ea51533535e3fc9e78007a711f - response: bookA 68986213bd4485ea51533535e3fc9e78007a711f + response: b'bookA68986213bd4485ea51533535e3fc9e78007a711f' With multiple bookmarks set @@ -1548,7 +1548,7 @@ o> bufferedread(93) -> 93: o> bookA 68986213bd4485ea51533535e3fc9e78007a711f\n o> bookB 1880f3755e2e52e3199e0ee5638128b08642f34d - response: bookA 68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d + response: b'bookA68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d' testing ssh2 creating ssh peer from handshake results @@ -1578,7 +1578,7 @@ o> bufferedread(93) -> 93: o> bookA 68986213bd4485ea51533535e3fc9e78007a711f\n o> bookB 1880f3755e2e52e3199e0ee5638128b08642f34d - response: bookA 68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d + response: b'bookA68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d' Test pushkey for bookmarks @@ -1624,7 +1624,7 @@ o> 2\n o> bufferedread(2) -> 2: o> 1\n - response: 1\n + response: b'1\n' testing ssh2 creating ssh peer from handshake results @@ -1661,7 +1661,7 @@ o> 2\n o> bufferedread(2) -> 2: o> 1\n - response: 1\n + response: b'1\n' $ hg bookmarks bookA 0:68986213bd44 @@ -1707,7 +1707,7 @@ o> bufferedreadline() -> 3: o> 15\n o> bufferedread(15) -> 15: publishingTrue - response: publishing True + response: b'publishing True' testing ssh2 creating ssh peer from handshake results @@ -1735,7 +1735,7 @@ o> bufferedreadline() -> 3: o> 15\n o> bufferedread(15) -> 15: publishingTrue - response: publishing True + response: b'publishing True' Create some commits @@ -1789,7 +1789,7 @@ o> 20b8a89289d80036e6c4e87c2083e3bea1586637 1\n o> c4750011d906c18ea2f0527419cbc1a544435150 1\n o> publishingTrue - response: 20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True + response: b'20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True' testing ssh2 creating ssh peer from handshake results @@ -1820,7 +1820,7 @@ o> 20b8a89289d80036e6c4e87c2083e3bea1586637 1\n o> c4750011d906c18ea2f0527419cbc1a544435150 1\n o> publishingTrue - response: 20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True + response: b'20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing