##// END OF EJS Templates
stream-clone: introduce the notion of an experimental "v3" version...
marmoute -
r51417:58adcabc default
parent child Browse files
Show More
@@ -408,9 +408,7 b' def cloneshallow(orig, ui, repo, *args, '
408 408 # bundle2 flavor of streamclones, so force us to use
409 409 # v1 instead.
410 410 if b'v2' in pullop.remotebundle2caps.get(b'stream', []):
411 pullop.remotebundle2caps[b'stream'] = [
412 c for c in pullop.remotebundle2caps[b'stream'] if c != b'v2'
413 ]
411 pullop.remotebundle2caps[b'stream'] = []
414 412 if bundle2:
415 413 return False, None
416 414 supported, requirements = orig(pullop, bundle2=bundle2)
@@ -1671,6 +1671,10 b' def getrepocaps(repo, allowpushback=Fals'
1671 1671 # Else always advertise support on client, because payload support
1672 1672 # should always be advertised.
1673 1673
1674 if repo.ui.configbool(b'experimental', b'stream-v3'):
1675 if b'stream' in caps:
1676 caps[b'stream'] += (b'v3-exp',)
1677
1674 1678 # b'rev-branch-cache is no longer advertised, but still supported
1675 1679 # for legacy clients.
1676 1680
@@ -1892,8 +1896,16 b' def addpartbundlestream2(bundler, repo, '
1892 1896 )
1893 1897 hint = _(b'the client seems buggy')
1894 1898 raise error.Abort(msg, hint=hint)
1895 if not (b'v2' in bundler.capabilities[b'stream']):
1896 raise error.Abort(_(b'the client does not support streamclone v2'))
1899 client_supported = set(bundler.capabilities[b'stream'])
1900 server_supported = set(getrepocaps(repo, role=b'client').get(b'stream', []))
1901 common_supported = client_supported & server_supported
1902 if not common_supported:
1903 msg = _(b'no common supported version with the client: %s; %s')
1904 str_server = b','.join(sorted(server_supported))
1905 str_client = b','.join(sorted(client_supported))
1906 msg %= (str_server, str_client)
1907 raise error.Abort(msg)
1908 version = max(common_supported)
1897 1909
1898 1910 # Stream clones don't compress well. And compression undermines a
1899 1911 # goal of stream clones, which is to be fast. Communicate the desire
@@ -1924,15 +1936,26 b' def addpartbundlestream2(bundler, repo, '
1924 1936 elif repo.obsstore._version in remoteversions:
1925 1937 includeobsmarkers = True
1926 1938
1927 filecount, bytecount, it = streamclone.generatev2(
1928 repo, includepats, excludepats, includeobsmarkers
1929 )
1930 requirements = streamclone.streamed_requirements(repo)
1931 requirements = _formatrequirementsspec(requirements)
1932 part = bundler.newpart(b'stream2', data=it)
1933 part.addparam(b'bytecount', b'%d' % bytecount, mandatory=True)
1934 part.addparam(b'filecount', b'%d' % filecount, mandatory=True)
1935 part.addparam(b'requirements', requirements, mandatory=True)
1939 if version == b"v2":
1940 filecount, bytecount, it = streamclone.generatev2(
1941 repo, includepats, excludepats, includeobsmarkers
1942 )
1943 requirements = streamclone.streamed_requirements(repo)
1944 requirements = _formatrequirementsspec(requirements)
1945 part = bundler.newpart(b'stream2', data=it)
1946 part.addparam(b'bytecount', b'%d' % bytecount, mandatory=True)
1947 part.addparam(b'filecount', b'%d' % filecount, mandatory=True)
1948 part.addparam(b'requirements', requirements, mandatory=True)
1949 elif version == b"v3-exp":
1950 filecount, bytecount, it = streamclone.generatev2(
1951 repo, includepats, excludepats, includeobsmarkers
1952 )
1953 requirements = streamclone.streamed_requirements(repo)
1954 requirements = _formatrequirementsspec(requirements)
1955 part = bundler.newpart(b'stream3', data=it)
1956 part.addparam(b'bytecount', b'%d' % bytecount, mandatory=True)
1957 part.addparam(b'filecount', b'%d' % filecount, mandatory=True)
1958 part.addparam(b'requirements', requirements, mandatory=True)
1936 1959
1937 1960
1938 1961 def buildobsmarkerspart(bundler, markers, mandatory=True):
@@ -2588,6 +2611,11 b' def handlestreamv2bundle(op, part):'
2588 2611 streamclone.applybundlev2(repo, part, filecount, bytecount, requirements)
2589 2612
2590 2613
2614 @parthandler(b'stream3', (b'requirements', b'filecount', b'bytecount'))
2615 def handlestreamv3bundle(op, part):
2616 return handlestreamv2bundle(op, part)
2617
2618
2591 2619 def widen_bundle(
2592 2620 bundler, repo, oldmatcher, newmatcher, common, known, cgversion, ellipses
2593 2621 ):
@@ -1298,6 +1298,11 b' coreconfigitem('
1298 1298 )
1299 1299 coreconfigitem(
1300 1300 b'experimental',
1301 b'stream-v3',
1302 default=False,
1303 )
1304 coreconfigitem(
1305 b'experimental',
1301 1306 b'treemanifest',
1302 1307 default=False,
1303 1308 )
@@ -2421,7 +2421,7 b' def getbundlechunks('
2421 2421 return info, bundler.getchunks()
2422 2422
2423 2423
2424 @getbundle2partsgenerator(b'stream2')
2424 @getbundle2partsgenerator(b'stream')
2425 2425 def _getbundlestream2(bundler, repo, *args, **kwargs):
2426 2426 return bundle2.addpartbundlestream2(bundler, repo, **kwargs)
2427 2427
@@ -758,6 +758,10 b' def generatev2(repo, includes, excludes,'
758 758 return len(entries), totalfilesize, chunks
759 759
760 760
761 def generatev3(repo, includes, excludes, includeobsmarkers):
762 return generatev2(repo, includes, excludes, includeobsmarkers)
763
764
761 765 @contextlib.contextmanager
762 766 def nested(*ctxs):
763 767 this = ctxs[0]
@@ -1,6 +1,6 b''
1 1 #require serve no-reposimplestore no-chg
2 2
3 #testcases stream-legacy stream-bundle2
3 #testcases stream-legacy stream-bundle2-v2 stream-bundle2-v3
4 4
5 5 #if stream-legacy
6 6 $ cat << EOF >> $HGRCPATH
@@ -8,6 +8,12 b''
8 8 > bundle2.stream = no
9 9 > EOF
10 10 #endif
11 #if stream-bundle2-v3
12 $ cat << EOF >> $HGRCPATH
13 > [experimental]
14 > stream-v3 = yes
15 > EOF
16 #endif
11 17
12 18 Initialize repository
13 19
@@ -174,7 +180,75 b' Cannot stream clone when server.uncompre'
174 180 0060: 69 73 20 66 |is f|
175 181
176 182 #endif
177 #if stream-bundle2
183 #if stream-bundle2-v2
184 $ hg debugcapabilities http://localhost:$HGPORT
185 Main capabilities:
186 batch
187 branchmap
188 $USUAL_BUNDLE2_CAPS_SERVER$
189 changegroupsubset
190 compression=$BUNDLE2_COMPRESSIONS$
191 getbundle
192 httpheader=1024
193 httpmediatype=0.1rx,0.1tx,0.2tx
194 known
195 lookup
196 pushkey
197 unbundle=HG10GZ,HG10BZ,HG10UN
198 unbundlehash
199 Bundle2 capabilities:
200 HG20
201 bookmarks
202 changegroup
203 01
204 02
205 03
206 checkheads
207 related
208 digests
209 md5
210 sha1
211 sha512
212 error
213 abort
214 unsupportedcontent
215 pushraced
216 pushkey
217 hgtagsfnodes
218 listkeys
219 phases
220 heads
221 pushkey
222 remote-changegroup
223 http
224 https
225
226 $ hg clone --stream -U http://localhost:$HGPORT server-disabled
227 warning: stream clone requested but server has them disabled
228 requesting all changes
229 adding changesets
230 adding manifests
231 adding file changes
232 added 3 changesets with 1088 changes to 1088 files
233 new changesets 96ee1d7354c4:5223b5e3265f
234
235 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=getbundle' content-type --bodyfile body --hgproto 0.2 --requestheader "x-hgarg-1=bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%252C03%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=0&common=0000000000000000000000000000000000000000&heads=c17445101a72edac06facd130d14808dfbd5c7c2&stream=1"
236 200 Script output follows
237 content-type: application/mercurial-0.2
238
239
240 $ f --size body --hexdump --bytes 100
241 body: size=140
242 0000: 04 6e 6f 6e 65 48 47 32 30 00 00 00 00 00 00 00 |.noneHG20.......|
243 0010: 73 0b 45 52 52 4f 52 3a 41 42 4f 52 54 00 00 00 |s.ERROR:ABORT...|
244 0020: 00 01 01 07 3c 04 16 6d 65 73 73 61 67 65 73 74 |....<..messagest|
245 0030: 72 65 61 6d 20 64 61 74 61 20 72 65 71 75 65 73 |ream data reques|
246 0040: 74 65 64 20 62 75 74 20 73 65 72 76 65 72 20 64 |ted but server d|
247 0050: 6f 65 73 20 6e 6f 74 20 61 6c 6c 6f 77 20 74 68 |oes not allow th|
248 0060: 69 73 20 66 |is f|
249
250 #endif
251 #if stream-bundle2-v3
178 252 $ hg debugcapabilities http://localhost:$HGPORT
179 253 Main capabilities:
180 254 batch
@@ -262,7 +336,28 b' Basic clone'
262 336 no changes found
263 337 $ cat server/errors.txt
264 338 #endif
265 #if stream-bundle2
339 #if stream-bundle2-v2
340 $ hg clone --stream -U http://localhost:$HGPORT clone1
341 streaming all changes
342 1093 files to transfer, 102 KB of data (no-zstd !)
343 transferred 102 KB in * seconds (* */sec) (glob) (no-zstd !)
344 1093 files to transfer, 98.9 KB of data (zstd !)
345 transferred 98.9 KB in * seconds (* */sec) (glob) (zstd !)
346
347 $ ls -1 clone1/.hg/cache
348 branch2-base
349 branch2-immutable
350 branch2-served
351 branch2-served.hidden
352 branch2-visible
353 branch2-visible-hidden
354 rbc-names-v1
355 rbc-revs-v1
356 tags2
357 tags2-served
358 $ cat server/errors.txt
359 #endif
360 #if stream-bundle2-v3
266 361 $ hg clone --stream -U http://localhost:$HGPORT clone1
267 362 streaming all changes
268 363 1093 files to transfer, 102 KB of data (no-zstd !)
@@ -386,7 +481,15 b' getbundle requests with stream=1 are unc'
386 481 searching for changes
387 482 no changes found
388 483 #endif
389 #if stream-bundle2
484 #if stream-bundle2-v2
485 $ hg clone --uncompressed -U http://localhost:$HGPORT clone1-uncompressed
486 streaming all changes
487 1093 files to transfer, 102 KB of data (no-zstd !)
488 transferred 102 KB in * seconds (* */sec) (glob) (no-zstd !)
489 1093 files to transfer, 98.9 KB of data (zstd !)
490 transferred 98.9 KB in * seconds (* */sec) (glob) (zstd !)
491 #endif
492 #if stream-bundle2-v3
390 493 $ hg clone --uncompressed -U http://localhost:$HGPORT clone1-uncompressed
391 494 streaming all changes
392 495 1093 files to transfer, 102 KB of data (no-zstd !)
@@ -425,7 +528,7 b' Clone with background file closing enabl'
425 528 updating the branch cache
426 529 (sent 5 HTTP requests and * bytes; received * bytes in responses) (glob)
427 530 #endif
428 #if stream-bundle2
531 #if stream-bundle2-v2
429 532 $ hg --debug --config worker.backgroundclose=true --config worker.backgroundcloseminfilecount=1 clone --stream -U http://localhost:$HGPORT clone-background | grep -v adding
430 533 using http://localhost:$HGPORT/
431 534 sending capabilities command
@@ -452,6 +555,33 b' Clone with background file closing enabl'
452 555 updating the branch cache
453 556 (sent 3 HTTP requests and * bytes; received * bytes in responses) (glob)
454 557 #endif
558 #if stream-bundle2-v3
559 $ hg --debug --config worker.backgroundclose=true --config worker.backgroundcloseminfilecount=1 clone --stream -U http://localhost:$HGPORT clone-background | grep -v adding
560 using http://localhost:$HGPORT/
561 sending capabilities command
562 query 1; heads
563 sending batch command
564 streaming all changes
565 sending getbundle command
566 bundle2-input-bundle: with-transaction
567 bundle2-input-part: "stream3" (params: 3 mandatory) supported
568 applying stream bundle
569 1093 files to transfer, 102 KB of data (no-zstd !)
570 1093 files to transfer, 98.9 KB of data (zstd !)
571 starting 4 threads for background file closing
572 starting 4 threads for background file closing
573 updating the branch cache
574 transferred 102 KB in * seconds (* */sec) (glob) (no-zstd !)
575 bundle2-input-part: total payload size 118984 (no-zstd !)
576 transferred 98.9 KB in * seconds (* */sec) (glob) (zstd !)
577 bundle2-input-part: total payload size 116145 (zstd no-bigendian !)
578 bundle2-input-part: total payload size 116140 (zstd bigendian !)
579 bundle2-input-part: "listkeys" (params: 1 mandatory) supported
580 bundle2-input-bundle: 2 parts total
581 checking for updated bookmarks
582 updating the branch cache
583 (sent 3 HTTP requests and * bytes; received * bytes in responses) (glob)
584 #endif
455 585
456 586 Cannot stream clone when there are secret changesets
457 587
@@ -484,7 +614,15 b' Streaming of secrets can be overridden b'
484 614 searching for changes
485 615 no changes found
486 616 #endif
487 #if stream-bundle2
617 #if stream-bundle2-v2
618 $ hg clone --stream -U http://localhost:$HGPORT secret-allowed
619 streaming all changes
620 1093 files to transfer, 102 KB of data (no-zstd !)
621 transferred 102 KB in * seconds (* */sec) (glob) (no-zstd !)
622 1093 files to transfer, 98.9 KB of data (zstd !)
623 transferred 98.9 KB in * seconds (* */sec) (glob) (zstd !)
624 #endif
625 #if stream-bundle2-v3
488 626 $ hg clone --stream -U http://localhost:$HGPORT secret-allowed
489 627 streaming all changes
490 628 1093 files to transfer, 102 KB of data (no-zstd !)
@@ -638,7 +776,17 b' clone it'
638 776 updating to branch default
639 777 1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
640 778 #endif
641 #if stream-bundle2
779 #if stream-bundle2-v2
780 $ hg clone --stream http://localhost:$HGPORT with-bookmarks
781 streaming all changes
782 1096 files to transfer, 102 KB of data (no-zstd !)
783 transferred 102 KB in * seconds (* */sec) (glob) (no-zstd !)
784 1096 files to transfer, 99.1 KB of data (zstd !)
785 transferred 99.1 KB in * seconds (* */sec) (glob) (zstd !)
786 updating to branch default
787 1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
788 #endif
789 #if stream-bundle2-v3
642 790 $ hg clone --stream http://localhost:$HGPORT with-bookmarks
643 791 streaming all changes
644 792 1096 files to transfer, 102 KB of data (no-zstd !)
@@ -674,7 +822,17 b' Clone as publishing'
674 822 updating to branch default
675 823 1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
676 824 #endif
677 #if stream-bundle2
825 #if stream-bundle2-v2
826 $ hg clone --stream http://localhost:$HGPORT phase-publish
827 streaming all changes
828 1096 files to transfer, 102 KB of data (no-zstd !)
829 transferred 102 KB in * seconds (* */sec) (glob) (no-zstd !)
830 1096 files to transfer, 99.1 KB of data (zstd !)
831 transferred 99.1 KB in * seconds (* */sec) (glob) (zstd !)
832 updating to branch default
833 1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
834 #endif
835 #if stream-bundle2-v3
678 836 $ hg clone --stream http://localhost:$HGPORT phase-publish
679 837 streaming all changes
680 838 1096 files to transfer, 102 KB of data (no-zstd !)
@@ -720,7 +878,21 b' stream v1 unsuitable for non-publishing '
720 878 1: public
721 879 2: public
722 880 #endif
723 #if stream-bundle2
881 #if stream-bundle2-v2
882 $ hg clone --stream http://localhost:$HGPORT phase-no-publish
883 streaming all changes
884 1097 files to transfer, 102 KB of data (no-zstd !)
885 transferred 102 KB in * seconds (* */sec) (glob) (no-zstd !)
886 1097 files to transfer, 99.1 KB of data (zstd !)
887 transferred 99.1 KB in * seconds (* */sec) (glob) (zstd !)
888 updating to branch default
889 1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
890 $ hg -R phase-no-publish phase -r 'all()'
891 0: draft
892 1: draft
893 2: draft
894 #endif
895 #if stream-bundle2-v3
724 896 $ hg clone --stream http://localhost:$HGPORT phase-no-publish
725 897 streaming all changes
726 898 1097 files to transfer, 102 KB of data (no-zstd !)
@@ -744,7 +916,57 b' With v1 of the stream protocol, changese'
744 916 no obsolescence markers exchange in stream v1.
745 917
746 918 #endif
747 #if stream-bundle2
919 #if stream-bundle2-v2
920
921 Stream repository with obsolescence
922 -----------------------------------
923
924 Clone non-publishing with obsolescence
925
926 $ cat >> $HGRCPATH << EOF
927 > [experimental]
928 > evolution=all
929 > EOF
930
931 $ cd server
932 $ echo foo > foo
933 $ hg -q commit -m 'about to be pruned'
934 $ hg debugobsolete `hg log -r . -T '{node}'` -d '0 0' -u test --record-parents
935 1 new obsolescence markers
936 obsoleted 1 changesets
937 $ hg up null -q
938 $ hg log -T '{rev}: {phase}\n'
939 2: draft
940 1: draft
941 0: draft
942 $ hg serve -p $HGPORT -d --pid-file=hg.pid
943 $ cat hg.pid > $DAEMON_PIDS
944 $ cd ..
945
946 $ hg clone -U --stream http://localhost:$HGPORT with-obsolescence
947 streaming all changes
948 1098 files to transfer, 102 KB of data (no-zstd !)
949 transferred 102 KB in * seconds (* */sec) (glob) (no-zstd !)
950 1098 files to transfer, 99.5 KB of data (zstd !)
951 transferred 99.5 KB in * seconds (* */sec) (glob) (zstd !)
952 $ hg -R with-obsolescence log -T '{rev}: {phase}\n'
953 2: draft
954 1: draft
955 0: draft
956 $ hg debugobsolete -R with-obsolescence
957 8c206a663911c1f97f2f9d7382e417ae55872cfa 0 {5223b5e3265f0df40bb743da62249413d74ac70f} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
958 $ hg verify -R with-obsolescence -q
959
960 $ hg clone -U --stream --config experimental.evolution=0 http://localhost:$HGPORT with-obsolescence-no-evolution
961 streaming all changes
962 remote: abort: server has obsolescence markers, but client cannot receive them via stream clone
963 abort: pull failed on remote
964 [100]
965
966 $ killdaemons.py
967
968 #endif
969 #if stream-bundle2-v3
748 970
749 971 Stream repository with obsolescence
750 972 -----------------------------------
General Comments 0
You need to be logged in to leave comments. Login now