Debian Codegraph @

tests/test-lfs-bundle.t

raw
1 In this test, we want to test LFS bundle application on both LFS and non-LFS
2 repos.
3
4 To make it more interesting, the file revisions will contain hg filelog
5 metadata ('\1\n'). The bundle will have 1 file revision overlapping with the
6 destination repo.
7
8 # rev 1 2 3
9 # repo: yes yes no
10 # bundle: no (base) yes yes (deltabase: 2 if possible)
11
12 It is interesting because rev 2 could have been stored as LFS in the repo, and
13 non-LFS in the bundle; or vice-versa.
14
15 Init
16
17 $ cat >> $HGRCPATH << EOF
18 > [extensions]
19 > lfs=
20 > drawdag=$TESTDIR/drawdag.py
21 > [lfs]
22 > url=file:$TESTTMP/lfs-remote
23 > EOF
24
25 Helper functions
26
27 $ commitxy() {
28 > hg debugdrawdag "$@" <<'EOS'
29 > Y # Y/X=\1\nAAAA\nE\nF
30 > | # Y/Y=\1\nAAAA\nG\nH
31 > X # X/X=\1\nAAAA\nC\n
32 > # X/Y=\1\nAAAA\nD\n
33 > EOS
34 > }
35
36 $ commitz() {
37 > hg debugdrawdag "$@" <<'EOS'
38 > Z # Z/X=\1\nAAAA\nI\n
39 > | # Z/Y=\1\nAAAA\nJ\n
40 > | # Z/Z=\1\nZ
41 > Y
42 > EOS
43 > }
44
45 $ enablelfs() {
46 > cat >> .hg/hgrc <<EOF
47 > [lfs]
48 > track=all()
49 > EOF
50 > }
51
52 Generate bundles
53
54 $ for i in normal lfs; do
55 > NAME=src-$i
56 > hg init $TESTTMP/$NAME
57 > cd $TESTTMP/$NAME
58 > [ $i = lfs ] && enablelfs
59 > commitxy
60 > commitz
61 > hg bundle -q --base X -r Y+Z $TESTTMP/$NAME.bundle
62 > SRCNAMES="$SRCNAMES $NAME"
63 > done
64
65 Prepare destination repos
66
67 $ for i in normal lfs; do
68 > NAME=dst-$i
69 > hg init $TESTTMP/$NAME
70 > cd $TESTTMP/$NAME
71 > [ $i = lfs ] && enablelfs
72 > commitxy
73 > DSTNAMES="$DSTNAMES $NAME"
74 > done
75
76 Apply bundles
77
78 $ for i in $SRCNAMES; do
79 > for j in $DSTNAMES; do
80 > echo ---- Applying $i.bundle to $j ----
81 > cp -R $TESTTMP/$j $TESTTMP/tmp-$i-$j
82 > cd $TESTTMP/tmp-$i-$j
83 > if hg unbundle $TESTTMP/$i.bundle -q 2>/dev/null; then
84 > hg verify -q && echo OK
85 > else
86 > echo CRASHED
87 > fi
88 > done
89 > done
90 ---- Applying src-normal.bundle to dst-normal ----
91 OK
92 ---- Applying src-normal.bundle to dst-lfs ----
93 OK
94 ---- Applying src-lfs.bundle to dst-normal ----
95 OK
96 ---- Applying src-lfs.bundle to dst-lfs ----
97 OK
98
99
100 Test that the cache info can be printed. The 4 cases are:
101
102 1) The test-provided config path, with plain and json output
103 2) The test-provided config path, with plain and json output, but the cache disabled
104 3) A config provided path, with plain and json output
105 4) A config provided path, with plain and json output, but the cache disabled
106
107 $ hg debug::lfs-local-cache
108 path: $TESTTMP/.cache/lfs (glob)
109 enabled: yes
110 $ hg debug::lfs-local-cache -T json
111 [
112 {
113 "enabled": "yes",
114 "path": "$TESTTMP/.cache/lfs" (glob) (no-windows !)
115 "path": "$STR_REPR_TESTTMP\\.cache\\lfs" (windows !)
116 }
117 ]
118
119 $ hg debug::lfs-local-cache --config experimental.lfs.disableusercache=1
120 path: (unknown)
121 enabled: no
122 $ hg debug::lfs-local-cache --config experimental.lfs.disableusercache=1 \
123 > -T json
124 [
125 {
126 "enabled": "no",
127 "path": ""
128 }
129 ]
130
131 $ hg debug::lfs-local-cache --config lfs.usercache=relpath
132 path: $TESTTMP/tmp-src-lfs-dst-lfs/relpath
133 enabled: yes
134 $ hg debug::lfs-local-cache --config lfs.usercache=relpath -T json
135 [
136 {
137 "enabled": "yes",
138 "path": "$TESTTMP/tmp-src-lfs-dst-lfs/relpath" (no-windows !)
139 "path": "$STR_REPR_TESTTMP\\tmp-src-lfs-dst-lfs\\relpath" (windows !)
140 }
141 ]
142
143 $ hg debug::lfs-local-cache --config lfs.usercache=relpath \
144 > --config experimental.lfs.disableusercache=1
145 path: (unknown)
146 enabled: no
147 $ hg debug::lfs-local-cache --config lfs.usercache=relpath \
148 > --config experimental.lfs.disableusercache=1 \
149 > -T json
150 [
151 {
152 "enabled": "no",
153 "path": ""
154 }
155 ]
156
157
158 Hint if the cache location cannot be inferred from the environment
159
160 #if windows
161 $ unset LOCALAPPDATA
162 $ unset APPDATA
163 $ HGRCPATH= hg config lfs --source
164 abort: unknown lfs usercache location
165 (define LOCALAPPDATA or APPDATA in the environment, or set lfs.usercache)
166 [255]
167 #endif
168
169 #if osx
170 $ unset HOME
171 $ HGRCPATH= hg config lfs --source
172 abort: unknown lfs usercache location
173 (define HOME in the environment, or set lfs.usercache)
174 [255]
175 #endif
176
177 #if no-windows no-osx
178 $ unset XDG_CACHE_HOME
179 $ unset HOME
180 $ HGRCPATH= hg config lfs --source
181 abort: unknown lfs usercache location
182 (define XDG_CACHE_HOME or HOME in the environment, or set lfs.usercache)
183 [255]
184 #endif
185