| 1 |
#require no-windows |
| 2 |
|
| 3 |
$ . "$TESTDIR/remotefilelog-library.sh" |
| 4 |
|
| 5 |
$ cat >> $HGRCPATH <<EOF |
| 6 |
> [remotefilelog] |
| 7 |
> fastdatapack=True |
| 8 |
> [devel] |
| 9 |
> remotefilelog.bg-wait=True |
| 10 |
> EOF |
| 11 |
|
| 12 |
$ hg init master |
| 13 |
$ cd master |
| 14 |
$ cat >> .hg/hgrc <<EOF |
| 15 |
> [remotefilelog] |
| 16 |
> server=True |
| 17 |
> serverexpiration=-1 |
| 18 |
> EOF |
| 19 |
$ echo x > x |
| 20 |
$ hg commit -qAm x |
| 21 |
$ echo x >> x |
| 22 |
$ hg commit -qAm x2 |
| 23 |
$ cd .. |
| 24 |
|
| 25 |
$ hgcloneshallow ssh://user@dummy/master shallow -q |
| 26 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
| 27 |
|
| 28 |
# Set the prefetchdays config to zero so that all commits are prefetched |
| 29 |
# no matter what their creation date is. |
| 30 |
$ cd shallow |
| 31 |
$ cat >> .hg/hgrc <<EOF |
| 32 |
> [remotefilelog] |
| 33 |
> prefetchdays=0 |
| 34 |
> EOF |
| 35 |
$ cd .. |
| 36 |
|
| 37 |
# Test that repack cleans up the old files and creates new packs |
| 38 |
|
| 39 |
$ cd shallow |
| 40 |
$ find $CACHEDIR | sort |
| 41 |
$TESTTMP/hgcache |
| 42 |
$TESTTMP/hgcache/master |
| 43 |
$TESTTMP/hgcache/master/11 |
| 44 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072 |
| 45 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/aee31534993a501858fb6dd96a065671922e7d51 |
| 46 |
$TESTTMP/hgcache/repos |
| 47 |
|
| 48 |
$ hg repack |
| 49 |
|
| 50 |
$ find $CACHEDIR | sort |
| 51 |
$TESTTMP/hgcache |
| 52 |
$TESTTMP/hgcache/master |
| 53 |
$TESTTMP/hgcache/master/packs |
| 54 |
$TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histidx |
| 55 |
$TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histpack |
| 56 |
$TESTTMP/hgcache/master/packs/b1e0cfc7f345e408a7825e3081501959488d59ce.dataidx |
| 57 |
$TESTTMP/hgcache/master/packs/b1e0cfc7f345e408a7825e3081501959488d59ce.datapack |
| 58 |
$TESTTMP/hgcache/repos |
| 59 |
|
| 60 |
# Test that the packs are readonly |
| 61 |
$ ls_l $CACHEDIR/master/packs |
| 62 |
-r--r--r-- 1145 1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histidx |
| 63 |
-r--r--r-- 172 1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histpack |
| 64 |
-r--r--r-- 1074 b1e0cfc7f345e408a7825e3081501959488d59ce.dataidx |
| 65 |
-r--r--r-- 72 b1e0cfc7f345e408a7825e3081501959488d59ce.datapack |
| 66 |
|
| 67 |
# Test that the data in the new packs is accessible |
| 68 |
$ hg cat -r . x |
| 69 |
x |
| 70 |
x |
| 71 |
|
| 72 |
# Test that adding new data and repacking it results in the loose data and the |
| 73 |
# old packs being combined. |
| 74 |
|
| 75 |
$ cd ../master |
| 76 |
$ echo x >> x |
| 77 |
$ hg commit -m x3 |
| 78 |
$ cd ../shallow |
| 79 |
$ hg pull -q |
| 80 |
$ hg up -q tip |
| 81 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 82 |
|
| 83 |
$ find $CACHEDIR -type f | sort |
| 84 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/d4a3ed9310e5bd9887e3bf779da5077efab28216 |
| 85 |
$TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histidx |
| 86 |
$TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histpack |
| 87 |
$TESTTMP/hgcache/master/packs/b1e0cfc7f345e408a7825e3081501959488d59ce.dataidx |
| 88 |
$TESTTMP/hgcache/master/packs/b1e0cfc7f345e408a7825e3081501959488d59ce.datapack |
| 89 |
$TESTTMP/hgcache/repos |
| 90 |
|
| 91 |
$ hg repack --traceback |
| 92 |
|
| 93 |
$ find $CACHEDIR -type f | sort |
| 94 |
$TESTTMP/hgcache/master/packs/78840d69389c7404327f7477e3931c89945c37d1.dataidx |
| 95 |
$TESTTMP/hgcache/master/packs/78840d69389c7404327f7477e3931c89945c37d1.datapack |
| 96 |
$TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histidx |
| 97 |
$TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack |
| 98 |
$TESTTMP/hgcache/repos |
| 99 |
|
| 100 |
# Verify all the file data is still available |
| 101 |
$ hg cat -r . x |
| 102 |
x |
| 103 |
x |
| 104 |
x |
| 105 |
$ hg cat -r '.^' x |
| 106 |
x |
| 107 |
x |
| 108 |
|
| 109 |
# Test that repacking again without new data does not delete the pack files |
| 110 |
# and did not change the pack names |
| 111 |
$ hg repack |
| 112 |
$ find $CACHEDIR -type f | sort |
| 113 |
$TESTTMP/hgcache/master/packs/78840d69389c7404327f7477e3931c89945c37d1.dataidx |
| 114 |
$TESTTMP/hgcache/master/packs/78840d69389c7404327f7477e3931c89945c37d1.datapack |
| 115 |
$TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histidx |
| 116 |
$TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack |
| 117 |
$TESTTMP/hgcache/repos |
| 118 |
|
| 119 |
# Run two repacks at once |
| 120 |
$ hg repack --config "hooks.prerepack=sleep 3" & |
| 121 |
$ sleep 1 |
| 122 |
$ hg repack |
| 123 |
skipping repack - another repack is already running |
| 124 |
$ hg debugwaitonrepack >/dev/null 2>&1 |
| 125 |
|
| 126 |
# Run repack in the background |
| 127 |
$ cd ../master |
| 128 |
$ echo x >> x |
| 129 |
$ hg commit -m x4 |
| 130 |
$ cd ../shallow |
| 131 |
$ hg pull -q |
| 132 |
$ hg up -q tip |
| 133 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 134 |
$ find $CACHEDIR -type f | sort |
| 135 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/1bb2e6237e035c8f8ef508e281f1ce075bc6db72 |
| 136 |
$TESTTMP/hgcache/master/packs/78840d69389c7404327f7477e3931c89945c37d1.dataidx |
| 137 |
$TESTTMP/hgcache/master/packs/78840d69389c7404327f7477e3931c89945c37d1.datapack |
| 138 |
$TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histidx |
| 139 |
$TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack |
| 140 |
$TESTTMP/hgcache/repos |
| 141 |
|
| 142 |
$ hg repack --background |
| 143 |
(running background repack) |
| 144 |
$ find $CACHEDIR -type f | sort |
| 145 |
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0.dataidx |
| 146 |
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0.datapack |
| 147 |
$TESTTMP/hgcache/master/packs/604552d403a1381749faf656feca0ca265a6d52c.histidx |
| 148 |
$TESTTMP/hgcache/master/packs/604552d403a1381749faf656feca0ca265a6d52c.histpack |
| 149 |
$TESTTMP/hgcache/repos |
| 150 |
|
| 151 |
# Test debug commands |
| 152 |
|
| 153 |
$ hg debugdatapack $TESTTMP/hgcache/master/packs/*.datapack |
| 154 |
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0: |
| 155 |
x: |
| 156 |
Node Delta Base Delta Length Blob Size |
| 157 |
1bb2e6237e03 000000000000 8 8 |
| 158 |
d4a3ed9310e5 1bb2e6237e03 12 6 |
| 159 |
aee31534993a d4a3ed9310e5 12 4 |
| 160 |
|
| 161 |
Total: 32 18 (77.8% bigger) |
| 162 |
$ hg debugdatapack --long $TESTTMP/hgcache/master/packs/*.datapack |
| 163 |
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0: |
| 164 |
x: |
| 165 |
Node Delta Base Delta Length Blob Size |
| 166 |
1bb2e6237e035c8f8ef508e281f1ce075bc6db72 0000000000000000000000000000000000000000 8 8 |
| 167 |
d4a3ed9310e5bd9887e3bf779da5077efab28216 1bb2e6237e035c8f8ef508e281f1ce075bc6db72 12 6 |
| 168 |
aee31534993a501858fb6dd96a065671922e7d51 d4a3ed9310e5bd9887e3bf779da5077efab28216 12 4 |
| 169 |
|
| 170 |
Total: 32 18 (77.8% bigger) |
| 171 |
$ hg debugdatapack $TESTTMP/hgcache/master/packs/*.datapack --node d4a3ed9310e5bd9887e3bf779da5077efab28216 |
| 172 |
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0: |
| 173 |
|
| 174 |
x |
| 175 |
Node Delta Base Delta SHA1 Delta Length |
| 176 |
d4a3ed9310e5bd9887e3bf779da5077efab28216 1bb2e6237e035c8f8ef508e281f1ce075bc6db72 77029ab56e83ea2115dd53ff87483682abe5d7ca 12 |
| 177 |
Node Delta Base Delta SHA1 Delta Length |
| 178 |
1bb2e6237e035c8f8ef508e281f1ce075bc6db72 0000000000000000000000000000000000000000 7ca8c71a64f7b56380e77573da2f7a5fdd2ecdb5 8 |
| 179 |
$ hg debughistorypack $TESTTMP/hgcache/master/packs/*.histidx |
| 180 |
|
| 181 |
x |
| 182 |
Node P1 Node P2 Node Link Node Copy From |
| 183 |
1bb2e6237e03 d4a3ed9310e5 000000000000 0b03bbc9e1e7 |
| 184 |
d4a3ed9310e5 aee31534993a 000000000000 421535db10b6 |
| 185 |
aee31534993a 1406e7411862 000000000000 a89d614e2364 |
| 186 |
1406e7411862 000000000000 000000000000 b292c1e3311f |
| 187 |
|
| 188 |
# Test copy tracing from a pack |
| 189 |
$ cd ../master |
| 190 |
$ hg mv x y |
| 191 |
$ hg commit -m 'move x to y' |
| 192 |
$ cd ../shallow |
| 193 |
$ hg pull -q |
| 194 |
$ hg up -q tip |
| 195 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 196 |
$ hg repack |
| 197 |
$ hg log -f y -T '{desc}\n' |
| 198 |
move x to y |
| 199 |
x4 |
| 200 |
x3 |
| 201 |
x2 |
| 202 |
x |
| 203 |
|
| 204 |
# Test copy trace across rename and back |
| 205 |
$ cp -R $TESTTMP/hgcache/master/packs $TESTTMP/backuppacks |
| 206 |
$ cd ../master |
| 207 |
$ hg mv y x |
| 208 |
$ hg commit -m 'move y back to x' |
| 209 |
$ hg revert -r 0 x |
| 210 |
$ mv x y |
| 211 |
$ hg add y |
| 212 |
$ echo >> y |
| 213 |
$ hg revert x |
| 214 |
$ hg commit -m 'add y back without metadata' |
| 215 |
$ cd ../shallow |
| 216 |
$ hg pull -q |
| 217 |
$ hg up -q tip |
| 218 |
2 files fetched over 2 fetches - (2 misses, 0.00% hit ratio) over * (glob) |
| 219 |
$ hg repack |
| 220 |
$ ls $TESTTMP/hgcache/master/packs |
| 221 |
bfd60adb76018bb952e27cd23fc151bf94865d7d.histidx |
| 222 |
bfd60adb76018bb952e27cd23fc151bf94865d7d.histpack |
| 223 |
fb3aa57b22789ebcc45706c352e2d6af099c5816.dataidx |
| 224 |
fb3aa57b22789ebcc45706c352e2d6af099c5816.datapack |
| 225 |
$ hg debughistorypack $TESTTMP/hgcache/master/packs/*.histidx |
| 226 |
|
| 227 |
x |
| 228 |
Node P1 Node P2 Node Link Node Copy From |
| 229 |
cd410a44d584 577959738234 000000000000 609547eda446 y |
| 230 |
1bb2e6237e03 d4a3ed9310e5 000000000000 0b03bbc9e1e7 |
| 231 |
d4a3ed9310e5 aee31534993a 000000000000 421535db10b6 |
| 232 |
aee31534993a 1406e7411862 000000000000 a89d614e2364 |
| 233 |
1406e7411862 000000000000 000000000000 b292c1e3311f |
| 234 |
|
| 235 |
y |
| 236 |
Node P1 Node P2 Node Link Node Copy From |
| 237 |
577959738234 1bb2e6237e03 000000000000 c7faf2fc439a x |
| 238 |
21f46f2721e7 000000000000 000000000000 d6868642b790 |
| 239 |
$ hg strip -r '.^' |
| 240 |
1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 241 |
saved backup bundle to $TESTTMP/shallow/.hg/strip-backup/609547eda446-b26b56a8-backup.hg (glob) |
| 242 |
$ hg -R ../master strip -r '.^' |
| 243 |
1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 244 |
saved backup bundle to $TESTTMP/master/.hg/strip-backup/609547eda446-b26b56a8-backup.hg (glob) |
| 245 |
|
| 246 |
$ rm -rf $TESTTMP/hgcache/master/packs |
| 247 |
$ cp -R $TESTTMP/backuppacks $TESTTMP/hgcache/master/packs |
| 248 |
|
| 249 |
# Test repacking datapack without history |
| 250 |
$ rm -rf $CACHEDIR/master/packs/*hist* |
| 251 |
$ hg repack |
| 252 |
$ hg debugdatapack $TESTTMP/hgcache/master/packs/*.datapack |
| 253 |
$TESTTMP/hgcache/master/packs/922aca43dbbeda4d250565372e8892ec7b08da6a: |
| 254 |
x: |
| 255 |
Node Delta Base Delta Length Blob Size |
| 256 |
1bb2e6237e03 000000000000 8 8 |
| 257 |
d4a3ed9310e5 1bb2e6237e03 12 6 |
| 258 |
aee31534993a d4a3ed9310e5 12 4 |
| 259 |
|
| 260 |
Total: 32 18 (77.8% bigger) |
| 261 |
y: |
| 262 |
Node Delta Base Delta Length Blob Size |
| 263 |
577959738234 000000000000 70 8 |
| 264 |
|
| 265 |
Total: 70 8 (775.0% bigger) |
| 266 |
|
| 267 |
$ hg cat -r ".^" x |
| 268 |
x |
| 269 |
x |
| 270 |
x |
| 271 |
x |
| 272 |
|
| 273 |
Incremental repack |
| 274 |
$ rm -rf $CACHEDIR/master/packs/* |
| 275 |
$ cat >> .hg/hgrc <<EOF |
| 276 |
> [remotefilelog] |
| 277 |
> data.generations=60 |
| 278 |
> 150 |
| 279 |
> EOF |
| 280 |
|
| 281 |
Single pack - repack does nothing |
| 282 |
$ hg prefetch -r 0 |
| 283 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 284 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack |
| 285 |
[1] |
| 286 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack |
| 287 |
[1] |
| 288 |
$ hg repack --incremental |
| 289 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack |
| 290 |
-r--r--r-- 70 052643fdcdebbd42d7c180a651a30d46098e6fe1.datapack |
| 291 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack |
| 292 |
-r--r--r-- 90 955a622173324b2d8b53e1147f209f1cf125302e.histpack |
| 293 |
|
| 294 |
3 gen1 packs, 1 gen0 pack - packs 3 gen1 into 1 |
| 295 |
$ hg prefetch -r 1 |
| 296 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 297 |
$ hg prefetch -r 2 |
| 298 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 299 |
$ hg prefetch -r 3 |
| 300 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 301 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack |
| 302 |
-r--r--r-- 70 052643fdcdebbd42d7c180a651a30d46098e6fe1.datapack |
| 303 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack |
| 304 |
-r--r--r-- 90 955a622173324b2d8b53e1147f209f1cf125302e.histpack |
| 305 |
$ hg repack --incremental |
| 306 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack |
| 307 |
-r--r--r-- 70 052643fdcdebbd42d7c180a651a30d46098e6fe1.datapack |
| 308 |
-r--r--r-- 226 39443fa1064182e93d968b5cba292eb5283260d0.datapack |
| 309 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack |
| 310 |
-r--r--r-- 336 604552d403a1381749faf656feca0ca265a6d52c.histpack |
| 311 |
-r--r--r-- 90 955a622173324b2d8b53e1147f209f1cf125302e.histpack |
| 312 |
|
| 313 |
1 gen3 pack, 1 gen0 pack - does nothing |
| 314 |
$ hg repack --incremental |
| 315 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack |
| 316 |
-r--r--r-- 70 052643fdcdebbd42d7c180a651a30d46098e6fe1.datapack |
| 317 |
-r--r--r-- 226 39443fa1064182e93d968b5cba292eb5283260d0.datapack |
| 318 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack |
| 319 |
-r--r--r-- 336 604552d403a1381749faf656feca0ca265a6d52c.histpack |
| 320 |
-r--r--r-- 90 955a622173324b2d8b53e1147f209f1cf125302e.histpack |
| 321 |
|
| 322 |
Pull should run background repack |
| 323 |
$ cat >> .hg/hgrc <<EOF |
| 324 |
> [remotefilelog] |
| 325 |
> backgroundrepack=True |
| 326 |
> EOF |
| 327 |
$ clearcache |
| 328 |
$ hg prefetch -r 0 |
| 329 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 330 |
$ hg prefetch -r 1 |
| 331 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 332 |
$ hg prefetch -r 2 |
| 333 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 334 |
$ hg prefetch -r 3 |
| 335 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 336 |
|
| 337 |
$ hg pull |
| 338 |
pulling from ssh://user@dummy/master |
| 339 |
searching for changes |
| 340 |
no changes found |
| 341 |
(running background incremental repack) |
| 342 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack |
| 343 |
-r--r--r-- 303 156a6c1c83aeb69422d7936e0a46ba9bc06a71c0.datapack |
| 344 |
$ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack |
| 345 |
-r--r--r-- 336 604552d403a1381749faf656feca0ca265a6d52c.histpack |
| 346 |
|
| 347 |
Test environment variable resolution |
| 348 |
$ CACHEPATH=$TESTTMP/envcache hg prefetch --config 'remotefilelog.cachepath=$CACHEPATH' |
| 349 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 350 |
$ find $TESTTMP/envcache | sort |
| 351 |
$TESTTMP/envcache |
| 352 |
$TESTTMP/envcache/master |
| 353 |
$TESTTMP/envcache/master/95 |
| 354 |
$TESTTMP/envcache/master/95/cb0bfd2977c761298d9624e4b4d4c72a39974a |
| 355 |
$TESTTMP/envcache/master/95/cb0bfd2977c761298d9624e4b4d4c72a39974a/577959738234a1eb241ed3ed4b22a575833f56e0 |
| 356 |
$TESTTMP/envcache/repos |
| 357 |
|
| 358 |
Test local remotefilelog blob is correct when based on a pack |
| 359 |
$ hg prefetch -r . |
| 360 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
| 361 |
$ echo >> y |
| 362 |
$ hg commit -m y2 |
| 363 |
$ hg debugremotefilelog .hg/store/data/95cb0bfd2977c761298d9624e4b4d4c72a39974a/b70860edba4f8242a1d52f2a94679dd23cb76808 |
| 364 |
size: 9 bytes |
| 365 |
path: .hg/store/data/95cb0bfd2977c761298d9624e4b4d4c72a39974a/b70860edba4f8242a1d52f2a94679dd23cb76808 |
| 366 |
key: b70860edba4f |
| 367 |
|
| 368 |
node => p1 p2 linknode copyfrom |
| 369 |
b70860edba4f => 577959738234 000000000000 08d3fbc98c48 |
| 370 |
577959738234 => 1bb2e6237e03 000000000000 c7faf2fc439a x |
| 371 |
1bb2e6237e03 => d4a3ed9310e5 000000000000 0b03bbc9e1e7 |
| 372 |
d4a3ed9310e5 => aee31534993a 000000000000 421535db10b6 |
| 373 |
aee31534993a => 1406e7411862 000000000000 a89d614e2364 |
| 374 |
1406e7411862 => 000000000000 000000000000 b292c1e3311f |