| 1 |
#require no-windows |
| 2 |
|
| 3 |
$ . "$TESTDIR/remotefilelog-library.sh" |
| 4 |
|
| 5 |
$ hg init master |
| 6 |
$ cd master |
| 7 |
$ cat >> .hg/hgrc <<EOF |
| 8 |
> [remotefilelog] |
| 9 |
> server=True |
| 10 |
> EOF |
| 11 |
$ echo x > x |
| 12 |
$ hg commit -qAm x |
| 13 |
$ echo y > y |
| 14 |
$ rm x |
| 15 |
$ hg commit -qAm DxAy |
| 16 |
$ echo yy > y |
| 17 |
$ hg commit -qAm y |
| 18 |
$ cd .. |
| 19 |
|
| 20 |
$ hgcloneshallow ssh://user@dummy/master shallow -q |
| 21 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
| 22 |
|
| 23 |
# Set the prefetchdays config to zero so that all commits are prefetched |
| 24 |
# no matter what their creation date is. |
| 25 |
$ cd shallow |
| 26 |
$ cat >> .hg/hgrc <<EOF |
| 27 |
> [remotefilelog] |
| 28 |
> prefetchdays=0 |
| 29 |
> EOF |
| 30 |
$ cd .. |
| 31 |
|
| 32 |
# Prefetch all data and repack |
| 33 |
|
| 34 |
$ cd shallow |
| 35 |
$ cat >> .hg/hgrc <<EOF |
| 36 |
> [remotefilelog] |
| 37 |
> bgprefetchrevs=all() |
| 38 |
> EOF |
| 39 |
|
| 40 |
$ hg prefetch |
| 41 |
2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) |
| 42 |
$ hg repack |
| 43 |
|
| 44 |
$ find $CACHEDIR | sort | grep -E ".datapack|.histpack" |
| 45 |
$TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack |
| 46 |
$TESTTMP/hgcache/master/packs/dc8f8fdc76690ce27791ce9f53a18da379e50d37.datapack |
| 47 |
|
| 48 |
# Ensure that all file versions were prefetched |
| 49 |
|
| 50 |
$ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1` |
| 51 |
$TESTTMP/hgcache/master/packs/dc8f8fdc76690ce27791ce9f53a18da379e50d37: |
| 52 |
x: |
| 53 |
Node Delta Base Delta Length Blob Size |
| 54 |
1406e7411862 000000000000 2 2 |
| 55 |
|
| 56 |
Total: 2 2 (0.0% bigger) |
| 57 |
y: |
| 58 |
Node Delta Base Delta Length Blob Size |
| 59 |
50dbc4572b8e 000000000000 3 3 |
| 60 |
076f5e2225b3 50dbc4572b8e 14 2 |
| 61 |
|
| 62 |
Total: 17 5 (240.0% bigger) |
| 63 |
|
| 64 |
# Test garbage collection during repack |
| 65 |
|
| 66 |
$ cat >> .hg/hgrc <<EOF |
| 67 |
> [remotefilelog] |
| 68 |
> bgprefetchrevs=tip |
| 69 |
> gcrepack=True |
| 70 |
> nodettl=86400 |
| 71 |
> EOF |
| 72 |
|
| 73 |
$ hg repack |
| 74 |
|
| 75 |
$ find $CACHEDIR | sort | grep -E ".datapack|.histpack" |
| 76 |
$TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack |
| 77 |
$TESTTMP/hgcache/master/packs/a4e1d094ec2aee8a08a4d6d95a13c634cc7d7394.datapack |
| 78 |
|
| 79 |
# Ensure that file 'x' was garbage collected. It should be GCed because it is not in the keepset |
| 80 |
# and is old (commit date is 0.0 in tests). Ensure that file 'y' is present as it is in the keepset. |
| 81 |
|
| 82 |
$ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1` |
| 83 |
$TESTTMP/hgcache/master/packs/a4e1d094ec2aee8a08a4d6d95a13c634cc7d7394: |
| 84 |
y: |
| 85 |
Node Delta Base Delta Length Blob Size |
| 86 |
50dbc4572b8e 000000000000 3 3 |
| 87 |
|
| 88 |
Total: 3 3 (0.0% bigger) |
| 89 |
|
| 90 |
# Prefetch all data again and repack for later garbage collection |
| 91 |
|
| 92 |
$ cat >> .hg/hgrc <<EOF |
| 93 |
> [remotefilelog] |
| 94 |
> bgprefetchrevs=all() |
| 95 |
> EOF |
| 96 |
|
| 97 |
$ hg prefetch |
| 98 |
2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) |
| 99 |
$ hg repack |
| 100 |
|
| 101 |
$ find $CACHEDIR | sort | grep -E ".datapack|.histpack" |
| 102 |
$TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack |
| 103 |
$TESTTMP/hgcache/master/packs/dc8f8fdc76690ce27791ce9f53a18da379e50d37.datapack |
| 104 |
|
| 105 |
# Ensure that all file versions were prefetched |
| 106 |
|
| 107 |
$ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1` |
| 108 |
$TESTTMP/hgcache/master/packs/dc8f8fdc76690ce27791ce9f53a18da379e50d37: |
| 109 |
x: |
| 110 |
Node Delta Base Delta Length Blob Size |
| 111 |
1406e7411862 000000000000 2 2 |
| 112 |
|
| 113 |
Total: 2 2 (0.0% bigger) |
| 114 |
y: |
| 115 |
Node Delta Base Delta Length Blob Size |
| 116 |
50dbc4572b8e 000000000000 3 3 |
| 117 |
076f5e2225b3 50dbc4572b8e 14 2 |
| 118 |
|
| 119 |
Total: 17 5 (240.0% bigger) |
| 120 |
|
| 121 |
# Test garbage collection during repack. Ensure that new files are not removed even though they are not in the keepset |
| 122 |
# For the purposes of the test the TTL of a file is set to current time + 100 seconds. i.e. all commits in tests have |
| 123 |
# a date of 1970 and therefore to prevent garbage collection we have to set nodettl to be farther from 1970 than we are now. |
| 124 |
|
| 125 |
$ cat >> .hg/hgrc <<EOF |
| 126 |
> [remotefilelog] |
| 127 |
> bgprefetchrevs= |
| 128 |
> nodettl=$(($(date +%s) + 100)) |
| 129 |
> EOF |
| 130 |
|
| 131 |
$ hg repack |
| 132 |
|
| 133 |
$ find $CACHEDIR | sort | grep -E ".datapack|.histpack" |
| 134 |
$TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack |
| 135 |
$TESTTMP/hgcache/master/packs/dc8f8fdc76690ce27791ce9f53a18da379e50d37.datapack |
| 136 |
|
| 137 |
# Ensure that all file versions were prefetched |
| 138 |
|
| 139 |
$ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1` |
| 140 |
$TESTTMP/hgcache/master/packs/dc8f8fdc76690ce27791ce9f53a18da379e50d37: |
| 141 |
x: |
| 142 |
Node Delta Base Delta Length Blob Size |
| 143 |
1406e7411862 000000000000 2 2 |
| 144 |
|
| 145 |
Total: 2 2 (0.0% bigger) |
| 146 |
y: |
| 147 |
Node Delta Base Delta Length Blob Size |
| 148 |
50dbc4572b8e 000000000000 3 3 |
| 149 |
076f5e2225b3 50dbc4572b8e 14 2 |
| 150 |
|
| 151 |
Total: 17 5 (240.0% bigger) |