tests/test-wireproto-command-filedata.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   $ cat > a << EOF
       
     7   > a0
       
     8   > 00000000000000000000000000000000000000
       
     9   > 11111111111111111111111111111111111111
       
    10   > EOF
       
    11   $ echo b0 > b
       
    12   $ mkdir -p dir0/child0 dir0/child1 dir1
       
    13   $ echo c0 > dir0/c
       
    14   $ echo d0 > dir0/d
       
    15   $ echo e0 > dir0/child0/e
       
    16   $ echo f0 > dir0/child1/f
       
    17   $ hg -q commit -A -m 'commit 0'
       
    18 
       
    19   $ echo a1 >> a
       
    20   $ echo d1 > dir0/d
       
    21   $ hg commit -m 'commit 1'
       
    22   $ echo f1 > dir0/child1/f
       
    23   $ hg commit -m 'commit 2'
       
    24 
       
    25   $ hg -q up -r 0
       
    26   $ echo a2 >> a
       
    27   $ hg commit -m 'commit 3'
       
    28   created new head
       
    29 
       
    30 Create multiple heads introducing the same changeset
       
    31 
       
    32   $ hg -q up -r 0
       
    33   $ echo foo > dupe-file
       
    34   $ hg commit -Am 'dupe 1'
       
    35   adding dupe-file
       
    36   created new head
       
    37   $ hg -q up -r 0
       
    38   $ echo foo > dupe-file
       
    39   $ hg commit -Am 'dupe 2'
       
    40   adding dupe-file
       
    41   created new head
       
    42 
       
    43   $ hg log -G -T '{rev}:{node} {desc}\n'
       
    44   @  5:732c3dd7bee94242de656000e5f458e7ccfe2828 dupe 2
       
    45   |
       
    46   | o  4:4334f10897d13c3e8beb4b636f7272b4ec2d0322 dupe 1
       
    47   |/
       
    48   | o  3:5ce944d7fece1252dae06c34422b573c191b9489 commit 3
       
    49   |/
       
    50   | o  2:b3c27db01410dae01e5485d425b1440078df540c commit 2
       
    51   | |
       
    52   | o  1:3ef5e551f219ba505481d34d6b0316b017fa3f00 commit 1
       
    53   |/
       
    54   o  0:91b232a2253ce0638496f67bdfd7a4933fb51b25 commit 0
       
    55   
       
    56 
       
    57   $ hg --debug debugindex a
       
    58      rev linkrev nodeid                                   p1                                       p2
       
    59        0       0 649d149df43d83882523b7fb1e6a3af6f1907b39 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
       
    60        1       1 0a86321f1379d1a9ecd0579a22977af7a5acaf11 649d149df43d83882523b7fb1e6a3af6f1907b39 0000000000000000000000000000000000000000
       
    61        2       3 7e5801b6d5f03a5a54f3c47b583f7567aad43e5b 649d149df43d83882523b7fb1e6a3af6f1907b39 0000000000000000000000000000000000000000
       
    62 
       
    63   $ hg --debug debugindex dir0/child0/e
       
    64      rev linkrev nodeid                                   p1                                       p2
       
    65        0       0 bbba6c06b30f443d34ff841bc985c4d0827c6be4 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
       
    66 
       
    67   $ hg --debug debugindex dupe-file
       
    68      rev linkrev nodeid                                   p1                                       p2
       
    69        0       4 2ed2a3912a0b24502043eae84ee4b279c18b90dd 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
       
    70 
       
    71   $ hg serve -p $HGPORT -d --pid-file hg.pid -E error.log
       
    72   $ cat hg.pid > $DAEMON_PIDS
       
    73 
       
    74 Missing arguments is an error
       
    75 
       
    76   $ sendhttpv2peer << EOF
       
    77   > command filedata
       
    78   > EOF
       
    79   creating http peer for wire protocol version 2
       
    80   sending filedata command
       
    81   abort: missing required arguments: nodes, path
       
    82   [255]
       
    83 
       
    84   $ sendhttpv2peer << EOF
       
    85   > command filedata
       
    86   >     nodes eval:[]
       
    87   > EOF
       
    88   creating http peer for wire protocol version 2
       
    89   sending filedata command
       
    90   abort: missing required arguments: path
       
    91   [255]
       
    92 
       
    93 Unknown node is an error
       
    94 
       
    95   $ sendhttpv2peer << EOF
       
    96   > command filedata
       
    97   >     nodes eval:[b'\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa']
       
    98   >     path eval:b'a'
       
    99   > EOF
       
   100   creating http peer for wire protocol version 2
       
   101   sending filedata command
       
   102   abort: unknown file node: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
       
   103   [255]
       
   104 
       
   105 Fetching a single revision returns just metadata by default
       
   106 
       
   107   $ sendhttpv2peer << EOF
       
   108   > command filedata
       
   109   >     nodes eval:[b'\x0a\x86\x32\x1f\x13\x79\xd1\xa9\xec\xd0\x57\x9a\x22\x97\x7a\xf7\xa5\xac\xaf\x11']
       
   110   >     path eval:b'a'
       
   111   > EOF
       
   112   creating http peer for wire protocol version 2
       
   113   sending filedata command
       
   114   response: gen[
       
   115     {
       
   116       b'totalitems': 1
       
   117     },
       
   118     {
       
   119       b'node': b'\n\x862\x1f\x13y\xd1\xa9\xec\xd0W\x9a"\x97z\xf7\xa5\xac\xaf\x11'
       
   120     }
       
   121   ]
       
   122 
       
   123 Requesting parents works
       
   124 
       
   125   $ sendhttpv2peer << EOF
       
   126   > command filedata
       
   127   >     nodes eval:[b'\x0a\x86\x32\x1f\x13\x79\xd1\xa9\xec\xd0\x57\x9a\x22\x97\x7a\xf7\xa5\xac\xaf\x11']
       
   128   >     path eval:b'a'
       
   129   >     fields eval:[b'parents']
       
   130   > EOF
       
   131   creating http peer for wire protocol version 2
       
   132   sending filedata command
       
   133   response: gen[
       
   134     {
       
   135       b'totalitems': 1
       
   136     },
       
   137     {
       
   138       b'node': b'\n\x862\x1f\x13y\xd1\xa9\xec\xd0W\x9a"\x97z\xf7\xa5\xac\xaf\x11',
       
   139       b'parents': [
       
   140         b'd\x9d\x14\x9d\xf4=\x83\x88%#\xb7\xfb\x1ej:\xf6\xf1\x90{9',
       
   141         b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
       
   142       ]
       
   143     }
       
   144   ]
       
   145 
       
   146 Requesting revision data works
       
   147 (haveparents defaults to False, so fulltext is emitted)
       
   148 
       
   149   $ sendhttpv2peer << EOF
       
   150   > command filedata
       
   151   >     nodes eval:[b'\x0a\x86\x32\x1f\x13\x79\xd1\xa9\xec\xd0\x57\x9a\x22\x97\x7a\xf7\xa5\xac\xaf\x11']
       
   152   >     path eval:b'a'
       
   153   >     fields eval:[b'revision']
       
   154   > EOF
       
   155   creating http peer for wire protocol version 2
       
   156   sending filedata command
       
   157   response: gen[
       
   158     {
       
   159       b'totalitems': 1
       
   160     },
       
   161     {
       
   162       b'fieldsfollowing': [
       
   163         [
       
   164           b'revision',
       
   165           84
       
   166         ]
       
   167       ],
       
   168       b'node': b'\n\x862\x1f\x13y\xd1\xa9\xec\xd0W\x9a"\x97z\xf7\xa5\xac\xaf\x11'
       
   169     },
       
   170     b'a0\n00000000000000000000000000000000000000\n11111111111111111111111111111111111111\na1\n'
       
   171   ]
       
   172 
       
   173 haveparents=False should be same as above
       
   174 
       
   175   $ sendhttpv2peer << EOF
       
   176   > command filedata
       
   177   >     nodes eval:[b'\x0a\x86\x32\x1f\x13\x79\xd1\xa9\xec\xd0\x57\x9a\x22\x97\x7a\xf7\xa5\xac\xaf\x11']
       
   178   >     path eval:b'a'
       
   179   >     fields eval:[b'revision']
       
   180   >     haveparents eval:False
       
   181   > EOF
       
   182   creating http peer for wire protocol version 2
       
   183   sending filedata command
       
   184   response: gen[
       
   185     {
       
   186       b'totalitems': 1
       
   187     },
       
   188     {
       
   189       b'fieldsfollowing': [
       
   190         [
       
   191           b'revision',
       
   192           84
       
   193         ]
       
   194       ],
       
   195       b'node': b'\n\x862\x1f\x13y\xd1\xa9\xec\xd0W\x9a"\x97z\xf7\xa5\xac\xaf\x11'
       
   196     },
       
   197     b'a0\n00000000000000000000000000000000000000\n11111111111111111111111111111111111111\na1\n'
       
   198   ]
       
   199 
       
   200 haveparents=True should emit a delta
       
   201 
       
   202   $ sendhttpv2peer << EOF
       
   203   > command filedata
       
   204   >     nodes eval:[b'\x0a\x86\x32\x1f\x13\x79\xd1\xa9\xec\xd0\x57\x9a\x22\x97\x7a\xf7\xa5\xac\xaf\x11']
       
   205   >     path eval:b'a'
       
   206   >     fields eval:[b'revision']
       
   207   >     haveparents eval:True
       
   208   > EOF
       
   209   creating http peer for wire protocol version 2
       
   210   sending filedata command
       
   211   response: gen[
       
   212     {
       
   213       b'totalitems': 1
       
   214     },
       
   215     {
       
   216       b'deltabasenode': b'd\x9d\x14\x9d\xf4=\x83\x88%#\xb7\xfb\x1ej:\xf6\xf1\x90{9',
       
   217       b'fieldsfollowing': [
       
   218         [
       
   219           b'delta',
       
   220           15
       
   221         ]
       
   222       ],
       
   223       b'node': b'\n\x862\x1f\x13y\xd1\xa9\xec\xd0W\x9a"\x97z\xf7\xa5\xac\xaf\x11'
       
   224     },
       
   225     b'\x00\x00\x00Q\x00\x00\x00Q\x00\x00\x00\x03a1\n'
       
   226   ]
       
   227 
       
   228 Requesting multiple revisions works
       
   229 (first revision is a fulltext since haveparents=False by default)
       
   230 
       
   231   $ sendhttpv2peer << EOF
       
   232   > command filedata
       
   233   >     nodes eval:[b'\x64\x9d\x14\x9d\xf4\x3d\x83\x88\x25\x23\xb7\xfb\x1e\x6a\x3a\xf6\xf1\x90\x7b\x39', b'\x0a\x86\x32\x1f\x13\x79\xd1\xa9\xec\xd0\x57\x9a\x22\x97\x7a\xf7\xa5\xac\xaf\x11']
       
   234   >     path eval:b'a'
       
   235   >     fields eval:[b'revision']
       
   236   > EOF
       
   237   creating http peer for wire protocol version 2
       
   238   sending filedata command
       
   239   response: gen[
       
   240     {
       
   241       b'totalitems': 2
       
   242     },
       
   243     {
       
   244       b'fieldsfollowing': [
       
   245         [
       
   246           b'revision',
       
   247           81
       
   248         ]
       
   249       ],
       
   250       b'node': b'd\x9d\x14\x9d\xf4=\x83\x88%#\xb7\xfb\x1ej:\xf6\xf1\x90{9'
       
   251     },
       
   252     b'a0\n00000000000000000000000000000000000000\n11111111111111111111111111111111111111\n',
       
   253     {
       
   254       b'deltabasenode': b'd\x9d\x14\x9d\xf4=\x83\x88%#\xb7\xfb\x1ej:\xf6\xf1\x90{9',
       
   255       b'fieldsfollowing': [
       
   256         [
       
   257           b'delta',
       
   258           15
       
   259         ]
       
   260       ],
       
   261       b'node': b'\n\x862\x1f\x13y\xd1\xa9\xec\xd0W\x9a"\x97z\xf7\xa5\xac\xaf\x11'
       
   262     },
       
   263     b'\x00\x00\x00Q\x00\x00\x00Q\x00\x00\x00\x03a1\n'
       
   264   ]
       
   265 
       
   266 Revisions are sorted by DAG order, parents first
       
   267 
       
   268   $ sendhttpv2peer << EOF
       
   269   > command filedata
       
   270   >     nodes eval:[b'\x0a\x86\x32\x1f\x13\x79\xd1\xa9\xec\xd0\x57\x9a\x22\x97\x7a\xf7\xa5\xac\xaf\x11', b'\x64\x9d\x14\x9d\xf4\x3d\x83\x88\x25\x23\xb7\xfb\x1e\x6a\x3a\xf6\xf1\x90\x7b\x39']
       
   271   >     path eval:b'a'
       
   272   >     fields eval:[b'revision']
       
   273   > EOF
       
   274   creating http peer for wire protocol version 2
       
   275   sending filedata command
       
   276   response: gen[
       
   277     {
       
   278       b'totalitems': 2
       
   279     },
       
   280     {
       
   281       b'fieldsfollowing': [
       
   282         [
       
   283           b'revision',
       
   284           81
       
   285         ]
       
   286       ],
       
   287       b'node': b'd\x9d\x14\x9d\xf4=\x83\x88%#\xb7\xfb\x1ej:\xf6\xf1\x90{9'
       
   288     },
       
   289     b'a0\n00000000000000000000000000000000000000\n11111111111111111111111111111111111111\n',
       
   290     {
       
   291       b'deltabasenode': b'd\x9d\x14\x9d\xf4=\x83\x88%#\xb7\xfb\x1ej:\xf6\xf1\x90{9',
       
   292       b'fieldsfollowing': [
       
   293         [
       
   294           b'delta',
       
   295           15
       
   296         ]
       
   297       ],
       
   298       b'node': b'\n\x862\x1f\x13y\xd1\xa9\xec\xd0W\x9a"\x97z\xf7\xa5\xac\xaf\x11'
       
   299     },
       
   300     b'\x00\x00\x00Q\x00\x00\x00Q\x00\x00\x00\x03a1\n'
       
   301   ]
       
   302 
       
   303 Requesting parents and revision data works
       
   304 
       
   305   $ sendhttpv2peer << EOF
       
   306   > command filedata
       
   307   >     nodes eval:[b'\x7e\x58\x01\xb6\xd5\xf0\x3a\x5a\x54\xf3\xc4\x7b\x58\x3f\x75\x67\xaa\xd4\x3e\x5b']
       
   308   >     path eval:b'a'
       
   309   >     fields eval:[b'parents', b'revision']
       
   310   > EOF
       
   311   creating http peer for wire protocol version 2
       
   312   sending filedata command
       
   313   response: gen[
       
   314     {
       
   315       b'totalitems': 1
       
   316     },
       
   317     {
       
   318       b'fieldsfollowing': [
       
   319         [
       
   320           b'revision',
       
   321           84
       
   322         ]
       
   323       ],
       
   324       b'node': b'~X\x01\xb6\xd5\xf0:ZT\xf3\xc4{X?ug\xaa\xd4>[',
       
   325       b'parents': [
       
   326         b'd\x9d\x14\x9d\xf4=\x83\x88%#\xb7\xfb\x1ej:\xf6\xf1\x90{9',
       
   327         b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
       
   328       ]
       
   329     },
       
   330     b'a0\n00000000000000000000000000000000000000\n11111111111111111111111111111111111111\na2\n'
       
   331   ]
       
   332 
       
   333 Linknode for duplicate revision is the initial revision
       
   334 
       
   335   $ sendhttpv2peer << EOF
       
   336   > command filedata
       
   337   >     nodes eval:[b'\x2e\xd2\xa3\x91\x2a\x0b\x24\x50\x20\x43\xea\xe8\x4e\xe4\xb2\x79\xc1\x8b\x90\xdd']
       
   338   >     path eval:b'dupe-file'
       
   339   >     fields eval:[b'linknode', b'parents', b'revision']
       
   340   > EOF
       
   341   creating http peer for wire protocol version 2
       
   342   sending filedata command
       
   343   response: gen[
       
   344     {
       
   345       b'totalitems': 1
       
   346     },
       
   347     {
       
   348       b'fieldsfollowing': [
       
   349         [
       
   350           b'revision',
       
   351           4
       
   352         ]
       
   353       ],
       
   354       b'linknode': b'C4\xf1\x08\x97\xd1<>\x8b\xebKcorr\xb4\xec-\x03"',
       
   355       b'node': b'.\xd2\xa3\x91*\x0b$P C\xea\xe8N\xe4\xb2y\xc1\x8b\x90\xdd',
       
   356       b'parents': [
       
   357         b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
       
   358         b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
       
   359       ]
       
   360     },
       
   361     b'foo\n'
       
   362   ]
       
   363 
       
   364   $ cat error.log