tests/test-wireproto-command-manifestdata.t
changeset 48526 04688c51f81f
parent 48525 d6c53b40b078
child 48527 bf5dc156bb4c
equal deleted inserted replaced
48525:d6c53b40b078 48526:04688c51f81f
     1   $ . $TESTDIR/wireprotohelpers.sh
       
     2 
       
     3   $ hg init server
       
     4   $ enablehttpv2 server
       
     5   $ cd server
       
     6   $ echo a0 > a
       
     7   $ echo b0 > b
       
     8   $ mkdir -p dir0/child0 dir0/child1 dir1
       
     9   $ echo c0 > dir0/c
       
    10   $ echo d0 > dir0/d
       
    11   $ echo e0 > dir0/child0/e
       
    12   $ echo f0 > dir0/child1/f
       
    13   $ hg -q commit -A -m 'commit 0'
       
    14 
       
    15   $ echo a1 > a
       
    16   $ echo d1 > dir0/d
       
    17   $ hg commit -m 'commit 1'
       
    18   $ echo f0 > dir0/child1/f
       
    19   $ hg commit -m 'commit 2'
       
    20   nothing changed
       
    21   [1]
       
    22 
       
    23   $ hg -q up -r 0
       
    24   $ echo a2 > a
       
    25   $ hg commit -m 'commit 3'
       
    26   created new head
       
    27 
       
    28   $ hg log -G -T '{rev}:{node} {desc}\n'
       
    29   @  2:c8757a2ffe552850d1e0dfe60d295ebf64c196d9 commit 3
       
    30   |
       
    31   | o  1:650165e803375748a94df471e5b58d85763e0b29 commit 1
       
    32   |/
       
    33   o  0:6d85ca1270b377d320098556ba5bfad34a9ee12d commit 0
       
    34   
       
    35 
       
    36   $ hg --debug debugindex -m
       
    37      rev linkrev nodeid                                   p1                                       p2
       
    38        0       0 1b175b595f022cfab5b809cc0ed551bd0b3ff5e4 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
       
    39        1       1 91e0bdbfb0dde0023fa063edc1445f207a22eac7 1b175b595f022cfab5b809cc0ed551bd0b3ff5e4 0000000000000000000000000000000000000000
       
    40        2       2 46a6721b5edaf0ea04b79a5cb3218854a4d2aba0 1b175b595f022cfab5b809cc0ed551bd0b3ff5e4 0000000000000000000000000000000000000000
       
    41 
       
    42   $ hg serve -p $HGPORT -d --pid-file hg.pid -E error.log
       
    43   $ cat hg.pid > $DAEMON_PIDS
       
    44 
       
    45 Missing arguments is an error
       
    46 
       
    47   $ sendhttpv2peer << EOF
       
    48   > command manifestdata
       
    49   > EOF
       
    50   creating http peer for wire protocol version 2
       
    51   sending manifestdata command
       
    52   abort: missing required arguments: nodes, tree
       
    53   [255]
       
    54 
       
    55   $ sendhttpv2peer << EOF
       
    56   > command manifestdata
       
    57   >     nodes eval:[]
       
    58   > EOF
       
    59   creating http peer for wire protocol version 2
       
    60   sending manifestdata command
       
    61   abort: missing required arguments: tree
       
    62   [255]
       
    63 
       
    64 Unknown node is an error
       
    65 
       
    66   $ sendhttpv2peer << EOF
       
    67   > command manifestdata
       
    68   >     nodes eval:[b'\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa']
       
    69   >     tree eval:b''
       
    70   > EOF
       
    71   creating http peer for wire protocol version 2
       
    72   sending manifestdata command
       
    73   abort: unknown node: \xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa (esc)
       
    74   [255]
       
    75 
       
    76 Fetching a single revision returns just metadata by default
       
    77 
       
    78   $ sendhttpv2peer << EOF
       
    79   > command manifestdata
       
    80   >     nodes eval:[b'\x46\xa6\x72\x1b\x5e\xda\xf0\xea\x04\xb7\x9a\x5c\xb3\x21\x88\x54\xa4\xd2\xab\xa0']
       
    81   >     tree eval:b''
       
    82   > EOF
       
    83   creating http peer for wire protocol version 2
       
    84   sending manifestdata command
       
    85   response: gen[
       
    86     {
       
    87       b'totalitems': 1
       
    88     },
       
    89     {
       
    90       b'node': b'F\xa6r\x1b^\xda\xf0\xea\x04\xb7\x9a\\\xb3!\x88T\xa4\xd2\xab\xa0'
       
    91     }
       
    92   ]
       
    93 
       
    94 Requesting parents works
       
    95 
       
    96   $ sendhttpv2peer << EOF
       
    97   > command manifestdata
       
    98   >     nodes eval:[b'\x46\xa6\x72\x1b\x5e\xda\xf0\xea\x04\xb7\x9a\x5c\xb3\x21\x88\x54\xa4\xd2\xab\xa0']
       
    99   >     tree eval:b''
       
   100   >     fields eval:[b'parents']
       
   101   > EOF
       
   102   creating http peer for wire protocol version 2
       
   103   sending manifestdata command
       
   104   response: gen[
       
   105     {
       
   106       b'totalitems': 1
       
   107     },
       
   108     {
       
   109       b'node': b'F\xa6r\x1b^\xda\xf0\xea\x04\xb7\x9a\\\xb3!\x88T\xa4\xd2\xab\xa0',
       
   110       b'parents': [
       
   111         b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4',
       
   112         b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
       
   113       ]
       
   114     }
       
   115   ]
       
   116 
       
   117 Requesting revision data works
       
   118 (haveparents defaults to false, so fulltext is emitted)
       
   119 
       
   120   $ sendhttpv2peer << EOF
       
   121   > command manifestdata
       
   122   >     nodes eval:[b'\x46\xa6\x72\x1b\x5e\xda\xf0\xea\x04\xb7\x9a\x5c\xb3\x21\x88\x54\xa4\xd2\xab\xa0']
       
   123   >     tree eval:b''
       
   124   >     fields eval:[b'revision']
       
   125   > EOF
       
   126   creating http peer for wire protocol version 2
       
   127   sending manifestdata command
       
   128   response: gen[
       
   129     {
       
   130       b'totalitems': 1
       
   131     },
       
   132     {
       
   133       b'fieldsfollowing': [
       
   134         [
       
   135           b'revision',
       
   136           292
       
   137         ]
       
   138       ],
       
   139       b'node': b'F\xa6r\x1b^\xda\xf0\xea\x04\xb7\x9a\\\xb3!\x88T\xa4\xd2\xab\xa0'
       
   140     },
       
   141     b'a\x000879345e39377229634b420c639454156726c6b6\nb\x00819e258d31a5e1606629f365bb902a1b21ee4216\ndir0/c\x00914445346a0ca0629bd47ceb5dfe07e4d4cf2501\ndir0/child0/e\x00bbba6c06b30f443d34ff841bc985c4d0827c6be4\ndir0/child1/f\x0012fc7dcd773b5a0a929ce195228083c6ddc9cec4\ndir0/d\x00538206dc971e521540d6843abfe6d16032f6d426\n'
       
   142   ]
       
   143 
       
   144 haveparents=False yields same output
       
   145 
       
   146   $ sendhttpv2peer << EOF
       
   147   > command manifestdata
       
   148   >     nodes eval:[b'\x46\xa6\x72\x1b\x5e\xda\xf0\xea\x04\xb7\x9a\x5c\xb3\x21\x88\x54\xa4\xd2\xab\xa0']
       
   149   >     tree eval:b''
       
   150   >     fields eval:[b'revision']
       
   151   >     haveparents eval:False
       
   152   > EOF
       
   153   creating http peer for wire protocol version 2
       
   154   sending manifestdata command
       
   155   response: gen[
       
   156     {
       
   157       b'totalitems': 1
       
   158     },
       
   159     {
       
   160       b'fieldsfollowing': [
       
   161         [
       
   162           b'revision',
       
   163           292
       
   164         ]
       
   165       ],
       
   166       b'node': b'F\xa6r\x1b^\xda\xf0\xea\x04\xb7\x9a\\\xb3!\x88T\xa4\xd2\xab\xa0'
       
   167     },
       
   168     b'a\x000879345e39377229634b420c639454156726c6b6\nb\x00819e258d31a5e1606629f365bb902a1b21ee4216\ndir0/c\x00914445346a0ca0629bd47ceb5dfe07e4d4cf2501\ndir0/child0/e\x00bbba6c06b30f443d34ff841bc985c4d0827c6be4\ndir0/child1/f\x0012fc7dcd773b5a0a929ce195228083c6ddc9cec4\ndir0/d\x00538206dc971e521540d6843abfe6d16032f6d426\n'
       
   169   ]
       
   170 
       
   171 haveparents=True will emit delta
       
   172 
       
   173   $ sendhttpv2peer << EOF
       
   174   > command manifestdata
       
   175   >     nodes eval:[b'\x46\xa6\x72\x1b\x5e\xda\xf0\xea\x04\xb7\x9a\x5c\xb3\x21\x88\x54\xa4\xd2\xab\xa0']
       
   176   >     tree eval:b''
       
   177   >     fields eval:[b'revision']
       
   178   >     haveparents eval:True
       
   179   > EOF
       
   180   creating http peer for wire protocol version 2
       
   181   sending manifestdata command
       
   182   response: gen[
       
   183     {
       
   184       b'totalitems': 1
       
   185     },
       
   186     {
       
   187       b'deltabasenode': b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4',
       
   188       b'fieldsfollowing': [
       
   189         [
       
   190           b'delta',
       
   191           55
       
   192         ]
       
   193       ],
       
   194       b'node': b'F\xa6r\x1b^\xda\xf0\xea\x04\xb7\x9a\\\xb3!\x88T\xa4\xd2\xab\xa0'
       
   195     },
       
   196     b'\x00\x00\x00\x00\x00\x00\x00+\x00\x00\x00+a\x000879345e39377229634b420c639454156726c6b6\n'
       
   197   ]
       
   198 
       
   199 Requesting multiple revisions works
       
   200 (haveparents defaults to false, so fulltext is emitted unless a parent
       
   201 has been emitted)
       
   202 
       
   203   $ sendhttpv2peer << EOF
       
   204   > command manifestdata
       
   205   >     nodes eval:[b'\x1b\x17\x5b\x59\x5f\x02\x2c\xfa\xb5\xb8\x09\xcc\x0e\xd5\x51\xbd\x0b\x3f\xf5\xe4', b'\x46\xa6\x72\x1b\x5e\xda\xf0\xea\x04\xb7\x9a\x5c\xb3\x21\x88\x54\xa4\xd2\xab\xa0']
       
   206   >     tree eval:b''
       
   207   >     fields eval:[b'revision']
       
   208   > EOF
       
   209   creating http peer for wire protocol version 2
       
   210   sending manifestdata command
       
   211   response: gen[
       
   212     {
       
   213       b'totalitems': 2
       
   214     },
       
   215     {
       
   216       b'fieldsfollowing': [
       
   217         [
       
   218           b'revision',
       
   219           292
       
   220         ]
       
   221       ],
       
   222       b'node': b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4'
       
   223     },
       
   224     b'a\x002b4eb07319bfa077a40a2f04913659aef0da42da\nb\x00819e258d31a5e1606629f365bb902a1b21ee4216\ndir0/c\x00914445346a0ca0629bd47ceb5dfe07e4d4cf2501\ndir0/child0/e\x00bbba6c06b30f443d34ff841bc985c4d0827c6be4\ndir0/child1/f\x0012fc7dcd773b5a0a929ce195228083c6ddc9cec4\ndir0/d\x00538206dc971e521540d6843abfe6d16032f6d426\n',
       
   225     {
       
   226       b'deltabasenode': b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4',
       
   227       b'fieldsfollowing': [
       
   228         [
       
   229           b'delta',
       
   230           55
       
   231         ]
       
   232       ],
       
   233       b'node': b'F\xa6r\x1b^\xda\xf0\xea\x04\xb7\x9a\\\xb3!\x88T\xa4\xd2\xab\xa0'
       
   234     },
       
   235     b'\x00\x00\x00\x00\x00\x00\x00+\x00\x00\x00+a\x000879345e39377229634b420c639454156726c6b6\n'
       
   236   ]
       
   237 
       
   238 With haveparents=True, first revision is a delta instead of fulltext
       
   239 
       
   240   $ sendhttpv2peer << EOF
       
   241   > command manifestdata
       
   242   >     nodes eval:[b'\x1b\x17\x5b\x59\x5f\x02\x2c\xfa\xb5\xb8\x09\xcc\x0e\xd5\x51\xbd\x0b\x3f\xf5\xe4', b'\x46\xa6\x72\x1b\x5e\xda\xf0\xea\x04\xb7\x9a\x5c\xb3\x21\x88\x54\xa4\xd2\xab\xa0']
       
   243   >     tree eval:b''
       
   244   >     fields eval:[b'revision']
       
   245   >     haveparents eval:True
       
   246   > EOF
       
   247   creating http peer for wire protocol version 2
       
   248   sending manifestdata command
       
   249   response: gen[
       
   250     {
       
   251       b'totalitems': 2
       
   252     },
       
   253     {
       
   254       b'fieldsfollowing': [
       
   255         [
       
   256           b'revision',
       
   257           292
       
   258         ]
       
   259       ],
       
   260       b'node': b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4'
       
   261     },
       
   262     b'a\x002b4eb07319bfa077a40a2f04913659aef0da42da\nb\x00819e258d31a5e1606629f365bb902a1b21ee4216\ndir0/c\x00914445346a0ca0629bd47ceb5dfe07e4d4cf2501\ndir0/child0/e\x00bbba6c06b30f443d34ff841bc985c4d0827c6be4\ndir0/child1/f\x0012fc7dcd773b5a0a929ce195228083c6ddc9cec4\ndir0/d\x00538206dc971e521540d6843abfe6d16032f6d426\n',
       
   263     {
       
   264       b'deltabasenode': b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4',
       
   265       b'fieldsfollowing': [
       
   266         [
       
   267           b'delta',
       
   268           55
       
   269         ]
       
   270       ],
       
   271       b'node': b'F\xa6r\x1b^\xda\xf0\xea\x04\xb7\x9a\\\xb3!\x88T\xa4\xd2\xab\xa0'
       
   272     },
       
   273     b'\x00\x00\x00\x00\x00\x00\x00+\x00\x00\x00+a\x000879345e39377229634b420c639454156726c6b6\n'
       
   274   ]
       
   275 
       
   276 Revisions are sorted by DAG order, parents first
       
   277 
       
   278   $ sendhttpv2peer << EOF
       
   279   > command manifestdata
       
   280   >     nodes eval:[b'\x46\xa6\x72\x1b\x5e\xda\xf0\xea\x04\xb7\x9a\x5c\xb3\x21\x88\x54\xa4\xd2\xab\xa0', b'\x1b\x17\x5b\x59\x5f\x02\x2c\xfa\xb5\xb8\x09\xcc\x0e\xd5\x51\xbd\x0b\x3f\xf5\xe4']
       
   281   >     tree eval:b''
       
   282   >     fields eval:[b'revision']
       
   283   > EOF
       
   284   creating http peer for wire protocol version 2
       
   285   sending manifestdata command
       
   286   response: gen[
       
   287     {
       
   288       b'totalitems': 2
       
   289     },
       
   290     {
       
   291       b'fieldsfollowing': [
       
   292         [
       
   293           b'revision',
       
   294           292
       
   295         ]
       
   296       ],
       
   297       b'node': b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4'
       
   298     },
       
   299     b'a\x002b4eb07319bfa077a40a2f04913659aef0da42da\nb\x00819e258d31a5e1606629f365bb902a1b21ee4216\ndir0/c\x00914445346a0ca0629bd47ceb5dfe07e4d4cf2501\ndir0/child0/e\x00bbba6c06b30f443d34ff841bc985c4d0827c6be4\ndir0/child1/f\x0012fc7dcd773b5a0a929ce195228083c6ddc9cec4\ndir0/d\x00538206dc971e521540d6843abfe6d16032f6d426\n',
       
   300     {
       
   301       b'deltabasenode': b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4',
       
   302       b'fieldsfollowing': [
       
   303         [
       
   304           b'delta',
       
   305           55
       
   306         ]
       
   307       ],
       
   308       b'node': b'F\xa6r\x1b^\xda\xf0\xea\x04\xb7\x9a\\\xb3!\x88T\xa4\xd2\xab\xa0'
       
   309     },
       
   310     b'\x00\x00\x00\x00\x00\x00\x00+\x00\x00\x00+a\x000879345e39377229634b420c639454156726c6b6\n'
       
   311   ]
       
   312 
       
   313 Requesting parents and revision data works
       
   314 
       
   315   $ sendhttpv2peer << EOF
       
   316   > command manifestdata
       
   317   >     nodes eval:[b'\x1b\x17\x5b\x59\x5f\x02\x2c\xfa\xb5\xb8\x09\xcc\x0e\xd5\x51\xbd\x0b\x3f\xf5\xe4', b'\x46\xa6\x72\x1b\x5e\xda\xf0\xea\x04\xb7\x9a\x5c\xb3\x21\x88\x54\xa4\xd2\xab\xa0']
       
   318   >     tree eval:b''
       
   319   >     fields eval:[b'parents', b'revision']
       
   320   > EOF
       
   321   creating http peer for wire protocol version 2
       
   322   sending manifestdata command
       
   323   response: gen[
       
   324     {
       
   325       b'totalitems': 2
       
   326     },
       
   327     {
       
   328       b'fieldsfollowing': [
       
   329         [
       
   330           b'revision',
       
   331           292
       
   332         ]
       
   333       ],
       
   334       b'node': b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4',
       
   335       b'parents': [
       
   336         b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
       
   337         b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
       
   338       ]
       
   339     },
       
   340     b'a\x002b4eb07319bfa077a40a2f04913659aef0da42da\nb\x00819e258d31a5e1606629f365bb902a1b21ee4216\ndir0/c\x00914445346a0ca0629bd47ceb5dfe07e4d4cf2501\ndir0/child0/e\x00bbba6c06b30f443d34ff841bc985c4d0827c6be4\ndir0/child1/f\x0012fc7dcd773b5a0a929ce195228083c6ddc9cec4\ndir0/d\x00538206dc971e521540d6843abfe6d16032f6d426\n',
       
   341     {
       
   342       b'deltabasenode': b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4',
       
   343       b'fieldsfollowing': [
       
   344         [
       
   345           b'delta',
       
   346           55
       
   347         ]
       
   348       ],
       
   349       b'node': b'F\xa6r\x1b^\xda\xf0\xea\x04\xb7\x9a\\\xb3!\x88T\xa4\xd2\xab\xa0',
       
   350       b'parents': [
       
   351         b'\x1b\x17[Y_\x02,\xfa\xb5\xb8\t\xcc\x0e\xd5Q\xbd\x0b?\xf5\xe4',
       
   352         b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
       
   353       ]
       
   354     },
       
   355     b'\x00\x00\x00\x00\x00\x00\x00+\x00\x00\x00+a\x000879345e39377229634b420c639454156726c6b6\n'
       
   356   ]
       
   357 
       
   358   $ cat error.log