| 1 |
#require no-windows |
| 2 |
|
| 3 |
$ . "$TESTDIR/remotefilelog-library.sh" |
| 4 |
$ cat >> $HGRCPATH <<EOF |
| 5 |
> [devel] |
| 6 |
> remotefilelog.bg-wait=True |
| 7 |
> EOF |
| 8 |
|
| 9 |
$ hg init master |
| 10 |
$ cd master |
| 11 |
$ cat >> .hg/hgrc <<EOF |
| 12 |
> [remotefilelog] |
| 13 |
> server=True |
| 14 |
> EOF |
| 15 |
$ echo x > x |
| 16 |
$ echo z > z |
| 17 |
$ hg commit -qAm x |
| 18 |
$ echo x2 > x |
| 19 |
$ echo y > y |
| 20 |
$ hg commit -qAm y |
| 21 |
$ echo w > w |
| 22 |
$ rm z |
| 23 |
$ hg commit -qAm w |
| 24 |
$ hg bookmark foo |
| 25 |
|
| 26 |
$ cd .. |
| 27 |
|
| 28 |
# clone the repo |
| 29 |
|
| 30 |
$ hgcloneshallow ssh://user@dummy/master shallow --noupdate |
| 31 |
streaming all changes |
| 32 |
3 files to transfer, 776 bytes of data (no-zstd !) |
| 33 |
stream-cloned 3 files / 776 bytes in * seconds (*/sec) (glob) (no-zstd !) |
| 34 |
3 files to transfer, 785 bytes of data (zstd no-rust !) |
| 35 |
stream-cloned 3 files / 785 bytes in * seconds (*/sec) (glob) (zstd no-rust !) |
| 36 |
5 files to transfer, 911 bytes of data (rust !) |
| 37 |
stream-cloned 5 files / 911 bytes in * seconds (*/sec) (glob) (rust !) |
| 38 |
searching for changes |
| 39 |
no changes found |
| 40 |
|
| 41 |
# Set the prefetchdays config to zero so that all commits are prefetched |
| 42 |
# no matter what their creation date is. Also set prefetchdelay config |
| 43 |
# to zero so that there is no delay between prefetches. |
| 44 |
$ cd shallow |
| 45 |
$ cat >> .hg/hgrc <<EOF |
| 46 |
> [remotefilelog] |
| 47 |
> prefetchdays=0 |
| 48 |
> prefetchdelay=0 |
| 49 |
> EOF |
| 50 |
$ cd .. |
| 51 |
|
| 52 |
# prefetch a revision |
| 53 |
$ cd shallow |
| 54 |
|
| 55 |
$ hg prefetch -r 0 |
| 56 |
2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) |
| 57 |
|
| 58 |
$ hg cat -r 0 x |
| 59 |
x |
| 60 |
|
| 61 |
# background prefetch on pull when configured |
| 62 |
|
| 63 |
$ cat >> .hg/hgrc <<EOF |
| 64 |
> [remotefilelog] |
| 65 |
> pullprefetch=bookmark() |
| 66 |
> backgroundprefetch=True |
| 67 |
> EOF |
| 68 |
$ hg strip tip |
| 69 |
saved backup bundle to $TESTTMP/shallow/.hg/strip-backup/6b4b6f66ef8c-b4b8bdaf-backup.hg (glob) |
| 70 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
| 71 |
|
| 72 |
$ clearcache |
| 73 |
$ hg pull |
| 74 |
pulling from ssh://user@dummy/master |
| 75 |
searching for changes |
| 76 |
adding changesets |
| 77 |
adding manifests |
| 78 |
adding file changes |
| 79 |
updating bookmark foo |
| 80 |
added 1 changesets with 0 changes to 0 files |
| 81 |
new changesets 6b4b6f66ef8c |
| 82 |
(run 'hg update' to get a working copy) |
| 83 |
prefetching file contents |
| 84 |
$ find $CACHEDIR -type f | sort |
| 85 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/ef95c5376f34698742fe34f315fd82136f8f68c0 |
| 86 |
$TESTTMP/hgcache/master/95/cb0bfd2977c761298d9624e4b4d4c72a39974a/076f5e2225b3ff0400b98c92aa6cdf403ee24cca |
| 87 |
$TESTTMP/hgcache/master/af/f024fe4ab0fece4091de044c58c9ae4233383a/bb6ccd5dceaa5e9dc220e0dad65e051b94f69a2c |
| 88 |
$TESTTMP/hgcache/repos |
| 89 |
|
| 90 |
# background prefetch with repack on pull when configured |
| 91 |
|
| 92 |
$ cat >> .hg/hgrc <<EOF |
| 93 |
> [remotefilelog] |
| 94 |
> backgroundrepack=True |
| 95 |
> EOF |
| 96 |
$ hg strip tip |
| 97 |
saved backup bundle to $TESTTMP/shallow/.hg/strip-backup/6b4b6f66ef8c-b4b8bdaf-backup.hg (glob) |
| 98 |
|
| 99 |
$ clearcache |
| 100 |
$ hg pull |
| 101 |
pulling from ssh://user@dummy/master |
| 102 |
searching for changes |
| 103 |
adding changesets |
| 104 |
adding manifests |
| 105 |
adding file changes |
| 106 |
updating bookmark foo |
| 107 |
added 1 changesets with 0 changes to 0 files |
| 108 |
new changesets 6b4b6f66ef8c |
| 109 |
(run 'hg update' to get a working copy) |
| 110 |
prefetching file contents |
| 111 |
$ find $CACHEDIR -type f | sort |
| 112 |
$TESTTMP/hgcache/master/packs/6e8633deba6e544e5f8edbd7b996d6e31a2c42ae.histidx |
| 113 |
$TESTTMP/hgcache/master/packs/6e8633deba6e544e5f8edbd7b996d6e31a2c42ae.histpack |
| 114 |
$TESTTMP/hgcache/master/packs/8ce5ab3745465ab83bba30a7b9c295e0c8404652.dataidx |
| 115 |
$TESTTMP/hgcache/master/packs/8ce5ab3745465ab83bba30a7b9c295e0c8404652.datapack |
| 116 |
$TESTTMP/hgcache/repos |
| 117 |
|
| 118 |
# background prefetch with repack on update when wcprevset configured |
| 119 |
|
| 120 |
$ clearcache |
| 121 |
$ hg up -r 0 |
| 122 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 123 |
2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) |
| 124 |
$ find $CACHEDIR -type f | sort |
| 125 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/1406e74118627694268417491f018a4a883152f0 |
| 126 |
$TESTTMP/hgcache/master/39/5df8f7c51f007019cb30201c49e884b46b92fa/69a1b67522704ec122181c0890bd16e9d3e7516a |
| 127 |
$TESTTMP/hgcache/repos |
| 128 |
|
| 129 |
$ hg up -r 1 |
| 130 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 131 |
2 files fetched over 2 fetches - (2 misses, 0.00% hit ratio) over *s (glob) |
| 132 |
|
| 133 |
$ cat >> .hg/hgrc <<EOF |
| 134 |
> [remotefilelog] |
| 135 |
> bgprefetchrevs=.:: |
| 136 |
> EOF |
| 137 |
|
| 138 |
$ clearcache |
| 139 |
$ hg up -r 0 |
| 140 |
1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 141 |
* files fetched over * fetches - (* misses, 0.00% hit ratio) over *s (glob) |
| 142 |
$ find $CACHEDIR -type f | sort |
| 143 |
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx |
| 144 |
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack |
| 145 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407.dataidx |
| 146 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407.datapack |
| 147 |
$TESTTMP/hgcache/repos |
| 148 |
|
| 149 |
# Ensure that file 'w' was prefetched - it was not part of the update operation and therefore |
| 150 |
# could only be downloaded by the background prefetch |
| 151 |
|
| 152 |
$ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1` |
| 153 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407: |
| 154 |
w: |
| 155 |
Node Delta Base Delta Length Blob Size |
| 156 |
bb6ccd5dceaa 000000000000 2 2 |
| 157 |
|
| 158 |
Total: 2 2 (0.0% bigger) |
| 159 |
x: |
| 160 |
Node Delta Base Delta Length Blob Size |
| 161 |
ef95c5376f34 000000000000 3 3 |
| 162 |
1406e7411862 ef95c5376f34 14 2 |
| 163 |
|
| 164 |
Total: 17 5 (240.0% bigger) |
| 165 |
y: |
| 166 |
Node Delta Base Delta Length Blob Size |
| 167 |
076f5e2225b3 000000000000 2 2 |
| 168 |
|
| 169 |
Total: 2 2 (0.0% bigger) |
| 170 |
z: |
| 171 |
Node Delta Base Delta Length Blob Size |
| 172 |
69a1b6752270 000000000000 2 2 |
| 173 |
|
| 174 |
Total: 2 2 (0.0% bigger) |
| 175 |
|
| 176 |
# background prefetch with repack on commit when wcprevset configured |
| 177 |
|
| 178 |
$ cat >> .hg/hgrc <<EOF |
| 179 |
> [remotefilelog] |
| 180 |
> bgprefetchrevs=0:: |
| 181 |
> EOF |
| 182 |
|
| 183 |
$ clearcache |
| 184 |
$ find $CACHEDIR -type f | sort |
| 185 |
$ echo b > b |
| 186 |
.. The following output line about files fetches is globed because it is |
| 187 |
.. flaky, the core the test is checked when checking the cache dir, so |
| 188 |
.. hopefully this flakyness is not hiding any actual bug. |
| 189 |
$ hg commit -qAm b |
| 190 |
* files fetched over 1 fetches - (* misses, 0.00% hit ratio) over *s (glob) (?) |
| 191 |
$ hg bookmark temporary |
| 192 |
$ find $CACHEDIR -type f | sort |
| 193 |
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx |
| 194 |
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack |
| 195 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407.dataidx |
| 196 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407.datapack |
| 197 |
$TESTTMP/hgcache/repos |
| 198 |
|
| 199 |
# Ensure that file 'w' was prefetched - it was not part of the commit operation and therefore |
| 200 |
# could only be downloaded by the background prefetch |
| 201 |
|
| 202 |
$ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1` |
| 203 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407: |
| 204 |
w: |
| 205 |
Node Delta Base Delta Length Blob Size |
| 206 |
bb6ccd5dceaa 000000000000 2 2 |
| 207 |
|
| 208 |
Total: 2 2 (0.0% bigger) |
| 209 |
x: |
| 210 |
Node Delta Base Delta Length Blob Size |
| 211 |
ef95c5376f34 000000000000 3 3 |
| 212 |
1406e7411862 ef95c5376f34 14 2 |
| 213 |
|
| 214 |
Total: 17 5 (240.0% bigger) |
| 215 |
y: |
| 216 |
Node Delta Base Delta Length Blob Size |
| 217 |
076f5e2225b3 000000000000 2 2 |
| 218 |
|
| 219 |
Total: 2 2 (0.0% bigger) |
| 220 |
z: |
| 221 |
Node Delta Base Delta Length Blob Size |
| 222 |
69a1b6752270 000000000000 2 2 |
| 223 |
|
| 224 |
Total: 2 2 (0.0% bigger) |
| 225 |
|
| 226 |
# background prefetch with repack on rebase when wcprevset configured |
| 227 |
|
| 228 |
$ hg up -r 2 |
| 229 |
3 files updated, 0 files merged, 2 files removed, 0 files unresolved |
| 230 |
(leaving bookmark temporary) |
| 231 |
$ clearcache |
| 232 |
$ find $CACHEDIR -type f | sort |
| 233 |
.. The following output line about files fetches is globed because it is |
| 234 |
.. flaky, the core the test is checked when checking the cache dir, so |
| 235 |
.. hopefully this flakyness is not hiding any actual bug. |
| 236 |
$ hg rebase -s temporary -d foo |
| 237 |
rebasing 3:d9cf06e3b5b6 temporary tip "b" |
| 238 |
saved backup bundle to $TESTTMP/shallow/.hg/strip-backup/d9cf06e3b5b6-e5c3dc63-rebase.hg |
| 239 |
? files fetched over ? fetches - (? misses, 0.00% hit ratio) over *s (glob) |
| 240 |
$ find $CACHEDIR -type f | sort |
| 241 |
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx |
| 242 |
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack |
| 243 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407.dataidx |
| 244 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407.datapack |
| 245 |
$TESTTMP/hgcache/repos |
| 246 |
|
| 247 |
# Ensure that file 'y' was prefetched - it was not part of the rebase operation and therefore |
| 248 |
# could only be downloaded by the background prefetch |
| 249 |
|
| 250 |
$ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1` |
| 251 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407: |
| 252 |
w: |
| 253 |
Node Delta Base Delta Length Blob Size |
| 254 |
bb6ccd5dceaa 000000000000 2 2 |
| 255 |
|
| 256 |
Total: 2 2 (0.0% bigger) |
| 257 |
x: |
| 258 |
Node Delta Base Delta Length Blob Size |
| 259 |
ef95c5376f34 000000000000 3 3 |
| 260 |
1406e7411862 ef95c5376f34 14 2 |
| 261 |
|
| 262 |
Total: 17 5 (240.0% bigger) |
| 263 |
y: |
| 264 |
Node Delta Base Delta Length Blob Size |
| 265 |
076f5e2225b3 000000000000 2 2 |
| 266 |
|
| 267 |
Total: 2 2 (0.0% bigger) |
| 268 |
z: |
| 269 |
Node Delta Base Delta Length Blob Size |
| 270 |
69a1b6752270 000000000000 2 2 |
| 271 |
|
| 272 |
Total: 2 2 (0.0% bigger) |
| 273 |
|
| 274 |
# Check that foregound prefetch with no arguments blocks until background prefetches finish |
| 275 |
|
| 276 |
$ hg up -r 3 |
| 277 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 278 |
$ clearcache |
| 279 |
$ hg prefetch --repack --config ui.timeout.warn=-1 |
| 280 |
(running background incremental repack) |
| 281 |
* files fetched over 1 fetches - (* misses, 0.00% hit ratio) over *s (glob) (?) |
| 282 |
|
| 283 |
$ find $CACHEDIR -type f | sort |
| 284 |
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx |
| 285 |
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack |
| 286 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407.dataidx |
| 287 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407.datapack |
| 288 |
$TESTTMP/hgcache/repos |
| 289 |
|
| 290 |
# Ensure that files were prefetched |
| 291 |
$ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1` |
| 292 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407: |
| 293 |
w: |
| 294 |
Node Delta Base Delta Length Blob Size |
| 295 |
bb6ccd5dceaa 000000000000 2 2 |
| 296 |
|
| 297 |
Total: 2 2 (0.0% bigger) |
| 298 |
x: |
| 299 |
Node Delta Base Delta Length Blob Size |
| 300 |
ef95c5376f34 000000000000 3 3 |
| 301 |
1406e7411862 ef95c5376f34 14 2 |
| 302 |
|
| 303 |
Total: 17 5 (240.0% bigger) |
| 304 |
y: |
| 305 |
Node Delta Base Delta Length Blob Size |
| 306 |
076f5e2225b3 000000000000 2 2 |
| 307 |
|
| 308 |
Total: 2 2 (0.0% bigger) |
| 309 |
z: |
| 310 |
Node Delta Base Delta Length Blob Size |
| 311 |
69a1b6752270 000000000000 2 2 |
| 312 |
|
| 313 |
Total: 2 2 (0.0% bigger) |
| 314 |
|
| 315 |
# Check that foreground prefetch fetches revs specified by '. + draft() + bgprefetchrevs + pullprefetch' |
| 316 |
|
| 317 |
$ clearcache |
| 318 |
$ hg prefetch --repack --config ui.timeout.warn=-1 |
| 319 |
(running background incremental repack) |
| 320 |
* files fetched over 1 fetches - (* misses, 0.00% hit ratio) over *s (glob) (?) |
| 321 |
|
| 322 |
$ find $CACHEDIR -type f | sort |
| 323 |
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx |
| 324 |
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack |
| 325 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407.dataidx |
| 326 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407.datapack |
| 327 |
$TESTTMP/hgcache/repos |
| 328 |
|
| 329 |
# Ensure that files were prefetched |
| 330 |
$ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1` |
| 331 |
$TESTTMP/hgcache/master/packs/f4d50848e0b465e9bfd2875f213044c06cfd7407: |
| 332 |
w: |
| 333 |
Node Delta Base Delta Length Blob Size |
| 334 |
bb6ccd5dceaa 000000000000 2 2 |
| 335 |
|
| 336 |
Total: 2 2 (0.0% bigger) |
| 337 |
x: |
| 338 |
Node Delta Base Delta Length Blob Size |
| 339 |
ef95c5376f34 000000000000 3 3 |
| 340 |
1406e7411862 ef95c5376f34 14 2 |
| 341 |
|
| 342 |
Total: 17 5 (240.0% bigger) |
| 343 |
y: |
| 344 |
Node Delta Base Delta Length Blob Size |
| 345 |
076f5e2225b3 000000000000 2 2 |
| 346 |
|
| 347 |
Total: 2 2 (0.0% bigger) |
| 348 |
z: |
| 349 |
Node Delta Base Delta Length Blob Size |
| 350 |
69a1b6752270 000000000000 2 2 |
| 351 |
|
| 352 |
Total: 2 2 (0.0% bigger) |
| 353 |
|
| 354 |
# Test that if data was prefetched and repacked we dont need to prefetch it again |
| 355 |
# It ensures that Mercurial looks not only in loose files but in packs as well |
| 356 |
|
| 357 |
$ hg prefetch --repack |
| 358 |
(running background incremental repack) |