##// END OF EJS Templates
stream-clone: smoothly detect and handle a case were a revlog is split...
marmoute -
r51534:54604240 default
parent child Browse files
Show More
@@ -506,7 +506,7 b' class revlog:'
506 506 except FileNotFoundError:
507 507 return b''
508 508
509 def get_streams(self, max_linkrev):
509 def get_streams(self, max_linkrev, force_inline=False):
510 510 n = len(self)
511 511 index = self.index
512 512 while n > 0:
@@ -547,6 +547,29 b' class revlog:'
547 547 return [
548 548 (self._indexfile, inline_stream, index_size + data_size),
549 549 ]
550 elif force_inline:
551
552 def get_stream():
553 with self._datafp() as fp_d:
554 yield None
555
556 for rev in range(n):
557 idx = self.index.entry_binary(rev)
558 if rev == 0 and self._docket is None:
559 # re-inject the inline flag
560 header = self._format_flags
561 header |= self._format_version
562 header |= FLAG_INLINE_DATA
563 header = self.index.pack_header(header)
564 idx = header + idx
565 yield idx
566 yield self._getsegmentforrevs(rev, rev, df=fp_d)[1]
567
568 inline_stream = get_stream()
569 next(inline_stream)
570 return [
571 (self._indexfile, inline_stream, index_size + data_size),
572 ]
550 573 else:
551 574
552 575 def get_index_stream():
@@ -645,8 +645,11 b' class RevlogStoreEntry(BaseStoreEntry):'
645 645 if name_to_ext[f.unencoded_path] not in (b'.d', b'.i')
646 646 ]
647 647
648 is_inline = b'.d' not in self._details
649
648 650 rl = self.get_revlog_instance(repo).get_revlog()
649 rl_stream = rl.get_streams(max_changeset)
651 rl_stream = rl.get_streams(max_changeset, force_inline=is_inline)
652
650 653 for name, s, size in rl_stream:
651 654 if name_to_size.get(name, 0) != size:
652 655 msg = _(b"expected %d bytes but %d provided for %s")
@@ -17,6 +17,8 b' setup a repository for tests'
17 17 > [format]
18 18 > # skip compression to make it easy to trigger a split
19 19 > revlog-compression=none
20 > [phases]
21 > publish=no
20 22 > EOF
21 23
22 24 $ hg init server
@@ -64,7 +66,11 b' Start the server'
64 66
65 67 Start a client doing a streaming clone
66 68
67 $ (hg clone -q --stream -U http://localhost:$HGPORT1 clone-while-split > client.log 2>&1; touch "$HG_TEST_STREAM_WALKED_FILE_3") &
69 $ ( \
70 > hg clone --debug --stream -U http://localhost:$HGPORT1 \
71 > clone-while-split > client.log 2>&1; \
72 > touch "$HG_TEST_STREAM_WALKED_FILE_3" \
73 > ) &
68 74
69 75 Wait for the server to be done collecting data
70 76
@@ -86,65 +92,84 b' wait for the client to be done cloning.'
86 92 Check everything is fine
87 93
88 94 $ cat client.log
89 remote: abort: unexpected error: expected 0 bytes but 1067 provided for data/some-file.d (known-bad-output !)
90 abort: pull failed on remote (known-bad-output !)
95 using http://localhost:$HGPORT1/
96 sending capabilities command
97 query 1; heads
98 sending batch command
99 streaming all changes
100 sending getbundle command
101 bundle2-input-bundle: with-transaction
102 bundle2-input-part: "stream2" (params: 3 mandatory) supported (stream-bundle2-v2 !)
103 bundle2-input-part: "stream3-exp" (params: 3 mandatory) supported (stream-bundle2-v3 !)
104 applying stream bundle
105 7 files to transfer, 2.11 KB of data
106 adding [s] data/some-file.i (1.23 KB)
107 adding [s] phaseroots (43 bytes)
108 adding [s] 00manifest.i (348 bytes)
109 adding [s] 00changelog.i (381 bytes)
110 adding [c] branch2-served (94 bytes)
111 adding [c] rbc-names-v1 (7 bytes)
112 adding [c] rbc-revs-v1 (24 bytes)
113 updating the branch cache
114 transferred 2.11 KB in * seconds (* */sec) (glob)
115 bundle2-input-part: total payload size 2268
116 bundle2-input-part: "listkeys" (params: 1 mandatory) supported
117 bundle2-input-bundle: 2 parts total
118 checking for updated bookmarks
119 updating the branch cache
120 (sent 3 HTTP requests and * bytes; received * bytes in responses) (glob)
91 121 $ tail -2 errors.log
92 mercurial.error.Abort: expected 0 bytes but 1067 provided for data/some-file.d (known-bad-output !)
93 (known-bad-output !)
94 122 $ hg -R clone-while-split verify
95 checking changesets (missing-correct-output !)
96 checking manifests (missing-correct-output !)
97 crosschecking files in changesets and manifests (missing-correct-output !)
98 checking files (missing-correct-output !)
99 checking dirstate (missing-correct-output !)
100 checked 3 changesets with 3 changes to 1 files (missing-correct-output !)
101 abort: repository clone-while-split not found (known-bad-output !)
102 [255]
123 checking changesets
124 checking manifests
125 crosschecking files in changesets and manifests
126 checking files
127 checking dirstate
128 checked 3 changesets with 3 changes to 1 files
103 129 $ hg -R clone-while-split tip
104 changeset: 2:dbd9854c38a6 (missing-correct-output !)
105 tag: tip (missing-correct-output !)
106 user: test (missing-correct-output !)
107 date: Thu Jan 01 00:00:00 1970 +0000 (missing-correct-output !)
108 summary: c (missing-correct-output !)
109 (missing-correct-output !)
110 abort: repository clone-while-split not found (known-bad-output !)
111 [255]
130 changeset: 2:dbd9854c38a6
131 tag: tip
132 user: test
133 date: Thu Jan 01 00:00:00 1970 +0000
134 summary: c
135
112 136 $ hg -R clone-while-split debug-revlog-index some-file
113 rev linkrev nodeid p1-nodeid p2-nodeid (missing-correct-output !)
114 0 0 ed70cecbc103 000000000000 000000000000 (missing-correct-output !)
115 1 1 7241018db64c ed70cecbc103 000000000000 (missing-correct-output !)
116 2 2 fa1120531cc1 7241018db64c 000000000000 (missing-correct-output !)
117 abort: repository clone-while-split not found (known-bad-output !)
118 [255]
137 rev linkrev nodeid p1-nodeid p2-nodeid
138 0 0 ed70cecbc103 000000000000 000000000000
139 1 1 7241018db64c ed70cecbc103 000000000000
140 2 2 fa1120531cc1 7241018db64c 000000000000
141 $ hg -R server phase --rev 'all()'
142 0: draft
143 1: draft
144 2: draft
145 3: draft
146 $ hg -R clone-while-split phase --rev 'all()'
147 0: draft
148 1: draft
149 2: draft
119 150
120 151 subsequent pull work
121 152
122 153 $ hg -R clone-while-split pull
123 pulling from http://localhost:$HGPORT1/ (missing-correct-output !)
124 searching for changes (missing-correct-output !)
125 adding changesets (missing-correct-output !)
126 adding manifests (missing-correct-output !)
127 adding file changes (missing-correct-output !)
128 added 1 changesets with 1 changes to 1 files (missing-correct-output !)
129 new changesets df05c6cb1406 (missing-correct-output !)
130 (run 'hg update' to get a working copy) (missing-correct-output !)
131 abort: repository clone-while-split not found (known-bad-output !)
132 [255]
154 pulling from http://localhost:$HGPORT1/
155 searching for changes
156 adding changesets
157 adding manifests
158 adding file changes
159 added 1 changesets with 1 changes to 1 files
160 new changesets df05c6cb1406 (1 drafts)
161 (run 'hg update' to get a working copy)
133 162
134 163 $ hg -R clone-while-split debug-revlog-index some-file
135 rev linkrev nodeid p1-nodeid p2-nodeid (missing-correct-output !)
136 0 0 ed70cecbc103 000000000000 000000000000 (missing-correct-output !)
137 1 1 7241018db64c ed70cecbc103 000000000000 (missing-correct-output !)
138 2 2 fa1120531cc1 7241018db64c 000000000000 (missing-correct-output !)
139 3 3 a631378adaa3 fa1120531cc1 000000000000 (missing-correct-output !)
140 abort: repository clone-while-split not found (known-bad-output !)
141 [255]
164 rev linkrev nodeid p1-nodeid p2-nodeid
165 0 0 ed70cecbc103 000000000000 000000000000
166 1 1 7241018db64c ed70cecbc103 000000000000
167 2 2 fa1120531cc1 7241018db64c 000000000000
168 3 3 a631378adaa3 fa1120531cc1 000000000000
142 169 $ hg -R clone-while-split verify
143 checking changesets (missing-correct-output !)
144 checking manifests (missing-correct-output !)
145 crosschecking files in changesets and manifests (missing-correct-output !)
146 checking files (missing-correct-output !)
147 checking dirstate (missing-correct-output !)
148 checked 4 changesets with 4 changes to 1 files (missing-correct-output !)
149 abort: repository clone-while-split not found (known-bad-output !)
150 [255]
170 checking changesets
171 checking manifests
172 crosschecking files in changesets and manifests
173 checking files
174 checking dirstate
175 checked 4 changesets with 4 changes to 1 files
General Comments 0
You need to be logged in to leave comments. Login now