Show More
@@ -2629,6 +2629,21 b' def debugwireproto(ui, repo, **opts):' | |||
|
2629 | 2629 | Values are interpreted as Python b'' literals. This allows encoding |
|
2630 | 2630 | special byte sequences via backslash escaping. |
|
2631 | 2631 | |
|
2632 | batchbegin | |
|
2633 | ---------- | |
|
2634 | ||
|
2635 | Instruct the peer to begin a batched send. | |
|
2636 | ||
|
2637 | All ``command`` blocks are queued for execution until the next | |
|
2638 | ``batchsubmit`` block. | |
|
2639 | ||
|
2640 | batchsubmit | |
|
2641 | ----------- | |
|
2642 | ||
|
2643 | Submit previously queued ``command`` blocks as a batch request. | |
|
2644 | ||
|
2645 | This action MUST be paired with a ``batchbegin`` action. | |
|
2646 | ||
|
2632 | 2647 | close |
|
2633 | 2648 | ----- |
|
2634 | 2649 | |
@@ -2716,6 +2731,8 b' def debugwireproto(ui, repo, **opts):' | |||
|
2716 | 2731 | else: |
|
2717 | 2732 | raise error.Abort(_('only --localssh is currently supported')) |
|
2718 | 2733 | |
|
2734 | batchedcommands = None | |
|
2735 | ||
|
2719 | 2736 | # Now perform actions based on the parsed wire language instructions. |
|
2720 | 2737 | for action, lines in blocks: |
|
2721 | 2738 | if action in ('raw', 'raw+'): |
@@ -2747,10 +2764,29 b' def debugwireproto(ui, repo, **opts):' | |||
|
2747 | 2764 | |
|
2748 | 2765 | args[key] = util.unescapestr(value) |
|
2749 | 2766 | |
|
2767 | if batchedcommands is not None: | |
|
2768 | batchedcommands.append((command, args)) | |
|
2769 | continue | |
|
2770 | ||
|
2750 | 2771 | ui.status(_('sending %s command\n') % command) |
|
2751 | 2772 | res = peer._call(command, **args) |
|
2752 | 2773 | ui.status(_('response: %s\n') % util.escapedata(res)) |
|
2753 | 2774 | |
|
2775 | elif action == 'batchbegin': | |
|
2776 | if batchedcommands is not None: | |
|
2777 | raise error.Abort(_('nested batchbegin not allowed')) | |
|
2778 | ||
|
2779 | batchedcommands = [] | |
|
2780 | elif action == 'batchsubmit': | |
|
2781 | # There is a batching API we could go through. But it would be | |
|
2782 | # difficult to normalize requests into function calls. It is easier | |
|
2783 | # to bypass this layer and normalize to commands + args. | |
|
2784 | ui.status(_('sending batch with %d sub-commands\n') % | |
|
2785 | len(batchedcommands)) | |
|
2786 | for i, chunk in enumerate(peer._submitbatch(batchedcommands)): | |
|
2787 | ui.status(_('response #%d: %s\n') % (i, util.escapedata(chunk))) | |
|
2788 | ||
|
2789 | batchedcommands = None | |
|
2754 | 2790 | elif action == 'close': |
|
2755 | 2791 | peer.close() |
|
2756 | 2792 | elif action == 'readavailable': |
@@ -2765,6 +2801,9 b' def debugwireproto(ui, repo, **opts):' | |||
|
2765 | 2801 | else: |
|
2766 | 2802 | raise error.Abort(_('unknown action: %s') % action) |
|
2767 | 2803 | |
|
2804 | if batchedcommands is not None: | |
|
2805 | raise error.Abort(_('unclosed "batchbegin" request')) | |
|
2806 | ||
|
2768 | 2807 | if peer: |
|
2769 | 2808 | peer.close() |
|
2770 | 2809 |
@@ -1830,3 +1830,105 b' All public heads' | |||
|
1830 | 1830 | o> 15\n |
|
1831 | 1831 | o> bufferedread(15) -> 15: publishing True |
|
1832 | 1832 | response: publishing True |
|
1833 | ||
|
1834 | $ cd .. | |
|
1835 | ||
|
1836 | Test batching of requests | |
|
1837 | ||
|
1838 | $ hg init batching | |
|
1839 | $ cd batching | |
|
1840 | $ echo 0 > foo | |
|
1841 | $ hg add foo | |
|
1842 | $ hg -q commit -m initial | |
|
1843 | $ hg phase --public | |
|
1844 | $ echo 1 > foo | |
|
1845 | $ hg commit -m 'commit 1' | |
|
1846 | $ hg -q up 0 | |
|
1847 | $ echo 2 > foo | |
|
1848 | $ hg commit -m 'commit 2' | |
|
1849 | created new head | |
|
1850 | $ hg book -r 1 bookA | |
|
1851 | $ hg book -r 2 bookB | |
|
1852 | ||
|
1853 | $ debugwireproto << EOF | |
|
1854 | > batchbegin | |
|
1855 | > command heads | |
|
1856 | > command listkeys | |
|
1857 | > namespace bookmarks | |
|
1858 | > command listkeys | |
|
1859 | > namespace phases | |
|
1860 | > batchsubmit | |
|
1861 | > EOF | |
|
1862 | testing ssh1 | |
|
1863 | creating ssh peer from handshake results | |
|
1864 | i> write(104) -> None: | |
|
1865 | i> hello\n | |
|
1866 | i> between\n | |
|
1867 | i> pairs 81\n | |
|
1868 | i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000 | |
|
1869 | i> flush() -> None | |
|
1870 | o> readline() -> 4: | |
|
1871 | o> 384\n | |
|
1872 | o> readline() -> 384: | |
|
1873 | o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n | |
|
1874 | o> readline() -> 2: | |
|
1875 | o> 1\n | |
|
1876 | o> readline() -> 1: | |
|
1877 | o> \n | |
|
1878 | sending batch with 3 sub-commands | |
|
1879 | i> write(6) -> None: | |
|
1880 | i> batch\n | |
|
1881 | i> write(4) -> None: | |
|
1882 | i> * 0\n | |
|
1883 | i> write(8) -> None: | |
|
1884 | i> cmds 61\n | |
|
1885 | i> write(61) -> None: heads ;listkeys namespace=bookmarks;listkeys namespace=phases | |
|
1886 | i> flush() -> None | |
|
1887 | o> bufferedreadline() -> 4: | |
|
1888 | o> 278\n | |
|
1889 | o> bufferedread(278) -> 278: | |
|
1890 | o> bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n | |
|
1891 | o> ;bookA 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n | |
|
1892 | o> bookB bfebe6bd38eebc6f8202e419c1171268987ea6a6;4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab 1\n | |
|
1893 | o> bfebe6bd38eebc6f8202e419c1171268987ea6a6 1\n | |
|
1894 | o> publishing True | |
|
1895 | response #0: bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n | |
|
1896 | response #1: bookA 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\nbookB bfebe6bd38eebc6f8202e419c1171268987ea6a6 | |
|
1897 | response #2: 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab 1\nbfebe6bd38eebc6f8202e419c1171268987ea6a6 1\npublishing True | |
|
1898 | ||
|
1899 | testing ssh2 | |
|
1900 | creating ssh peer from handshake results | |
|
1901 | i> write(171) -> None: | |
|
1902 | i> upgrade * proto=exp-ssh-v2-0001\n (glob) | |
|
1903 | i> hello\n | |
|
1904 | i> between\n | |
|
1905 | i> pairs 81\n | |
|
1906 | i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000 | |
|
1907 | i> flush() -> None | |
|
1908 | o> readline() -> 62: | |
|
1909 | o> upgraded * exp-ssh-v2-0001\n (glob) | |
|
1910 | o> readline() -> 4: | |
|
1911 | o> 383\n | |
|
1912 | o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN | |
|
1913 | o> read(1) -> 1: | |
|
1914 | o> \n | |
|
1915 | sending batch with 3 sub-commands | |
|
1916 | i> write(6) -> None: | |
|
1917 | i> batch\n | |
|
1918 | i> write(4) -> None: | |
|
1919 | i> * 0\n | |
|
1920 | i> write(8) -> None: | |
|
1921 | i> cmds 61\n | |
|
1922 | i> write(61) -> None: heads ;listkeys namespace=bookmarks;listkeys namespace=phases | |
|
1923 | i> flush() -> None | |
|
1924 | o> bufferedreadline() -> 4: | |
|
1925 | o> 278\n | |
|
1926 | o> bufferedread(278) -> 278: | |
|
1927 | o> bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n | |
|
1928 | o> ;bookA 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n | |
|
1929 | o> bookB bfebe6bd38eebc6f8202e419c1171268987ea6a6;4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab 1\n | |
|
1930 | o> bfebe6bd38eebc6f8202e419c1171268987ea6a6 1\n | |
|
1931 | o> publishing True | |
|
1932 | response #0: bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n | |
|
1933 | response #1: bookA 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\nbookB bfebe6bd38eebc6f8202e419c1171268987ea6a6 | |
|
1934 | response #2: 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab 1\nbfebe6bd38eebc6f8202e419c1171268987ea6a6 1\npublishing True |
General Comments 0
You need to be logged in to leave comments.
Login now