comparison tests/test-remotefilelog-gc.t @ 40495:3a333a582d7b

remotefilelog: import pruned-down remotefilelog extension from hg-experimental This is remotefilelog as of my recent patches for compatibility with current tip of hg, minus support for old versions of Mercurial and some FB-specific features like their treemanifest extension and fetching linkrev data from a patched phabricator. The file extutil.py moved from hgext3rd to remotefilelog. This is not yet ready to be landed, consider it a preview for now. Planned changes include: * replace lz4 with zstd * rename some capabilities, requirements and wireproto commands to mark them as experimental * consolidate bits of shallowutil with related functions (eg readfile) I'm certainly open to other (small) changes, but my rough mission is to land this largely as-is so we can use it as a model of the functionality we need going forward for lazy-fetching of file contents from a server. # no-check-commit because of a few foo_bar functions Differential Revision: https://phab.mercurial-scm.org/D4782
author Augie Fackler <augie@google.com>
date Thu, 27 Sep 2018 13:03:19 -0400
parents
children 10c10da14c5d
comparison
equal deleted inserted replaced
40494:9aeb9e2d28a7 40495:3a333a582d7b
1 $ PYTHONPATH=$TESTDIR/..:$PYTHONPATH
2 $ export PYTHONPATH
3
4 $ . "$TESTDIR/remotefilelog-library.sh"
5
6 $ hginit master
7 $ cd master
8 $ cat >> .hg/hgrc <<EOF
9 > [remotefilelog]
10 > server=True
11 > serverexpiration=-1
12 > EOF
13 $ echo x > x
14 $ hg commit -qAm x
15 $ cd ..
16
17 $ hgcloneshallow ssh://user@dummy/master shallow -q
18 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
19
20 # Set the prefetchdays config to zero so that all commits are prefetched
21 # no matter what their creation date is.
22 $ cd shallow
23 $ cat >> .hg/hgrc <<EOF
24 > [remotefilelog]
25 > prefetchdays=0
26 > EOF
27 $ cd ..
28
29 # commit a new version of x so we can gc the old one
30
31 $ cd master
32 $ echo y > x
33 $ hg commit -qAm y
34 $ cd ..
35
36 $ cd shallow
37 $ hg pull -q
38 $ hg update -q
39 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
40 $ cd ..
41
42 # gc client cache
43
44 $ lastweek=`$PYTHON -c 'import datetime,time; print(datetime.datetime.fromtimestamp(time.time() - (86400 * 7)).strftime("%y%m%d%H%M"))'`
45 $ find $CACHEDIR -type f -exec touch -t $lastweek {} \;
46
47 $ find $CACHEDIR -type f | sort
48 $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/1406e74118627694268417491f018a4a883152f0 (glob)
49 $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/48023ec064c1d522f0d792a5a912bb1bf7859a4a (glob)
50 $TESTTMP/hgcache/repos (glob)
51 $ hg gc
52 finished: removed 1 of 2 files (0.00 GB to 0.00 GB)
53 $ find $CACHEDIR -type f | sort
54 $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/48023ec064c1d522f0d792a5a912bb1bf7859a4a (glob)
55 $TESTTMP/hgcache/repos
56
57 # gc server cache
58
59 $ find master/.hg/remotefilelogcache -type f | sort
60 master/.hg/remotefilelogcache/x/1406e74118627694268417491f018a4a883152f0 (glob)
61 master/.hg/remotefilelogcache/x/48023ec064c1d522f0d792a5a912bb1bf7859a4a (glob)
62 $ hg gc master
63 finished: removed 0 of 1 files (0.00 GB to 0.00 GB)
64 $ find master/.hg/remotefilelogcache -type f | sort
65 master/.hg/remotefilelogcache/x/48023ec064c1d522f0d792a5a912bb1bf7859a4a (glob)
66
67 # Test that GC keepset includes pullprefetch revset if it is configured
68
69 $ cd shallow
70 $ cat >> .hg/hgrc <<EOF
71 > [remotefilelog]
72 > pullprefetch=all()
73 > EOF
74 $ hg prefetch
75 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
76
77 $ cd ..
78 $ hg gc
79 finished: removed 0 of 2 files (0.00 GB to 0.00 GB)
80
81 # Ensure that there are 2 versions of the file in cache
82 $ find $CACHEDIR -type f | sort
83 $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/1406e74118627694268417491f018a4a883152f0 (glob)
84 $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/48023ec064c1d522f0d792a5a912bb1bf7859a4a (glob)
85 $TESTTMP/hgcache/repos (glob)
86
87 # Test that if garbage collection on repack and repack on hg gc flags are set then incremental repack with garbage collector is run
88
89 $ hg gc --config remotefilelog.gcrepack=True --config remotefilelog.repackonhggc=True
90
91 # Ensure that loose files are repacked
92 $ find $CACHEDIR -type f | sort
93 $TESTTMP/hgcache/master/packs/8d3499c65d926e4f107cf03c6b0df833222025b4.histidx
94 $TESTTMP/hgcache/master/packs/8d3499c65d926e4f107cf03c6b0df833222025b4.histpack
95 $TESTTMP/hgcache/master/packs/9c7046f8cad0417c39aa7c03ce13e0ba991306c2.dataidx
96 $TESTTMP/hgcache/master/packs/9c7046f8cad0417c39aa7c03ce13e0ba991306c2.datapack
97 $TESTTMP/hgcache/master/packs/repacklock
98 $TESTTMP/hgcache/repos
99
100 # Test that warning is displayed when there are no valid repos in repofile
101
102 $ cp $CACHEDIR/repos $CACHEDIR/repos.bak
103 $ echo " " > $CACHEDIR/repos
104 $ hg gc
105 warning: no valid repos in repofile
106 $ mv $CACHEDIR/repos.bak $CACHEDIR/repos
107
108 # Test that warning is displayed when the repo path is malformed
109
110 $ printf "asdas\0das" >> $CACHEDIR/repos
111 $ hg gc 2>&1 | head -n2
112 warning: malformed path: * (glob)
113 Traceback (most recent call last):