diff tests/test-wireproto-command-filesdata.t @ 40922:ca6372b7e566

tests: add tests for server-side linknode adjustment with wireprotov2 The current implementation of linknode serving in wireprotov2 simply serves up the linkrev/linknode as stored: it doesn't attempt to adjust the linknode to what the receiver is aware of. This can result in the client seeing a linknode referencing a changeset that is unknown to it. This commit adds test coverage of that scenario. The tests in test-wireproto-command-filesdata.t demonstrate two failures. First, the linknode refers to a changeset not in the available set. Second, the server doesn't send a file revision that it should have (because of linkrev filtering). The test in test-wireproto-exchange.t demonstrates that the lack of a file revision results in a corrupted repository on the client. Differential Revision: https://phab.mercurial-scm.org/D5404
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 10 Dec 2018 17:26:12 +0000
parents abbd077965c0
children 3ed77780f4a6
line wrap: on
line diff
--- a/tests/test-wireproto-command-filesdata.t	Mon Dec 10 16:53:09 2018 +0000
+++ b/tests/test-wireproto-command-filesdata.t	Mon Dec 10 17:26:12 2018 +0000
@@ -34,9 +34,26 @@
   $ hg commit -m 'commit 3'
   created new head
 
+Create multiple heads introducing the same file nodefile node
+
+  $ hg -q up -r 0
+  $ echo foo > dupe-file
+  $ hg commit -Am 'dupe 1'
+  adding dupe-file
+  created new head
+  $ hg -q up -r 0
+  $ echo foo > dupe-file
+  $ hg commit -Am 'dupe 2'
+  adding dupe-file
+  created new head
+
   $ hg log -G -T '{rev}:{node} {desc}\n'
-  @  3:476fbf122cd82f6726f0191ff146f67140946abc commit 3
+  @  5:47fc30580911232cb264675b402819deddf6c6f0 dupe 2
   |
+  | o  4:b16cce2967c1749ef4f4e3086a806cfbad8a3af7 dupe 1
+  |/
+  | o  3:476fbf122cd82f6726f0191ff146f67140946abc commit 3
+  |/
   | o  2:b91c03cbba3519ab149b6cd0a0afbdb5cf1b5c8a commit 2
   | |
   | o  1:5b0b1a23577e205ea240e39c9704e28d7697cbd8 commit 1
@@ -1161,4 +1178,116 @@
     }
   ]
 
+Test behavior where a file node is introduced in 2 DAG heads
+
+Request for changeset introducing filenode returns linknode as self
+
+  $ sendhttpv2peer << EOF
+  > command filesdata
+  >     revisions eval:[{
+  >         b'type': b'changesetexplicit',
+  >         b'nodes': [
+  >             b'\xb1\x6c\xce\x29\x67\xc1\x74\x9e\xf4\xf4\xe3\x08\x6a\x80\x6c\xfb\xad\x8a\x3a\xf7',
+  >         ]}]
+  >     fields eval:[b'linknode']
+  >     pathfilter eval:{b'include': [b'path:dupe-file']}
+  > EOF
+  creating http peer for wire protocol version 2
+  sending filesdata command
+  response: gen[
+    {
+      b'totalitems': 1,
+      b'totalpaths': 1
+    },
+    {
+      b'path': b'dupe-file',
+      b'totalitems': 1
+    },
+    {
+      b'linknode': b'\xb1l\xce)g\xc1t\x9e\xf4\xf4\xe3\x08j\x80l\xfb\xad\x8a:\xf7',
+      b'node': b'.\xd2\xa3\x91*\x0b$P C\xea\xe8N\xe4\xb2y\xc1\x8b\x90\xdd'
+    }
+  ]
+
+  $ sendhttpv2peer << EOF
+  > command filesdata
+  >     revisions eval:[{
+  >         b'type': b'changesetexplicit',
+  >         b'nodes': [
+  >             b'\xb1\x6c\xce\x29\x67\xc1\x74\x9e\xf4\xf4\xe3\x08\x6a\x80\x6c\xfb\xad\x8a\x3a\xf7',
+  >         ]}]
+  >     fields eval:[b'linknode']
+  >     haveparents eval:True
+  >     pathfilter eval:{b'include': [b'path:dupe-file']}
+  > EOF
+  creating http peer for wire protocol version 2
+  sending filesdata command
+  response: gen[
+    {
+      b'totalitems': 1,
+      b'totalpaths': 1
+    },
+    {
+      b'path': b'dupe-file',
+      b'totalitems': 1
+    },
+    {
+      b'linknode': b'\xb1l\xce)g\xc1t\x9e\xf4\xf4\xe3\x08j\x80l\xfb\xad\x8a:\xf7',
+      b'node': b'.\xd2\xa3\x91*\x0b$P C\xea\xe8N\xe4\xb2y\xc1\x8b\x90\xdd'
+    }
+  ]
+
+Request for changeset where recorded linknode isn't in DAG ancestry will get
+rewritten accordingly
+TODO this is buggy
+
+  $ sendhttpv2peer << EOF
+  > command filesdata
+  >     revisions eval:[{
+  >         b'type': b'changesetexplicit',
+  >         b'nodes': [
+  >             b'\x47\xfc\x30\x58\x09\x11\x23\x2c\xb2\x64\x67\x5b\x40\x28\x19\xde\xdd\xf6\xc6\xf0',
+  >         ]}]
+  >     fields eval:[b'linknode']
+  >     pathfilter eval:{b'include': [b'path:dupe-file']}
+  > EOF
+  creating http peer for wire protocol version 2
+  sending filesdata command
+  response: gen[
+    {
+      b'totalitems': 1,
+      b'totalpaths': 1
+    },
+    {
+      b'path': b'dupe-file',
+      b'totalitems': 1
+    },
+    {
+      b'linknode': b'\xb1l\xce)g\xc1t\x9e\xf4\xf4\xe3\x08j\x80l\xfb\xad\x8a:\xf7',
+      b'node': b'.\xd2\xa3\x91*\x0b$P C\xea\xe8N\xe4\xb2y\xc1\x8b\x90\xdd'
+    }
+  ]
+
+TODO this is buggy
+
+  $ sendhttpv2peer << EOF
+  > command filesdata
+  >     revisions eval:[{
+  >         b'type': b'changesetexplicit',
+  >         b'nodes': [
+  >             b'\x47\xfc\x30\x58\x09\x11\x23\x2c\xb2\x64\x67\x5b\x40\x28\x19\xde\xdd\xf6\xc6\xf0',
+  >         ]}]
+  >     fields eval:[b'linknode']
+  >     haveparents eval:True
+  >     pathfilter eval:{b'include': [b'path:dupe-file']}
+  > EOF
+  creating http peer for wire protocol version 2
+  sending filesdata command
+  response: gen[
+    {
+      b'totalitems': 0,
+      b'totalpaths': 0
+    }
+  ]
+
   $ cat error.log