##// END OF EJS Templates
largefiles: test coverage of error handling from putlfile...
Mads Kiilerich -
r26824:30db531e stable
parent child Browse files
Show More
@@ -1,202 +1,233 b''
1 1 Create user cache directory
2 2
3 3 $ USERCACHE=`pwd`/cache; export USERCACHE
4 4 $ cat <<EOF >> ${HGRCPATH}
5 5 > [extensions]
6 6 > hgext.largefiles=
7 7 > [largefiles]
8 8 > usercache=${USERCACHE}
9 9 > EOF
10 10 $ mkdir -p ${USERCACHE}
11 11
12 12 Create source repo, and commit adding largefile.
13 13
14 14 $ hg init src
15 15 $ cd src
16 16 $ echo large > large
17 17 $ hg add --large large
18 18 $ hg commit -m 'add largefile'
19 19 $ hg rm large
20 20 $ hg commit -m 'branchhead without largefile'
21 21 $ hg up -qr 0
22 22 $ cd ..
23 23
24 24 Discard all cached largefiles in USERCACHE
25 25
26 26 $ rm -rf ${USERCACHE}
27 27
28 28 Create mirror repo, and pull from source without largefile:
29 29 "pull" is used instead of "clone" for suppression of (1) updating to
30 30 tip (= caching largefile from source repo), and (2) recording source
31 31 repo as "default" path in .hg/hgrc.
32 32
33 33 $ hg init mirror
34 34 $ cd mirror
35 35 $ hg pull ../src
36 36 pulling from ../src
37 37 requesting all changes
38 38 adding changesets
39 39 adding manifests
40 40 adding file changes
41 41 added 2 changesets with 1 changes to 1 files
42 42 (run 'hg update' to get a working copy)
43 43
44 44 Update working directory to "tip", which requires largefile("large"),
45 45 but there is no cache file for it. So, hg must treat it as
46 46 "missing"(!) file.
47 47
48 48 $ hg update -r0
49 49 getting changed largefiles
50 50 large: largefile 7f7097b041ccf68cc5561e9600da4655d21c6d18 not available from file:/*/$TESTTMP/mirror (glob)
51 51 0 largefiles updated, 0 removed
52 52 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
53 53 $ hg status
54 54 ! large
55 55
56 56 Update working directory to null: this cleanup .hg/largefiles/dirstate
57 57
58 58 $ hg update null
59 59 getting changed largefiles
60 60 0 largefiles updated, 0 removed
61 61 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
62 62
63 63 Update working directory to tip, again.
64 64
65 65 $ hg update -r0
66 66 getting changed largefiles
67 67 large: largefile 7f7097b041ccf68cc5561e9600da4655d21c6d18 not available from file:/*/$TESTTMP/mirror (glob)
68 68 0 largefiles updated, 0 removed
69 69 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
70 70 $ hg status
71 71 ! large
72 72 $ cd ..
73 73
74 74 Verify that largefiles from pulled branchheads are fetched, also to an empty repo
75 75
76 76 $ hg init mirror2
77 77 $ hg -R mirror2 pull src -r0
78 78 pulling from src
79 79 adding changesets
80 80 adding manifests
81 81 adding file changes
82 82 added 1 changesets with 1 changes to 1 files
83 83 (run 'hg update' to get a working copy)
84 84
85 85 #if unix-permissions
86 86
87 87 Portable way to print file permissions:
88 88
89 89 $ cat > ls-l.py <<EOF
90 90 > #!/usr/bin/env python
91 91 > import sys, os
92 92 > path = sys.argv[1]
93 93 > print '%03o' % (os.lstat(path).st_mode & 0777)
94 94 > EOF
95 95 $ chmod +x ls-l.py
96 96
97 97 Test that files in .hg/largefiles inherit mode from .hg/store, not
98 98 from file in working copy:
99 99
100 100 $ cd src
101 101 $ chmod 750 .hg/store
102 102 $ chmod 660 large
103 103 $ echo change >> large
104 104 $ hg commit -m change
105 105 created new head
106 106 $ ../ls-l.py .hg/largefiles/e151b474069de4ca6898f67ce2f2a7263adf8fea
107 107 640
108 108
109 109 Test permission of with files in .hg/largefiles created by update:
110 110
111 111 $ cd ../mirror
112 112 $ rm -r "$USERCACHE" .hg/largefiles # avoid links
113 113 $ chmod 750 .hg/store
114 114 $ hg pull ../src --update -q
115 115 $ ../ls-l.py .hg/largefiles/e151b474069de4ca6898f67ce2f2a7263adf8fea
116 116 640
117 117
118 118 Test permission of files created by push:
119 119
120 120 $ hg serve -R ../src -d -p $HGPORT --pid-file hg.pid \
121 121 > --config "web.allow_push=*" --config web.push_ssl=no
122 122 $ cat hg.pid >> $DAEMON_PIDS
123 123
124 124 $ echo change >> large
125 125 $ hg commit -m change
126 126
127 127 $ rm -r "$USERCACHE"
128 128
129 129 $ hg push -q http://localhost:$HGPORT/
130 130
131 131 $ ../ls-l.py ../src/.hg/largefiles/b734e14a0971e370408ab9bce8d56d8485e368a9
132 132 640
133 133
134 134 $ cd ..
135 135
136 136 #endif
137 137
138 138 Test issue 4053 (remove --after on a deleted, uncommitted file shouldn't say
139 139 it is missing, but a remove on a nonexistent unknown file still should. Same
140 140 for a forget.)
141 141
142 142 $ cd src
143 143 $ touch x
144 144 $ hg add x
145 145 $ mv x y
146 146 $ hg remove -A x y ENOENT
147 147 ENOENT: * (glob)
148 148 not removing y: file is untracked
149 149 [1]
150 150 $ hg add y
151 151 $ mv y z
152 152 $ hg forget y z ENOENT
153 153 ENOENT: * (glob)
154 154 not removing z: file is already untracked
155 155 [1]
156 156
157 157 Largefiles are accessible from the share's store
158 158 $ cd ..
159 159 $ hg share -q src share_dst --config extensions.share=
160 160 $ hg -R share_dst update -r0
161 161 getting changed largefiles
162 162 1 largefiles updated, 0 removed
163 163 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
164 164
165 165 $ echo modified > share_dst/large
166 166 $ hg -R share_dst ci -m modified
167 167 created new head
168 168
169 169 Only dirstate is in the local store for the share, and the largefile is in the
170 170 share source's local store. Avoid the extra largefiles added in the unix
171 171 conditional above.
172 172 $ hash=`hg -R share_dst cat share_dst/.hglf/large`
173 173 $ echo $hash
174 174 e2fb5f2139d086ded2cb600d5a91a196e76bf020
175 175
176 176 $ find share_dst/.hg/largefiles/* | sort
177 177 share_dst/.hg/largefiles/dirstate
178 178
179 179 $ find src/.hg/largefiles/* | egrep "(dirstate|$hash)" | sort
180 180 src/.hg/largefiles/dirstate
181 181 src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
182 182
183 183 Inject corruption into the largefiles store and see how update handles that:
184 184
185 185 $ cd src
186 186 $ hg up -qC
187 187 $ cat large
188 188 modified
189 189 $ rm large
190 190 $ cat .hglf/large
191 191 e2fb5f2139d086ded2cb600d5a91a196e76bf020
192 192 $ mv .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020 ..
193 193 $ echo corruption > .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
194 194 $ hg up -C
195 195 getting changed largefiles
196 196 large: data corruption in $TESTTMP/src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020 with hash 6a7bb2556144babe3899b25e5428123735bb1e27
197 197 0 largefiles updated, 0 removed
198 198 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
199 199 $ hg st
200 200 ! large
201 201 ? z
202 202 $ rm .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
203
204 #if serve
205
206 Test coverage of error handling from putlfile:
207
208 $ mkdir $TESTTMP/mirrorcache
209 $ hg serve -R ../mirror -d -p $HGPORT1 --pid-file hg.pid --config largefiles.usercache=$TESTTMP/mirrorcache
210 $ cat hg.pid >> $DAEMON_PIDS
211
212 (the following push fails but doesn't show why)
213 $ hg push http://localhost:$HGPORT1 -f --config files.usercache=nocache
214 pushing to http://localhost:$HGPORT1/
215 searching for changes
216 unexpected putlfile response: None
217 abort: remotestore: could not put $TESTTMP/src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020 to remote store http://localhost:$HGPORT1/
218 [255]
219
220 $ rm .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
221
222 Test coverage of 'missing from store':
223
224 $ hg serve -R ../mirror -d -p $HGPORT2 --pid-file hg.pid --config largefiles.usercache=$TESTTMP/mirrorcache --config "web.allow_push=*" --config web.push_ssl=no
225 $ cat hg.pid >> $DAEMON_PIDS
226
227 $ hg push http://localhost:$HGPORT2 -f --config largefiles.usercache=nocache
228 pushing to http://localhost:$HGPORT2/
229 searching for changes
230 abort: largefile e2fb5f2139d086ded2cb600d5a91a196e76bf020 missing from store (needs to be uploaded)
231 [255]
232
233 #endif
General Comments 0
You need to be logged in to leave comments. Login now