1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
|
#require rust
TODO test streamv3 once that gains shapes support
Setup
=====
$ cat >> $HGRCPATH << EOF
> [extensions]
> clonebundles=
> narrow=
>
> [experimental]
> server.stream-narrow-clones=yes
> EOF
Generate a source repo with a bunch of files and folders, some with a few edits
$ hg init source
$ cd source
$ mkdir -p dir1/excluded/nested dir2 excluded
$ touch \
> a \
> b \
> dir1/a \
> dir1/b \
> dir1/excluded/a \
> dir1/excluded/b \
> dir1/excluded/nested/a \
> dir1/excluded/nested/b \
> dir2/a \
> dir2/b \
> excluded/a \
> excluded/b
$ hg commit -Aqm0
$ echo "foo" > a
$ echo "foo" > dir1/a
$ echo "foobar" > dir1/b
$ echo "foobar" > dir2/b
$ echo "foo" > dir2/a
$ echo "foo" > dir1/excluded/a
$ echo "foo" > excluded/a
$ echo "foobar" > excluded/b
$ hg commit -qm1
$ echo "bar" > dir1/excluded/a
$ hg commit -qm2
$ cd ..
Test errors
===========
Make sure we complain if not using Rust when generating a shape bundle
$ HGMODULEPOLICY=c hg bundle -R source -a -t"none-v2;stream=v2;shape=foo" --config storage.all-slow-path=allow outfile.hg
abort: shape bundlespec option is only available with the Rust extensions
[10]
Make sure we complain if not using stream bundles when generating a shape bundle
$ hg bundle -R source -a -t"none-v2;shape=foo" outfile.hg
abort: shape bundlespec option is only implemented for stream bundles
[10]
Test without any shaping (sanity check)
$ hg bundle -R source -a -t"none-v2;stream=v2" outfile-no-shape.hg
$ hg debugbundle outfile-no-shape.hg
Stream params: {}
stream2 -- {bytecount: *, filecount: 20, requirements: *} (mandatory: True) (glob)
Create shapes config
$ cat >> source/.hg/store/server-shapes << EOF
> version = 0
> [[shards]]
> name = "default"
> requires = ["base"]
> shape = true
> [[shards]]
> name = "excluded1"
> paths = ["excluded"]
> [[shards]]
> name = "excluded2"
> paths = ["dir1/excluded"]
> [[shards]]
> name = "foobar"
> paths = ["dir2"]
> shape = true
> [[shards]]
> name = "foobaz"
> shape = true
> requires = ["excluded1", "foobar"]
> EOF
Test with an unknown shape
$ hg -R source bundle -a --type="none-v2;stream=v2;shape=foo" outfile-shaped.hg
abort: unknown shape: 'foo'
[10]
Test with the default shape
$ hg -R source bundle -a --type="none-v2;stream=v2;shape=default" outfile-shape-default.hg
$ hg debugbundle outfile-shape-default.hg | grep -E 'store-fingerprint: [0-9a-f]{64}'
stream2 -- {bytecount: *, filecount: 12, requirements: *, store-fingerprint: 961e3d6d14621106b59a576aa6d8907d3f4734ea3f04c01d0bdff031b5572b19} (mandatory: True) (glob)
Add a full non-fingerprinted streaming clone for reference and fallback testing
$ hg -R source bundle -a --type="none-v2;stream=v2" outfile-shape-full.hg
$ hg debugbundle outfile-shape-full.hg
Stream params: {}
stream2 -- {bytecount: 2637, filecount: 20, requirements: generaldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog} (mandatory: True)
Test with a known shape
$ hg -R source bundle -a --type="none-v2;stream=v2;shape=foobar" outfile-shape-foobar.hg
$ hg debugbundle outfile-shape-foobar.hg | grep -E 'store-fingerprint: [0-9a-f]{64}'
stream2 -- {bytecount: *, filecount: 10, requirements: *, store-fingerprint: feb09be59c639f9f80726b5cd0204cf05cda6ea875fa7fd7c1dea98f9a28e726} (mandatory: True) (glob)
$ hg -R source bundle -a --type="none-v2;stream=v2;shape=foobaz" outfile-shape-foobaz.hg
$ hg debugbundle outfile-shape-foobaz.hg | grep -E 'store-fingerprint: [0-9a-f]{64}'
stream2 -- {bytecount: *, filecount: 12, requirements: *, store-fingerprint: bda77439a4ee183aaa533e68680cdbc2fae13fb0c0e20210a598fe8889ef640e} (mandatory: True) (glob)
Test cloning
============
Start hg server
---------------
$ cd source
$ hg serve -d -p $HGPORT --pid-file hg.pid --errorlog error.log --accesslog access.log
$ cat hg.pid >> $DAEMON_PIDS
$ cd ..
Prepare inline bundles
----------------------
$ bundlespec="$(hg debugbundle --spec outfile-shape-foobar.hg)"
$ echo $bundlespec
none-v2;stream=v2;requirements*;store-fingerprint=feb09be59c639f9f80726b5cd0204cf05cda6ea875fa7fd7c1dea98f9a28e726 (glob)
$ bundlespec2="$(hg debugbundle --spec outfile-shape-foobaz.hg)"
$ echo $bundlespec2
none-v2;stream=v2;requirements*;store-fingerprint=bda77439a4ee183aaa533e68680cdbc2fae13fb0c0e20210a598fe8889ef640e (glob)
$ bundlespecfull="$(hg debugbundle --spec outfile-shape-full.hg)"
$ echo $bundlespecfull
none-v2;stream=v2;requirements%3Dgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog
$ mkdir source/.hg/bundle-cache
$ mv outfile-shape-*.hg source/.hg/bundle-cache/
$ cat > source/.hg/clonebundles.manifest << EOF
> peer-bundle-cache://outfile-shape-foobar.hg BUNDLESPEC=$bundlespec
> peer-bundle-cache://outfile-shape-foobaz.hg BUNDLESPEC=$bundlespec2
> EOF
Check the resulting manifest
----------------------------
Define the special set of files included in all shapes.
$ hgfiles="--include=.hgignore --include=.hgtags --include=.hgsub --include=.hgsubstate"
The raw manifest looks OK
$ hg debug::clonebundle-manifest ssh://user@dummy/source --raw
peer-bundle-cache://outfile-shape-foobar.hg BUNDLESPEC=none-v2;stream=v2;requirements*;store-fingerprint=feb09be59c639f9f80726b5cd0204cf05cda6ea875fa7fd7c1dea98f9a28e726 (glob)
peer-bundle-cache://outfile-shape-foobaz.hg BUNDLESPEC=none-v2;stream=v2;requirements*;store-fingerprint=bda77439a4ee183aaa533e68680cdbc2fae13fb0c0e20210a598fe8889ef640e (glob)
Passing in no includes or excludes shows that all entries are filtered out due to their fingerprints
$ hg debug::clonebundle-manifest ssh://user@dummy/source --debug | grep 'correct store fingerprint'
filtering peer-bundle-cache://outfile-shape-foobar.hg because not the correct store fingerprint (expected feb09be59c639f9f80726b5cd0204cf05cda6ea875fa7fd7c1dea98f9a28e726)
filtering peer-bundle-cache://outfile-shape-foobaz.hg because not the correct store fingerprint (expected bda77439a4ee183aaa533e68680cdbc2fae13fb0c0e20210a598fe8889ef640e)
Passing a pattern that matches nothing filters all entries
$ hg debug::clonebundle-manifest ssh://user@dummy/source --include=no_match
Passing a matching pattern works
$ hg debug::clonebundle-manifest ssh://user@dummy/source --include=dir2 $hgfiles
URL: peer-bundle-cache://outfile-shape-foobar.hg
BUNDLESPEC: none-v2;stream=v2;requirements=*;store-fingerprint=feb09be59c639f9f80726b5cd0204cf05cda6ea875fa7fd7c1dea98f9a28e726 (glob)
COMPRESSION: none
VERSION: v2
STORE-FINGERPRINT: feb09be59c639f9f80726b5cd0204cf05cda6ea875fa7fd7c1dea98f9a28e726
Non-streaming, non-narrow cloning
---------------------------------
Passing no includes should fall back to regular clone
$ hg clone ssh://user@dummy/source plain-clone 2>&1 --narrow | grep "falling back"
no compatible clone bundles available on server; falling back to regular clone
$ rm -rf plain-clone
Test a pure Python client
$ HGMODULEPOLICY=py hg clone ssh://user@dummy/source --narrow plain-clone 2>&1 | grep "falling back"
no compatible clone bundles available on server; falling back to regular clone
$ cat source/error.log
$ cat source/access.log
Non-narrow streaming cloning
----------------------------
Passing no includes should fall back to full (non-fingerprinted) streaming clone if available
$ echo "peer-bundle-cache://outfile-shape-full.hg BUNDLESPEC=$bundlespecfull" >> source/.hg/clonebundles.manifest
$ hg clone ssh://user@dummy/source full-clone | grep "bundle from"
applying clone bundle from peer-bundle-cache://outfile-shape-full.hg
Test a pure Python client
$ rm -rf full-clone
$ HGMODULEPOLICY=py hg clone ssh://user@dummy/source --narrow full-clone | grep "bundle from"
applying clone bundle from peer-bundle-cache://outfile-shape-full.hg
$ cat source/error.log
$ cat source/access.log
Narrow + stream cloning
-----------------------
The right fingerprint should be derived from the narrow patterns, selecting
the correct narrow stream clone bundle
Test that if no fingerprints match, we don't clone anything
$ hg debug::clonebundle-manifest ssh://user@dummy/source --include=notexist
$ hg clone ssh://user@dummy/source clone-shaped --narrow --include=notexist 2>&1 | grep "falling back"
no compatible clone bundles available on server; falling back to regular clone
$ rm -rf clone-shaped
Test matching fingerprints
First with a Python client
$ HGMODULEPOLICY=py hg clone ssh://user@dummy/source clone-shaped --narrow $hgfiles --include=dir2 | grep "bundle from"
applying clone bundle from peer-bundle-cache://outfile-shape-foobar.hg
$ hg admin::narrow-client -R clone-shaped --store-fingerprint
feb09be59c639f9f80726b5cd0204cf05cda6ea875fa7fd7c1dea98f9a28e726
$ rm -rf clone-shaped
Then with the Rust client
$ hg clone ssh://user@dummy/source clone-shaped --narrow $hgfiles --include=dir2 | grep "bundle from"
applying clone bundle from peer-bundle-cache://outfile-shape-foobar.hg
$ cd clone-shaped
$ hg debug-revlog-stats --filelogs -T'{revlog_target}\n'
dir2/a
dir2/b
We make sure that the client has the same fingerprint than the streamclone
$ hg admin::narrow-client --store-fingerprint
feb09be59c639f9f80726b5cd0204cf05cda6ea875fa7fd7c1dea98f9a28e726
We make sure that the client has the expected narrowspec
$ hg tracked
I path:.hgignore
I path:.hgsub
I path:.hgsubstate
I path:.hgtags
I path:dir2
Accessing a file outside of the shape is not possible
$ hg cat a
[1]
$ hg cat excluded/a
[1]
The rest works correctly
$ hg cat dir2/a
foo
$ hg cat dir2/b
foobar
$ cd ..
Testing another shape
---------------------
First with a pure Python client
$ HGMODULEPOLICY=py hg clone ssh://user@dummy/source clone-shaped2 --narrow $hgfiles --include=dir2 --include=excluded | grep "bundle from"
applying clone bundle from peer-bundle-cache://outfile-shape-foobaz.hg
$ hg -R clone-shaped2 admin::narrow-client --store-fingerprint
bda77439a4ee183aaa533e68680cdbc2fae13fb0c0e20210a598fe8889ef640e
$ rm -rf clone-shaped2
Then with the Rust client
$ hg clone ssh://user@dummy/source clone-shaped2 --narrow --include=dir2 $hgfiles --include=excluded | grep "bundle from"
applying clone bundle from peer-bundle-cache://outfile-shape-foobaz.hg
$ cd clone-shaped2
$ hg debug-revlog-stats --filelogs -T'{revlog_target}\n'
dir2/a
dir2/b
excluded/a
excluded/b
The client has the same fingerprint than the streamclone
$ hg admin::narrow-client --store-fingerprint
bda77439a4ee183aaa533e68680cdbc2fae13fb0c0e20210a598fe8889ef640e
The client has the expected narrowspec
$ hg tracked
I path:.hgignore
I path:.hgsub
I path:.hgsubstate
I path:.hgtags
I path:dir2
I path:excluded
Accessing a file outside of the shape is not possible
$ hg cat a
[1]
$ hg cat excluded/a
foo
The rest works correctly
$ hg cat excluded/a
foo
$ hg cat dir2/a
foo
$ hg cat dir2/b
foobar
|