Mercurial > hg
comparison tests/test-ssh-proto.t @ 37300:2f859ad7ed8c
stringutil: add function to pretty print an object
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.
Differential Revision: https://phab.mercurial-scm.org/D2987
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 28 Mar 2018 14:52:57 -0700 |
parents | 27527d8cff5c |
children | a67fd1fe5109 |
comparison
equal
deleted
inserted
replaced
37299:e9aadee698cf | 37300:2f859ad7ed8c |
---|---|
1343 o> 30\n | 1343 o> 30\n |
1344 o> bufferedread(30) -> 30: | 1344 o> bufferedread(30) -> 30: |
1345 o> bookmarks \n | 1345 o> bookmarks \n |
1346 o> namespaces \n | 1346 o> namespaces \n |
1347 o> phases | 1347 o> phases |
1348 response: bookmarks \nnamespaces \nphases | 1348 response: b'bookmarks \nnamespaces \nphases ' |
1349 | 1349 |
1350 testing ssh2 | 1350 testing ssh2 |
1351 creating ssh peer from handshake results | 1351 creating ssh peer from handshake results |
1352 i> write(171) -> 171: | 1352 i> write(171) -> 171: |
1353 i> upgrade * proto=exp-ssh-v2-0001\n (glob) | 1353 i> upgrade * proto=exp-ssh-v2-0001\n (glob) |
1374 o> 30\n | 1374 o> 30\n |
1375 o> bufferedread(30) -> 30: | 1375 o> bufferedread(30) -> 30: |
1376 o> bookmarks \n | 1376 o> bookmarks \n |
1377 o> namespaces \n | 1377 o> namespaces \n |
1378 o> phases | 1378 o> phases |
1379 response: bookmarks \nnamespaces \nphases | 1379 response: b'bookmarks \nnamespaces \nphases ' |
1380 | 1380 |
1381 $ cd .. | 1381 $ cd .. |
1382 | 1382 |
1383 Test listkeys for bookmarks | 1383 Test listkeys for bookmarks |
1384 | 1384 |
1419 i> namespace 9\n | 1419 i> namespace 9\n |
1420 i> write(9) -> 9: bookmarks | 1420 i> write(9) -> 9: bookmarks |
1421 i> flush() -> None | 1421 i> flush() -> None |
1422 o> bufferedreadline() -> 2: | 1422 o> bufferedreadline() -> 2: |
1423 o> 0\n | 1423 o> 0\n |
1424 response: | 1424 response: b'' |
1425 | 1425 |
1426 testing ssh2 | 1426 testing ssh2 |
1427 creating ssh peer from handshake results | 1427 creating ssh peer from handshake results |
1428 i> write(171) -> 171: | 1428 i> write(171) -> 171: |
1429 i> upgrade * proto=exp-ssh-v2-0001\n (glob) | 1429 i> upgrade * proto=exp-ssh-v2-0001\n (glob) |
1446 i> namespace 9\n | 1446 i> namespace 9\n |
1447 i> write(9) -> 9: bookmarks | 1447 i> write(9) -> 9: bookmarks |
1448 i> flush() -> None | 1448 i> flush() -> None |
1449 o> bufferedreadline() -> 2: | 1449 o> bufferedreadline() -> 2: |
1450 o> 0\n | 1450 o> 0\n |
1451 response: | 1451 response: b'' |
1452 | 1452 |
1453 With a single bookmark set | 1453 With a single bookmark set |
1454 | 1454 |
1455 $ hg book -r 0 bookA | 1455 $ hg book -r 0 bookA |
1456 $ debugwireproto << EOF | 1456 $ debugwireproto << EOF |
1481 i> write(9) -> 9: bookmarks | 1481 i> write(9) -> 9: bookmarks |
1482 i> flush() -> None | 1482 i> flush() -> None |
1483 o> bufferedreadline() -> 3: | 1483 o> bufferedreadline() -> 3: |
1484 o> 46\n | 1484 o> 46\n |
1485 o> bufferedread(46) -> 46: bookA 68986213bd4485ea51533535e3fc9e78007a711f | 1485 o> bufferedread(46) -> 46: bookA 68986213bd4485ea51533535e3fc9e78007a711f |
1486 response: bookA 68986213bd4485ea51533535e3fc9e78007a711f | 1486 response: b'bookA 68986213bd4485ea51533535e3fc9e78007a711f' |
1487 | 1487 |
1488 testing ssh2 | 1488 testing ssh2 |
1489 creating ssh peer from handshake results | 1489 creating ssh peer from handshake results |
1490 i> write(171) -> 171: | 1490 i> write(171) -> 171: |
1491 i> upgrade * proto=exp-ssh-v2-0001\n (glob) | 1491 i> upgrade * proto=exp-ssh-v2-0001\n (glob) |
1509 i> write(9) -> 9: bookmarks | 1509 i> write(9) -> 9: bookmarks |
1510 i> flush() -> None | 1510 i> flush() -> None |
1511 o> bufferedreadline() -> 3: | 1511 o> bufferedreadline() -> 3: |
1512 o> 46\n | 1512 o> 46\n |
1513 o> bufferedread(46) -> 46: bookA 68986213bd4485ea51533535e3fc9e78007a711f | 1513 o> bufferedread(46) -> 46: bookA 68986213bd4485ea51533535e3fc9e78007a711f |
1514 response: bookA 68986213bd4485ea51533535e3fc9e78007a711f | 1514 response: b'bookA 68986213bd4485ea51533535e3fc9e78007a711f' |
1515 | 1515 |
1516 With multiple bookmarks set | 1516 With multiple bookmarks set |
1517 | 1517 |
1518 $ hg book -r 1 bookB | 1518 $ hg book -r 1 bookB |
1519 $ debugwireproto << EOF | 1519 $ debugwireproto << EOF |
1546 o> bufferedreadline() -> 3: | 1546 o> bufferedreadline() -> 3: |
1547 o> 93\n | 1547 o> 93\n |
1548 o> bufferedread(93) -> 93: | 1548 o> bufferedread(93) -> 93: |
1549 o> bookA 68986213bd4485ea51533535e3fc9e78007a711f\n | 1549 o> bookA 68986213bd4485ea51533535e3fc9e78007a711f\n |
1550 o> bookB 1880f3755e2e52e3199e0ee5638128b08642f34d | 1550 o> bookB 1880f3755e2e52e3199e0ee5638128b08642f34d |
1551 response: bookA 68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d | 1551 response: b'bookA 68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d' |
1552 | 1552 |
1553 testing ssh2 | 1553 testing ssh2 |
1554 creating ssh peer from handshake results | 1554 creating ssh peer from handshake results |
1555 i> write(171) -> 171: | 1555 i> write(171) -> 171: |
1556 i> upgrade * proto=exp-ssh-v2-0001\n (glob) | 1556 i> upgrade * proto=exp-ssh-v2-0001\n (glob) |
1576 o> bufferedreadline() -> 3: | 1576 o> bufferedreadline() -> 3: |
1577 o> 93\n | 1577 o> 93\n |
1578 o> bufferedread(93) -> 93: | 1578 o> bufferedread(93) -> 93: |
1579 o> bookA 68986213bd4485ea51533535e3fc9e78007a711f\n | 1579 o> bookA 68986213bd4485ea51533535e3fc9e78007a711f\n |
1580 o> bookB 1880f3755e2e52e3199e0ee5638128b08642f34d | 1580 o> bookB 1880f3755e2e52e3199e0ee5638128b08642f34d |
1581 response: bookA 68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d | 1581 response: b'bookA 68986213bd4485ea51533535e3fc9e78007a711f\nbookB 1880f3755e2e52e3199e0ee5638128b08642f34d' |
1582 | 1582 |
1583 Test pushkey for bookmarks | 1583 Test pushkey for bookmarks |
1584 | 1584 |
1585 $ debugwireproto << EOF | 1585 $ debugwireproto << EOF |
1586 > command pushkey | 1586 > command pushkey |
1622 i> flush() -> None | 1622 i> flush() -> None |
1623 o> bufferedreadline() -> 2: | 1623 o> bufferedreadline() -> 2: |
1624 o> 2\n | 1624 o> 2\n |
1625 o> bufferedread(2) -> 2: | 1625 o> bufferedread(2) -> 2: |
1626 o> 1\n | 1626 o> 1\n |
1627 response: 1\n | 1627 response: b'1\n' |
1628 | 1628 |
1629 testing ssh2 | 1629 testing ssh2 |
1630 creating ssh peer from handshake results | 1630 creating ssh peer from handshake results |
1631 i> write(171) -> 171: | 1631 i> write(171) -> 171: |
1632 i> upgrade * proto=exp-ssh-v2-0001\n (glob) | 1632 i> upgrade * proto=exp-ssh-v2-0001\n (glob) |
1659 i> flush() -> None | 1659 i> flush() -> None |
1660 o> bufferedreadline() -> 2: | 1660 o> bufferedreadline() -> 2: |
1661 o> 2\n | 1661 o> 2\n |
1662 o> bufferedread(2) -> 2: | 1662 o> bufferedread(2) -> 2: |
1663 o> 1\n | 1663 o> 1\n |
1664 response: 1\n | 1664 response: b'1\n' |
1665 | 1665 |
1666 $ hg bookmarks | 1666 $ hg bookmarks |
1667 bookA 0:68986213bd44 | 1667 bookA 0:68986213bd44 |
1668 bookB 1:1880f3755e2e | 1668 bookB 1:1880f3755e2e |
1669 remote 0:68986213bd44 | 1669 remote 0:68986213bd44 |
1705 i> write(6) -> 6: phases | 1705 i> write(6) -> 6: phases |
1706 i> flush() -> None | 1706 i> flush() -> None |
1707 o> bufferedreadline() -> 3: | 1707 o> bufferedreadline() -> 3: |
1708 o> 15\n | 1708 o> 15\n |
1709 o> bufferedread(15) -> 15: publishing True | 1709 o> bufferedread(15) -> 15: publishing True |
1710 response: publishing True | 1710 response: b'publishing True' |
1711 | 1711 |
1712 testing ssh2 | 1712 testing ssh2 |
1713 creating ssh peer from handshake results | 1713 creating ssh peer from handshake results |
1714 i> write(171) -> 171: | 1714 i> write(171) -> 171: |
1715 i> upgrade * proto=exp-ssh-v2-0001\n (glob) | 1715 i> upgrade * proto=exp-ssh-v2-0001\n (glob) |
1733 i> write(6) -> 6: phases | 1733 i> write(6) -> 6: phases |
1734 i> flush() -> None | 1734 i> flush() -> None |
1735 o> bufferedreadline() -> 3: | 1735 o> bufferedreadline() -> 3: |
1736 o> 15\n | 1736 o> 15\n |
1737 o> bufferedread(15) -> 15: publishing True | 1737 o> bufferedread(15) -> 15: publishing True |
1738 response: publishing True | 1738 response: b'publishing True' |
1739 | 1739 |
1740 Create some commits | 1740 Create some commits |
1741 | 1741 |
1742 $ echo 0 > foo | 1742 $ echo 0 > foo |
1743 $ hg add foo | 1743 $ hg add foo |
1787 o> 101\n | 1787 o> 101\n |
1788 o> bufferedread(101) -> 101: | 1788 o> bufferedread(101) -> 101: |
1789 o> 20b8a89289d80036e6c4e87c2083e3bea1586637 1\n | 1789 o> 20b8a89289d80036e6c4e87c2083e3bea1586637 1\n |
1790 o> c4750011d906c18ea2f0527419cbc1a544435150 1\n | 1790 o> c4750011d906c18ea2f0527419cbc1a544435150 1\n |
1791 o> publishing True | 1791 o> publishing True |
1792 response: 20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True | 1792 response: b'20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True' |
1793 | 1793 |
1794 testing ssh2 | 1794 testing ssh2 |
1795 creating ssh peer from handshake results | 1795 creating ssh peer from handshake results |
1796 i> write(171) -> 171: | 1796 i> write(171) -> 171: |
1797 i> upgrade * proto=exp-ssh-v2-0001\n (glob) | 1797 i> upgrade * proto=exp-ssh-v2-0001\n (glob) |
1818 o> 101\n | 1818 o> 101\n |
1819 o> bufferedread(101) -> 101: | 1819 o> bufferedread(101) -> 101: |
1820 o> 20b8a89289d80036e6c4e87c2083e3bea1586637 1\n | 1820 o> 20b8a89289d80036e6c4e87c2083e3bea1586637 1\n |
1821 o> c4750011d906c18ea2f0527419cbc1a544435150 1\n | 1821 o> c4750011d906c18ea2f0527419cbc1a544435150 1\n |
1822 o> publishing True | 1822 o> publishing True |
1823 response: 20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True | 1823 response: b'20b8a89289d80036e6c4e87c2083e3bea1586637 1\nc4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True' |
1824 | 1824 |
1825 Single draft head | 1825 Single draft head |
1826 | 1826 |
1827 $ hg phase --public -r 2 | 1827 $ hg phase --public -r 2 |
1828 $ debugwireproto << EOF | 1828 $ debugwireproto << EOF |
1855 o> bufferedreadline() -> 3: | 1855 o> bufferedreadline() -> 3: |
1856 o> 58\n | 1856 o> 58\n |
1857 o> bufferedread(58) -> 58: | 1857 o> bufferedread(58) -> 58: |
1858 o> c4750011d906c18ea2f0527419cbc1a544435150 1\n | 1858 o> c4750011d906c18ea2f0527419cbc1a544435150 1\n |
1859 o> publishing True | 1859 o> publishing True |
1860 response: c4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True | 1860 response: b'c4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True' |
1861 | 1861 |
1862 testing ssh2 | 1862 testing ssh2 |
1863 creating ssh peer from handshake results | 1863 creating ssh peer from handshake results |
1864 i> write(171) -> 171: | 1864 i> write(171) -> 171: |
1865 i> upgrade * proto=exp-ssh-v2-0001\n (glob) | 1865 i> upgrade * proto=exp-ssh-v2-0001\n (glob) |
1885 o> bufferedreadline() -> 3: | 1885 o> bufferedreadline() -> 3: |
1886 o> 58\n | 1886 o> 58\n |
1887 o> bufferedread(58) -> 58: | 1887 o> bufferedread(58) -> 58: |
1888 o> c4750011d906c18ea2f0527419cbc1a544435150 1\n | 1888 o> c4750011d906c18ea2f0527419cbc1a544435150 1\n |
1889 o> publishing True | 1889 o> publishing True |
1890 response: c4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True | 1890 response: b'c4750011d906c18ea2f0527419cbc1a544435150 1\npublishing True' |
1891 | 1891 |
1892 All public heads | 1892 All public heads |
1893 | 1893 |
1894 $ hg phase --public -r 4 | 1894 $ hg phase --public -r 4 |
1895 $ debugwireproto << EOF | 1895 $ debugwireproto << EOF |
1920 i> write(6) -> 6: phases | 1920 i> write(6) -> 6: phases |
1921 i> flush() -> None | 1921 i> flush() -> None |
1922 o> bufferedreadline() -> 3: | 1922 o> bufferedreadline() -> 3: |
1923 o> 15\n | 1923 o> 15\n |
1924 o> bufferedread(15) -> 15: publishing True | 1924 o> bufferedread(15) -> 15: publishing True |
1925 response: publishing True | 1925 response: b'publishing True' |
1926 | 1926 |
1927 testing ssh2 | 1927 testing ssh2 |
1928 creating ssh peer from handshake results | 1928 creating ssh peer from handshake results |
1929 i> write(171) -> 171: | 1929 i> write(171) -> 171: |
1930 i> upgrade * proto=exp-ssh-v2-0001\n (glob) | 1930 i> upgrade * proto=exp-ssh-v2-0001\n (glob) |
1948 i> write(6) -> 6: phases | 1948 i> write(6) -> 6: phases |
1949 i> flush() -> None | 1949 i> flush() -> None |
1950 o> bufferedreadline() -> 3: | 1950 o> bufferedreadline() -> 3: |
1951 o> 15\n | 1951 o> 15\n |
1952 o> bufferedread(15) -> 15: publishing True | 1952 o> bufferedread(15) -> 15: publishing True |
1953 response: publishing True | 1953 response: b'publishing True' |
1954 | 1954 |
1955 Setting public phase via pushkey | 1955 Setting public phase via pushkey |
1956 | 1956 |
1957 $ hg phase --draft --force -r . | 1957 $ hg phase --draft --force -r . |
1958 | 1958 |
1997 i> flush() -> None | 1997 i> flush() -> None |
1998 o> bufferedreadline() -> 2: | 1998 o> bufferedreadline() -> 2: |
1999 o> 2\n | 1999 o> 2\n |
2000 o> bufferedread(2) -> 2: | 2000 o> bufferedread(2) -> 2: |
2001 o> 1\n | 2001 o> 1\n |
2002 response: 1\n | 2002 response: b'1\n' |
2003 | 2003 |
2004 testing ssh2 | 2004 testing ssh2 |
2005 creating ssh peer from handshake results | 2005 creating ssh peer from handshake results |
2006 i> write(171) -> 171: | 2006 i> write(171) -> 171: |
2007 i> upgrade * proto=exp-ssh-v2-0001\n (glob) | 2007 i> upgrade * proto=exp-ssh-v2-0001\n (glob) |
2035 i> flush() -> None | 2035 i> flush() -> None |
2036 o> bufferedreadline() -> 2: | 2036 o> bufferedreadline() -> 2: |
2037 o> 2\n | 2037 o> 2\n |
2038 o> bufferedread(2) -> 2: | 2038 o> bufferedread(2) -> 2: |
2039 o> 1\n | 2039 o> 1\n |
2040 response: 1\n | 2040 response: b'1\n' |
2041 | 2041 |
2042 $ hg phase . | 2042 $ hg phase . |
2043 4: public | 2043 4: public |
2044 | 2044 |
2045 $ cd .. | 2045 $ cd .. |