| 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 |
> serverexpiration=-1 |
| 11 |
> EOF |
| 12 |
$ echo x > x |
| 13 |
$ hg commit -qAm x |
| 14 |
$ cd .. |
| 15 |
|
| 16 |
$ hgcloneshallow ssh://user@dummy/master shallow -q |
| 17 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
| 18 |
|
| 19 |
# Set the prefetchdays config to zero so that all commits are prefetched |
| 20 |
# no matter what their creation date is. |
| 21 |
$ cd shallow |
| 22 |
$ cat >> .hg/hgrc <<EOF |
| 23 |
> [remotefilelog] |
| 24 |
> prefetchdays=0 |
| 25 |
> EOF |
| 26 |
$ cd .. |
| 27 |
|
| 28 |
# commit a new version of x so we can gc the old one |
| 29 |
|
| 30 |
$ cd master |
| 31 |
$ echo y > x |
| 32 |
$ hg commit -qAm y |
| 33 |
$ cd .. |
| 34 |
|
| 35 |
$ cd shallow |
| 36 |
$ hg pull -q |
| 37 |
$ hg update -q |
| 38 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
| 39 |
$ cd .. |
| 40 |
|
| 41 |
# gc client cache |
| 42 |
|
| 43 |
$ lastweek=`"$PYTHON" -c 'import datetime,time; print(datetime.datetime.fromtimestamp(time.time() - (86400 * 7)).strftime("%y%m%d%H%M"))'` |
| 44 |
$ find $CACHEDIR -type f -exec touch -t $lastweek {} \; |
| 45 |
|
| 46 |
$ find $CACHEDIR -type f | sort |
| 47 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/1406e74118627694268417491f018a4a883152f0 (glob) |
| 48 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/48023ec064c1d522f0d792a5a912bb1bf7859a4a (glob) |
| 49 |
$TESTTMP/hgcache/repos (glob) |
| 50 |
$ hg gc |
| 51 |
finished: removed 1 of 2 files (0.00 GB to 0.00 GB) |
| 52 |
$ find $CACHEDIR -type f | sort |
| 53 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/48023ec064c1d522f0d792a5a912bb1bf7859a4a (glob) |
| 54 |
$TESTTMP/hgcache/repos |
| 55 |
|
| 56 |
# gc server cache |
| 57 |
|
| 58 |
$ find master/.hg/remotefilelogcache -type f | sort |
| 59 |
master/.hg/remotefilelogcache/x/1406e74118627694268417491f018a4a883152f0 (glob) |
| 60 |
master/.hg/remotefilelogcache/x/48023ec064c1d522f0d792a5a912bb1bf7859a4a (glob) |
| 61 |
$ hg gc master |
| 62 |
finished: removed 0 of 1 files (0.00 GB to 0.00 GB) |
| 63 |
$ find master/.hg/remotefilelogcache -type f | sort |
| 64 |
master/.hg/remotefilelogcache/x/48023ec064c1d522f0d792a5a912bb1bf7859a4a (glob) |
| 65 |
|
| 66 |
# Test that GC keepset includes pullprefetch revset if it is configured |
| 67 |
|
| 68 |
$ cd shallow |
| 69 |
$ cat >> .hg/hgrc <<EOF |
| 70 |
> [remotefilelog] |
| 71 |
> pullprefetch=all() |
| 72 |
> EOF |
| 73 |
$ hg prefetch |
| 74 |
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
| 75 |
|
| 76 |
$ cd .. |
| 77 |
$ hg gc |
| 78 |
finished: removed 0 of 2 files (0.00 GB to 0.00 GB) |
| 79 |
|
| 80 |
# Ensure that there are 2 versions of the file in cache |
| 81 |
$ find $CACHEDIR -type f | sort |
| 82 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/1406e74118627694268417491f018a4a883152f0 (glob) |
| 83 |
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/48023ec064c1d522f0d792a5a912bb1bf7859a4a (glob) |
| 84 |
$TESTTMP/hgcache/repos (glob) |
| 85 |
|
| 86 |
# Test that if garbage collection on repack and repack on hg gc flags are set then incremental repack with garbage collector is run |
| 87 |
|
| 88 |
$ hg gc --config remotefilelog.gcrepack=True --config remotefilelog.repackonhggc=True |
| 89 |
|
| 90 |
# Ensure that loose files are repacked |
| 91 |
$ find $CACHEDIR -type f | sort |
| 92 |
$TESTTMP/hgcache/master/packs/320dab99b7e3f60512b97f347689625263d22cf5.dataidx |
| 93 |
$TESTTMP/hgcache/master/packs/320dab99b7e3f60512b97f347689625263d22cf5.datapack |
| 94 |
$TESTTMP/hgcache/master/packs/837b83c1ef6485a336eb4421ac5973c0ec130fbb.histidx |
| 95 |
$TESTTMP/hgcache/master/packs/837b83c1ef6485a336eb4421ac5973c0ec130fbb.histpack |
| 96 |
$TESTTMP/hgcache/repos |
| 97 |
|
| 98 |
# Test that warning is displayed when there are no valid repos in repofile |
| 99 |
|
| 100 |
$ cp $CACHEDIR/repos $CACHEDIR/repos.bak |
| 101 |
$ echo " " > $CACHEDIR/repos |
| 102 |
$ hg gc |
| 103 |
warning: no valid repos in repofile |
| 104 |
$ mv $CACHEDIR/repos.bak $CACHEDIR/repos |
| 105 |
|
| 106 |
# Test that warning is displayed when the repo path is malformed |
| 107 |
|
| 108 |
$ printf "asdas\0das" >> $CACHEDIR/repos |
| 109 |
$ hg gc |
| 110 |
abort: invalid path asdas\x00da: .*(null|NULL).* (re) |
| 111 |
[255] |