##// END OF EJS Templates
largefiles: display remote errors from putlfile (issue3123) (issue3149)
Kevin Gessner -
r15778:f15c646b default
parent child Browse files
Show More
@@ -1,161 +1,167
1 1 # Copyright 2011 Fog Creek Software
2 2 #
3 3 # This software may be used and distributed according to the terms of the
4 4 # GNU General Public License version 2 or any later version.
5 5
6 6 import os
7 7 import urllib2
8 8
9 9 from mercurial import error, httprepo, util, wireproto
10 10 from mercurial.i18n import _
11 11
12 12 import lfutil
13 13
14 14 LARGEFILES_REQUIRED_MSG = ('\nThis repository uses the largefiles extension.'
15 15 '\n\nPlease enable it in your Mercurial config '
16 16 'file.\n')
17 17
18 18 def putlfile(repo, proto, sha):
19 19 '''Put a largefile into a repository's local store and into the
20 20 user cache.'''
21 21 proto.redirect()
22 22
23 23 fd, tmpname = lfutil.mkstemp(repo, prefix='hg-putlfile')
24 24 tmpfp = os.fdopen(fd, 'wb+')
25 25 try:
26 26 try:
27 27 proto.getfile(tmpfp)
28 28 tmpfp.seek(0)
29 29 if sha != lfutil.hexsha1(tmpfp):
30 return wireproto.pushres(1)
30 raise IOError(0, _('largefile contents do not match hash'))
31 31 tmpfp.close()
32 32 lfutil.copytostoreabsolute(repo, tmpname, sha)
33 33 except IOError, e:
34 repo.ui.warn(_('largefiles: failed to put %s (%s) into store: %s') %
35 (sha, tmpname, e.strerror))
34 repo.ui.warn(_('largefiles: failed to put %s into store: %s') %
35 (sha, e.strerror))
36 36 return wireproto.pushres(1)
37 37 finally:
38 38 tmpfp.close()
39 39 os.unlink(tmpname)
40 40
41 41 return wireproto.pushres(0)
42 42
43 43 def getlfile(repo, proto, sha):
44 44 '''Retrieve a largefile from the repository-local cache or system
45 45 cache.'''
46 46 filename = lfutil.findfile(repo, sha)
47 47 if not filename:
48 48 raise util.Abort(_('requested largefile %s not present in cache') % sha)
49 49 f = open(filename, 'rb')
50 50 length = os.fstat(f.fileno())[6]
51 51
52 52 # Since we can't set an HTTP content-length header here, and
53 53 # Mercurial core provides no way to give the length of a streamres
54 54 # (and reading the entire file into RAM would be ill-advised), we
55 55 # just send the length on the first line of the response, like the
56 56 # ssh proto does for string responses.
57 57 def generator():
58 58 yield '%d\n' % length
59 59 for chunk in f:
60 60 yield chunk
61 61 return wireproto.streamres(generator())
62 62
63 63 def statlfile(repo, proto, sha):
64 64 '''Return '2\n' if the largefile is missing, '1\n' if it has a
65 65 mismatched checksum, or '0\n' if it is in good condition'''
66 66 filename = lfutil.findfile(repo, sha)
67 67 if not filename:
68 68 return '2\n'
69 69 fd = None
70 70 try:
71 71 fd = open(filename, 'rb')
72 72 return lfutil.hexsha1(fd) == sha and '0\n' or '1\n'
73 73 finally:
74 74 if fd:
75 75 fd.close()
76 76
77 77 def wirereposetup(ui, repo):
78 78 class lfileswirerepository(repo.__class__):
79 79 def putlfile(self, sha, fd):
80 80 # unfortunately, httprepository._callpush tries to convert its
81 81 # input file-like into a bundle before sending it, so we can't use
82 82 # it ...
83 83 if issubclass(self.__class__, httprepo.httprepository):
84 res = None
84 85 try:
85 return int(self._call('putlfile', data=fd, sha=sha,
86 headers={'content-type':'application/mercurial-0.1'}))
86 res = self._call('putlfile', data=fd, sha=sha,
87 headers={'content-type':'application/mercurial-0.1'})
88 d, output = res.split('\n', 1)
89 for l in output.splitlines(True):
90 self.ui.warn(_('remote: '), l, '\n')
91 return int(d)
87 92 except (ValueError, urllib2.HTTPError):
93 self.ui.warn(_('unexpected putlfile response: %s') % res)
88 94 return 1
89 95 # ... but we can't use sshrepository._call because the data=
90 96 # argument won't get sent, and _callpush does exactly what we want
91 97 # in this case: send the data straight through
92 98 else:
93 99 try:
94 100 ret, output = self._callpush("putlfile", fd, sha=sha)
95 101 if ret == "":
96 102 raise error.ResponseError(_('putlfile failed:'),
97 103 output)
98 104 return int(ret)
99 105 except IOError:
100 106 return 1
101 107 except ValueError:
102 108 raise error.ResponseError(
103 109 _('putlfile failed (unexpected response):'), ret)
104 110
105 111 def getlfile(self, sha):
106 112 stream = self._callstream("getlfile", sha=sha)
107 113 length = stream.readline()
108 114 try:
109 115 length = int(length)
110 116 except ValueError:
111 117 self._abort(error.ResponseError(_("unexpected response:"),
112 118 length))
113 119 return (length, stream)
114 120
115 121 def statlfile(self, sha):
116 122 try:
117 123 return int(self._call("statlfile", sha=sha))
118 124 except (ValueError, urllib2.HTTPError):
119 125 # If the server returns anything but an integer followed by a
120 126 # newline, newline, it's not speaking our language; if we get
121 127 # an HTTP error, we can't be sure the largefile is present;
122 128 # either way, consider it missing.
123 129 return 2
124 130
125 131 repo.__class__ = lfileswirerepository
126 132
127 133 # advertise the largefiles=serve capability
128 134 def capabilities(repo, proto):
129 135 return capabilities_orig(repo, proto) + ' largefiles=serve'
130 136
131 137 # duplicate what Mercurial's new out-of-band errors mechanism does, because
132 138 # clients old and new alike both handle it well
133 139 def webproto_refuseclient(self, message):
134 140 self.req.header([('Content-Type', 'application/hg-error')])
135 141 return message
136 142
137 143 def sshproto_refuseclient(self, message):
138 144 self.ui.write_err('%s\n-\n' % message)
139 145 self.fout.write('\n')
140 146 self.fout.flush()
141 147
142 148 return ''
143 149
144 150 def heads(repo, proto):
145 151 if lfutil.islfilesrepo(repo):
146 152 return wireproto.ooberror(LARGEFILES_REQUIRED_MSG)
147 153 return wireproto.heads(repo, proto)
148 154
149 155 def sshrepo_callstream(self, cmd, **args):
150 156 if cmd == 'heads' and self.capable('largefiles'):
151 157 cmd = 'lheads'
152 158 if cmd == 'batch' and self.capable('largefiles'):
153 159 args['cmds'] = args['cmds'].replace('heads ', 'lheads ')
154 160 return ssh_oldcallstream(self, cmd, **args)
155 161
156 162 def httprepo_callstream(self, cmd, **args):
157 163 if cmd == 'heads' and self.capable('largefiles'):
158 164 cmd = 'lheads'
159 165 if cmd == 'batch' and self.capable('largefiles'):
160 166 args['cmds'] = args['cmds'].replace('heads ', 'lheads ')
161 167 return http_oldcallstream(self, cmd, **args)
@@ -1,879 +1,897
1 1 $ "$TESTDIR/hghave" symlink unix-permissions serve || exit 80
2 2
3 $ USERCACHE=`pwd`/cache; export USERCACHE
4 $ mkdir -p ${USERCACHE}
3 5 $ cat >> $HGRCPATH <<EOF
4 6 > [extensions]
5 7 > largefiles=
6 8 > purge=
7 9 > rebase=
8 10 > transplant=
9 11 > [phases]
10 12 > publish=False
11 13 > [largefiles]
12 14 > minsize=2
13 15 > patterns=glob:**.dat
16 > usercache=${USERCACHE}
14 17 > EOF
15 18
16 19 Create the repo with a couple of revisions of both large and normal
17 20 files, testing that status correctly shows largefiles.
18 21
19 22 $ hg init a
20 23 $ cd a
21 24 $ mkdir sub
22 25 $ echo normal1 > normal1
23 26 $ echo normal2 > sub/normal2
24 27 $ echo large1 > large1
25 28 $ echo large2 > sub/large2
26 29 $ hg add normal1 sub/normal2
27 30 $ hg add --large large1 sub/large2
28 31 $ hg commit -m "add files"
29 32 $ echo normal11 > normal1
30 33 $ echo normal22 > sub/normal2
31 34 $ echo large11 > large1
32 35 $ echo large22 > sub/large2
33 36 $ hg st
34 37 M large1
35 38 M normal1
36 39 M sub/large2
37 40 M sub/normal2
38 41 $ hg commit -m "edit files"
39 42
40 43 Commit preserved largefile contents.
41 44
42 45 $ cat normal1
43 46 normal11
44 47 $ cat large1
45 48 large11
46 49 $ cat sub/normal2
47 50 normal22
48 51 $ cat sub/large2
49 52 large22
50 53
51 54 Remove both largefiles and normal files.
52 55
53 56 $ hg remove normal1 large1
54 57 $ hg commit -m "remove files"
55 58 $ ls
56 59 sub
57 60
58 61 Copy both largefiles and normal files (testing that status output is correct).
59 62
60 63 $ hg cp sub/normal2 normal1
61 64 $ hg cp sub/large2 large1
62 65 $ hg st
63 66 A large1
64 67 A normal1
65 68 $ hg commit -m "copy files"
66 69 $ cat normal1
67 70 normal22
68 71 $ cat large1
69 72 large22
70 73
71 74 Test moving largefiles and verify that normal files are also unaffected.
72 75
73 76 $ hg mv normal1 normal3
74 77 $ hg mv large1 large3
75 78 $ hg mv sub/normal2 sub/normal4
76 79 $ hg mv sub/large2 sub/large4
77 80 $ hg commit -m "move files"
78 81 $ cat normal3
79 82 normal22
80 83 $ cat large3
81 84 large22
82 85 $ cat sub/normal4
83 86 normal22
84 87 $ cat sub/large4
85 88 large22
86 89
87 90 Test archiving the various revisions. These hit corner cases known with
88 91 archiving.
89 92
90 93 $ hg archive -r 0 ../archive0
91 94 $ hg archive -r 1 ../archive1
92 95 $ hg archive -r 2 ../archive2
93 96 $ hg archive -r 3 ../archive3
94 97 $ hg archive -r 4 ../archive4
95 98 $ cd ../archive0
96 99 $ cat normal1
97 100 normal1
98 101 $ cat large1
99 102 large1
100 103 $ cat sub/normal2
101 104 normal2
102 105 $ cat sub/large2
103 106 large2
104 107 $ cd ../archive1
105 108 $ cat normal1
106 109 normal11
107 110 $ cat large1
108 111 large11
109 112 $ cat sub/normal2
110 113 normal22
111 114 $ cat sub/large2
112 115 large22
113 116 $ cd ../archive2
114 117 $ ls
115 118 sub
116 119 $ cat sub/normal2
117 120 normal22
118 121 $ cat sub/large2
119 122 large22
120 123 $ cd ../archive3
121 124 $ cat normal1
122 125 normal22
123 126 $ cat large1
124 127 large22
125 128 $ cat sub/normal2
126 129 normal22
127 130 $ cat sub/large2
128 131 large22
129 132 $ cd ../archive4
130 133 $ cat normal3
131 134 normal22
132 135 $ cat large3
133 136 large22
134 137 $ cat sub/normal4
135 138 normal22
136 139 $ cat sub/large4
137 140 large22
138 141
139 142 Commit corner case: specify files to commit.
140 143
141 144 $ cd ../a
142 145 $ echo normal3 > normal3
143 146 $ echo large3 > large3
144 147 $ echo normal4 > sub/normal4
145 148 $ echo large4 > sub/large4
146 149 $ hg commit normal3 large3 sub/normal4 sub/large4 -m "edit files again"
147 150 $ cat normal3
148 151 normal3
149 152 $ cat large3
150 153 large3
151 154 $ cat sub/normal4
152 155 normal4
153 156 $ cat sub/large4
154 157 large4
155 158
156 159 One more commit corner case: commit from a subdirectory.
157 160
158 161 $ cd ../a
159 162 $ echo normal33 > normal3
160 163 $ echo large33 > large3
161 164 $ echo normal44 > sub/normal4
162 165 $ echo large44 > sub/large4
163 166 $ cd sub
164 167 $ hg commit -m "edit files yet again"
165 168 $ cat ../normal3
166 169 normal33
167 170 $ cat ../large3
168 171 large33
169 172 $ cat normal4
170 173 normal44
171 174 $ cat large4
172 175 large44
173 176
174 177 Committing standins is not allowed.
175 178
176 179 $ cd ..
177 180 $ echo large3 > large3
178 181 $ hg commit .hglf/large3 -m "try to commit standin"
179 182 abort: file ".hglf/large3" is a largefile standin
180 183 (commit the largefile itself instead)
181 184 [255]
182 185
183 186 Corner cases for adding largefiles.
184 187
185 188 $ echo large5 > large5
186 189 $ hg add --large large5
187 190 $ hg add --large large5
188 191 large5 already a largefile
189 192 $ mkdir sub2
190 193 $ echo large6 > sub2/large6
191 194 $ echo large7 > sub2/large7
192 195 $ hg add --large sub2
193 196 adding sub2/large6 as a largefile (glob)
194 197 adding sub2/large7 as a largefile (glob)
195 198 $ hg st
196 199 M large3
197 200 A large5
198 201 A sub2/large6
199 202 A sub2/large7
200 203
201 204 Config settings (pattern **.dat, minsize 2 MB) are respected.
202 205
203 206 $ echo testdata > test.dat
204 207 $ dd bs=1k count=2k if=/dev/zero of=reallylarge > /dev/null 2> /dev/null
205 208 $ hg add
206 209 adding reallylarge as a largefile
207 210 adding test.dat as a largefile
208 211
209 212 Test that minsize and --lfsize handle float values;
210 213 also tests that --lfsize overrides largefiles.minsize.
211 214 (0.250 MB = 256 kB = 262144 B)
212 215
213 216 $ dd if=/dev/zero of=ratherlarge bs=1024 count=256 > /dev/null 2> /dev/null
214 217 $ dd if=/dev/zero of=medium bs=1024 count=128 > /dev/null 2> /dev/null
215 218 $ hg --config largefiles.minsize=.25 add
216 219 adding ratherlarge as a largefile
217 220 adding medium
218 221 $ hg forget medium
219 222 $ hg --config largefiles.minsize=.25 add --lfsize=.125
220 223 adding medium as a largefile
221 224 $ dd if=/dev/zero of=notlarge bs=1024 count=127 > /dev/null 2> /dev/null
222 225 $ hg --config largefiles.minsize=.25 add --lfsize=.125
223 226 adding notlarge
224 227 $ hg forget notlarge
225 228
226 229 Test forget on largefiles.
227 230
228 231 $ hg forget large3 large5 test.dat reallylarge ratherlarge medium
229 232 $ hg st
230 233 A sub2/large6
231 234 A sub2/large7
232 235 R large3
233 236 ? large5
234 237 ? medium
235 238 ? notlarge
236 239 ? ratherlarge
237 240 ? reallylarge
238 241 ? test.dat
239 242 $ hg commit -m "add/edit more largefiles"
240 243 $ hg st
241 244 ? large3
242 245 ? large5
243 246 ? medium
244 247 ? notlarge
245 248 ? ratherlarge
246 249 ? reallylarge
247 250 ? test.dat
248 251
249 252 Purge with largefiles: verify that largefiles are still in the working
250 253 dir after a purge.
251 254
252 255 $ hg purge --all
253 256 $ cat sub/large4
254 257 large44
255 258 $ cat sub2/large6
256 259 large6
257 260 $ cat sub2/large7
258 261 large7
259 262
260 263 Clone a largefiles repo.
261 264
262 265 $ hg clone . ../b
263 266 updating to branch default
264 267 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
265 268 getting changed largefiles
266 269 3 largefiles updated, 0 removed
267 270 $ cd ../b
268 271 $ hg log --template '{rev}:{node|short} {desc|firstline}\n'
269 272 7:daea875e9014 add/edit more largefiles
270 273 6:4355d653f84f edit files yet again
271 274 5:9d5af5072dbd edit files again
272 275 4:74c02385b94c move files
273 276 3:9e8fbc4bce62 copy files
274 277 2:51a0ae4d5864 remove files
275 278 1:ce8896473775 edit files
276 279 0:30d30fe6a5be add files
277 280 $ cat normal3
278 281 normal33
279 282 $ cat sub/normal4
280 283 normal44
281 284 $ cat sub/large4
282 285 large44
283 286 $ cat sub2/large6
284 287 large6
285 288 $ cat sub2/large7
286 289 large7
287 290 $ cd ..
288 291 $ hg clone a -r 3 c
289 292 adding changesets
290 293 adding manifests
291 294 adding file changes
292 295 added 4 changesets with 10 changes to 4 files
293 296 updating to branch default
294 297 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
295 298 getting changed largefiles
296 299 2 largefiles updated, 0 removed
297 300 $ cd c
298 301 $ hg log --template '{rev}:{node|short} {desc|firstline}\n'
299 302 3:9e8fbc4bce62 copy files
300 303 2:51a0ae4d5864 remove files
301 304 1:ce8896473775 edit files
302 305 0:30d30fe6a5be add files
303 306 $ cat normal1
304 307 normal22
305 308 $ cat large1
306 309 large22
307 310 $ cat sub/normal2
308 311 normal22
309 312 $ cat sub/large2
310 313 large22
311 314
312 315 Old revisions of a clone have correct largefiles content (this also
313 316 tests update).
314 317
315 318 $ hg update -r 1
316 319 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
317 320 getting changed largefiles
318 321 1 largefiles updated, 0 removed
319 322 $ cat large1
320 323 large11
321 324 $ cat sub/large2
322 325 large22
323 326
324 327 Rebasing between two repositories does not revert largefiles to old
325 328 revisions (this was a very bad bug that took a lot of work to fix).
326 329
327 330 $ cd ..
328 331 $ hg clone a d
329 332 updating to branch default
330 333 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
331 334 getting changed largefiles
332 335 3 largefiles updated, 0 removed
333 336 $ cd b
334 337 $ echo large4-modified > sub/large4
335 338 $ echo normal3-modified > normal3
336 339 $ hg commit -m "modify normal file and largefile in repo b"
337 340 $ cd ../d
338 341 $ echo large6-modified > sub2/large6
339 342 $ echo normal4-modified > sub/normal4
340 343 $ hg commit -m "modify normal file largefile in repo d"
341 344 $ cd ..
342 345 $ hg clone d e
343 346 updating to branch default
344 347 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
345 348 getting changed largefiles
346 349 3 largefiles updated, 0 removed
347 350 $ cd d
348 351 $ hg pull --rebase ../b
349 352 pulling from ../b
350 353 searching for changes
351 354 adding changesets
352 355 adding manifests
353 356 adding file changes
354 357 added 1 changesets with 2 changes to 2 files (+1 heads)
355 358 getting changed largefiles
356 359 1 largefiles updated, 0 removed
357 360 saved backup bundle to $TESTTMP/d/.hg/strip-backup/f574fb32bb45-backup.hg (glob)
358 361 nothing to rebase
359 362 $ hg log --template '{rev}:{node|short} {desc|firstline}\n'
360 363 9:598410d3eb9a modify normal file largefile in repo d
361 364 8:a381d2c8c80e modify normal file and largefile in repo b
362 365 7:daea875e9014 add/edit more largefiles
363 366 6:4355d653f84f edit files yet again
364 367 5:9d5af5072dbd edit files again
365 368 4:74c02385b94c move files
366 369 3:9e8fbc4bce62 copy files
367 370 2:51a0ae4d5864 remove files
368 371 1:ce8896473775 edit files
369 372 0:30d30fe6a5be add files
370 373 $ cat normal3
371 374 normal3-modified
372 375 $ cat sub/normal4
373 376 normal4-modified
374 377 $ cat sub/large4
375 378 large4-modified
376 379 $ cat sub2/large6
377 380 large6-modified
378 381 $ cat sub2/large7
379 382 large7
380 383 $ cd ../e
381 384 $ hg pull ../b
382 385 pulling from ../b
383 386 searching for changes
384 387 adding changesets
385 388 adding manifests
386 389 adding file changes
387 390 added 1 changesets with 2 changes to 2 files (+1 heads)
388 391 (run 'hg heads' to see heads, 'hg merge' to merge)
389 392 $ hg rebase
390 393 getting changed largefiles
391 394 1 largefiles updated, 0 removed
392 395 saved backup bundle to $TESTTMP/e/.hg/strip-backup/f574fb32bb45-backup.hg (glob)
393 396 $ hg log
394 397 changeset: 9:598410d3eb9a
395 398 tag: tip
396 399 user: test
397 400 date: Thu Jan 01 00:00:00 1970 +0000
398 401 summary: modify normal file largefile in repo d
399 402
400 403 changeset: 8:a381d2c8c80e
401 404 user: test
402 405 date: Thu Jan 01 00:00:00 1970 +0000
403 406 summary: modify normal file and largefile in repo b
404 407
405 408 changeset: 7:daea875e9014
406 409 user: test
407 410 date: Thu Jan 01 00:00:00 1970 +0000
408 411 summary: add/edit more largefiles
409 412
410 413 changeset: 6:4355d653f84f
411 414 user: test
412 415 date: Thu Jan 01 00:00:00 1970 +0000
413 416 summary: edit files yet again
414 417
415 418 changeset: 5:9d5af5072dbd
416 419 user: test
417 420 date: Thu Jan 01 00:00:00 1970 +0000
418 421 summary: edit files again
419 422
420 423 changeset: 4:74c02385b94c
421 424 user: test
422 425 date: Thu Jan 01 00:00:00 1970 +0000
423 426 summary: move files
424 427
425 428 changeset: 3:9e8fbc4bce62
426 429 user: test
427 430 date: Thu Jan 01 00:00:00 1970 +0000
428 431 summary: copy files
429 432
430 433 changeset: 2:51a0ae4d5864
431 434 user: test
432 435 date: Thu Jan 01 00:00:00 1970 +0000
433 436 summary: remove files
434 437
435 438 changeset: 1:ce8896473775
436 439 user: test
437 440 date: Thu Jan 01 00:00:00 1970 +0000
438 441 summary: edit files
439 442
440 443 changeset: 0:30d30fe6a5be
441 444 user: test
442 445 date: Thu Jan 01 00:00:00 1970 +0000
443 446 summary: add files
444 447
445 448 $ cat normal3
446 449 normal3-modified
447 450 $ cat sub/normal4
448 451 normal4-modified
449 452 $ cat sub/large4
450 453 large4-modified
451 454 $ cat sub2/large6
452 455 large6-modified
453 456 $ cat sub2/large7
454 457 large7
455 458
456 459 Rollback on largefiles.
457 460
458 461 $ echo large4-modified-again > sub/large4
459 462 $ hg commit -m "Modify large4 again"
460 463 $ hg rollback
461 464 repository tip rolled back to revision 9 (undo commit)
462 465 working directory now based on revision 9
463 466 $ hg st
464 467 M sub/large4
465 468 $ hg log
466 469 changeset: 9:598410d3eb9a
467 470 tag: tip
468 471 user: test
469 472 date: Thu Jan 01 00:00:00 1970 +0000
470 473 summary: modify normal file largefile in repo d
471 474
472 475 changeset: 8:a381d2c8c80e
473 476 user: test
474 477 date: Thu Jan 01 00:00:00 1970 +0000
475 478 summary: modify normal file and largefile in repo b
476 479
477 480 changeset: 7:daea875e9014
478 481 user: test
479 482 date: Thu Jan 01 00:00:00 1970 +0000
480 483 summary: add/edit more largefiles
481 484
482 485 changeset: 6:4355d653f84f
483 486 user: test
484 487 date: Thu Jan 01 00:00:00 1970 +0000
485 488 summary: edit files yet again
486 489
487 490 changeset: 5:9d5af5072dbd
488 491 user: test
489 492 date: Thu Jan 01 00:00:00 1970 +0000
490 493 summary: edit files again
491 494
492 495 changeset: 4:74c02385b94c
493 496 user: test
494 497 date: Thu Jan 01 00:00:00 1970 +0000
495 498 summary: move files
496 499
497 500 changeset: 3:9e8fbc4bce62
498 501 user: test
499 502 date: Thu Jan 01 00:00:00 1970 +0000
500 503 summary: copy files
501 504
502 505 changeset: 2:51a0ae4d5864
503 506 user: test
504 507 date: Thu Jan 01 00:00:00 1970 +0000
505 508 summary: remove files
506 509
507 510 changeset: 1:ce8896473775
508 511 user: test
509 512 date: Thu Jan 01 00:00:00 1970 +0000
510 513 summary: edit files
511 514
512 515 changeset: 0:30d30fe6a5be
513 516 user: test
514 517 date: Thu Jan 01 00:00:00 1970 +0000
515 518 summary: add files
516 519
517 520 $ cat sub/large4
518 521 large4-modified-again
519 522
520 523 "update --check" refuses to update with uncommitted changes.
521 524 $ hg update --check 8
522 525 abort: uncommitted local changes
523 526 [255]
524 527
525 528 "update --clean" leaves correct largefiles in working copy.
526 529
527 530 $ hg update --clean
528 531 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
529 532 getting changed largefiles
530 533 1 largefiles updated, 0 removed
531 534 $ cat normal3
532 535 normal3-modified
533 536 $ cat sub/normal4
534 537 normal4-modified
535 538 $ cat sub/large4
536 539 large4-modified
537 540 $ cat sub2/large6
538 541 large6-modified
539 542 $ cat sub2/large7
540 543 large7
541 544
542 545 Now "update check" is happy.
543 546 $ hg update --check 8
544 547 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
545 548 getting changed largefiles
546 549 1 largefiles updated, 0 removed
547 550 $ hg update --check
548 551 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
549 552 getting changed largefiles
550 553 1 largefiles updated, 0 removed
551 554
552 555 "revert" works on largefiles (and normal files too).
553 556 $ echo hack3 >> normal3
554 557 $ echo hack4 >> sub/normal4
555 558 $ echo hack4 >> sub/large4
556 559 $ hg rm sub2/large6
557 560 $ echo new >> sub2/large8
558 561 $ hg add --large sub2/large8
559 562 # XXX we don't really want to report that we're reverting the standin;
560 563 # that's just an implementation detail. But I don't see an obvious fix. ;-(
561 564 $ hg revert sub
562 565 reverting .hglf/sub/large4 (glob)
563 566 reverting sub/normal4 (glob)
564 567 $ hg status
565 568 M normal3
566 569 A sub2/large8
567 570 R sub2/large6
568 571 ? sub/large4.orig
569 572 ? sub/normal4.orig
570 573 $ cat sub/normal4
571 574 normal4-modified
572 575 $ cat sub/large4
573 576 large4-modified
574 577 $ hg revert -a --no-backup
575 578 undeleting .hglf/sub2/large6 (glob)
576 579 forgetting .hglf/sub2/large8 (glob)
577 580 reverting normal3
578 581 $ hg status
579 582 ? sub/large4.orig
580 583 ? sub/normal4.orig
581 584 ? sub2/large8
582 585 $ cat normal3
583 586 normal3-modified
584 587 $ cat sub2/large6
585 588 large6-modified
586 589 $ rm sub/*.orig sub2/large8
587 590
588 591 revert some files to an older revision
589 592 $ hg revert --no-backup -r 8 sub2
590 593 reverting .hglf/sub2/large6 (glob)
591 594 $ cat sub2/large6
592 595 large6
593 596 $ hg revert --no-backup sub2
594 597 reverting .hglf/sub2/large6 (glob)
595 598 $ hg status
596 599
597 600 "verify --large" actually verifies largefiles
598 601
599 602 $ hg verify --large
600 603 checking changesets
601 604 checking manifests
602 605 crosschecking files in changesets and manifests
603 606 checking files
604 607 10 files, 10 changesets, 28 total revisions
605 608 searching 1 changesets for largefiles
606 609 verified existence of 3 revisions of 3 largefiles
607 610
608 611 Merging does not revert to old versions of largefiles (this has also
609 612 been very problematic).
610 613
611 614 $ cd ..
612 615 $ hg clone -r 7 e f
613 616 adding changesets
614 617 adding manifests
615 618 adding file changes
616 619 added 8 changesets with 24 changes to 10 files
617 620 updating to branch default
618 621 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
619 622 getting changed largefiles
620 623 3 largefiles updated, 0 removed
621 624 $ cd f
622 625 $ echo "large4-merge-test" > sub/large4
623 626 $ hg commit -m "Modify large4 to test merge"
624 627 $ hg pull ../e
625 628 pulling from ../e
626 629 searching for changes
627 630 adding changesets
628 631 adding manifests
629 632 adding file changes
630 633 added 2 changesets with 4 changes to 4 files (+1 heads)
631 634 (run 'hg heads' to see heads, 'hg merge' to merge)
632 635 $ hg merge
633 636 merging sub/large4
634 637 largefile sub/large4 has a merge conflict
635 638 keep (l)ocal or take (o)ther? l
636 639 3 files updated, 1 files merged, 0 files removed, 0 files unresolved
637 640 (branch merge, don't forget to commit)
638 641 getting changed largefiles
639 642 1 largefiles updated, 0 removed
640 643 $ hg commit -m "Merge repos e and f"
641 644 $ cat normal3
642 645 normal3-modified
643 646 $ cat sub/normal4
644 647 normal4-modified
645 648 $ cat sub/large4
646 649 large4-merge-test
647 650 $ cat sub2/large6
648 651 large6-modified
649 652 $ cat sub2/large7
650 653 large7
651 654
652 655 Test status after merging with a branch that introduces a new largefile:
653 656
654 657 $ echo large > large
655 658 $ hg add --large large
656 659 $ hg commit -m 'add largefile'
657 660 $ hg update -q ".^"
658 661 $ echo change >> normal3
659 662 $ hg commit -m 'some change'
660 663 created new head
661 664 $ hg merge
662 665 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
663 666 (branch merge, don't forget to commit)
664 667 getting changed largefiles
665 668 1 largefiles updated, 0 removed
666 669 $ hg status
667 670 M large
668 671
669 672 Test that a normal file and a largefile with the same name and path cannot
670 673 coexist.
671 674
672 675 $ rm sub2/large7
673 676 $ echo "largeasnormal" > sub2/large7
674 677 $ hg add sub2/large7
675 678 sub2/large7 already a largefile
676 679
677 680 Test that transplanting a largefile change works correctly.
678 681
679 682 $ cd ..
680 683 $ hg clone -r 8 d g
681 684 adding changesets
682 685 adding manifests
683 686 adding file changes
684 687 added 9 changesets with 26 changes to 10 files
685 688 updating to branch default
686 689 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
687 690 getting changed largefiles
688 691 3 largefiles updated, 0 removed
689 692 $ cd g
690 693 $ hg transplant -s ../d 598410d3eb9a
691 694 searching for changes
692 695 searching for changes
693 696 adding changesets
694 697 adding manifests
695 698 adding file changes
696 699 added 1 changesets with 2 changes to 2 files
697 700 getting changed largefiles
698 701 1 largefiles updated, 0 removed
699 702 $ hg log --template '{rev}:{node|short} {desc|firstline}\n'
700 703 9:598410d3eb9a modify normal file largefile in repo d
701 704 8:a381d2c8c80e modify normal file and largefile in repo b
702 705 7:daea875e9014 add/edit more largefiles
703 706 6:4355d653f84f edit files yet again
704 707 5:9d5af5072dbd edit files again
705 708 4:74c02385b94c move files
706 709 3:9e8fbc4bce62 copy files
707 710 2:51a0ae4d5864 remove files
708 711 1:ce8896473775 edit files
709 712 0:30d30fe6a5be add files
710 713 $ cat normal3
711 714 normal3-modified
712 715 $ cat sub/normal4
713 716 normal4-modified
714 717 $ cat sub/large4
715 718 large4-modified
716 719 $ cat sub2/large6
717 720 large6-modified
718 721 $ cat sub2/large7
719 722 large7
720 723
721 724 Test that renaming a largefile results in correct output for status
722 725
723 726 $ hg rename sub/large4 large4-renamed
724 727 $ hg st
725 728 A large4-renamed
726 729 R sub/large4
727 730 $ hg commit -m "test rename output"
728 731 $ cat large4-renamed
729 732 large4-modified
730 733 $ cd sub2
731 734 $ hg rename large6 large6-renamed
732 735 $ hg st
733 736 A sub2/large6-renamed
734 737 R sub2/large6
735 738 $ cd ../..
736 739
737 740 vanilla clients not locked out from largefiles servers on vanilla repos
738 741 $ mkdir r1
739 742 $ cd r1
740 743 $ hg init
741 744 $ echo c1 > f1
742 745 $ hg add f1
743 746 $ hg com -m "m1"
744 747 $ cd ..
745 748 $ hg serve -R r1 -d -p $HGPORT --pid-file hg.pid
746 749 $ cat hg.pid >> $DAEMON_PIDS
747 750 $ hg --config extensions.largefiles=! clone http://localhost:$HGPORT r2
748 751 requesting all changes
749 752 adding changesets
750 753 adding manifests
751 754 adding file changes
752 755 added 1 changesets with 1 changes to 1 files
753 756 updating to branch default
754 757 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
755 758
756 759 largefiles clients still work with vanilla servers
757 760 $ hg --config extensions.largefiles=! serve -R r1 -d -p $HGPORT1 --pid-file hg.pid
758 761 $ cat hg.pid >> $DAEMON_PIDS
759 762 $ hg clone http://localhost:$HGPORT1 r3
760 763 requesting all changes
761 764 adding changesets
762 765 adding manifests
763 766 adding file changes
764 767 added 1 changesets with 1 changes to 1 files
765 768 updating to branch default
766 769 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
767 770
768 771 vanilla clients locked out from largefiles http repos
769 772 $ mkdir r4
770 773 $ cd r4
771 774 $ hg init
772 775 $ echo c1 > f1
773 776 $ hg add --large f1
774 777 $ hg com -m "m1"
775 778 $ cd ..
776 779 $ hg serve -R r4 -d -p $HGPORT2 --pid-file hg.pid
777 780 $ cat hg.pid >> $DAEMON_PIDS
778 781 $ hg --config extensions.largefiles=! clone http://localhost:$HGPORT2 r5
779 782 abort: remote error:
780 783
781 784 This repository uses the largefiles extension.
782 785
783 786 Please enable it in your Mercurial config file.
784 787 [255]
785 788
786 789 used all HGPORTs, kill all daemons
787 790 $ "$TESTDIR/killdaemons.py"
788 791
789 792 vanilla clients locked out from largefiles ssh repos
790 793 $ hg --config extensions.largefiles=! clone -e "python $TESTDIR/dummyssh" ssh://user@dummy/r4 r5
791 794 abort: remote error:
792 795
793 796 This repository uses the largefiles extension.
794 797
795 798 Please enable it in your Mercurial config file.
796 799 [255]
797 800
798 801 largefiles clients refuse to push largefiles repos to vanilla servers
799 802 $ mkdir r6
800 803 $ cd r6
801 804 $ hg init
802 805 $ echo c1 > f1
803 806 $ hg add f1
804 807 $ hg com -m "m1"
805 808 $ cat >> .hg/hgrc <<!
806 809 > [web]
807 810 > push_ssl = false
808 811 > allow_push = *
809 812 > !
810 813 $ cd ..
811 814 $ hg clone r6 r7
812 815 updating to branch default
813 816 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
814 817 $ cd r7
815 818 $ echo c2 > f2
816 819 $ hg add --large f2
817 820 $ hg com -m "m2"
818 821 $ hg --config extensions.largefiles=! -R ../r6 serve -d -p $HGPORT --pid-file ../hg.pid
819 822 $ cat ../hg.pid >> $DAEMON_PIDS
820 823 $ hg push http://localhost:$HGPORT
821 824 pushing to http://localhost:$HGPORT/
822 825 searching for changes
823 826 abort: http://localhost:$HGPORT/ does not appear to be a largefile store
824 827 [255]
825 828 $ cd ..
826 829
830 putlfile errors are shown (issue3123)
831 Corrupt the cached largefile in r7
832 $ echo corruption > $USERCACHE/4cdac4d8b084d0b599525cf732437fb337d422a8
833 $ hg init empty
834 $ hg serve -R empty -d -p $HGPORT1 --pid-file hg.pid \
835 > --config 'web.allow_push=*' --config web.push_ssl=False
836 $ cat hg.pid >> $DAEMON_PIDS
837 $ hg push -R r7 http://localhost:$HGPORT1
838 pushing to http://localhost:$HGPORT1/
839 searching for changes
840 remote: largefiles: failed to put 4cdac4d8b084d0b599525cf732437fb337d422a8 into store: largefile contents do not match hash
841 abort: remotestore: could not put $TESTTMP/r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 to remote store http://localhost:$HGPORT1/
842 [255]
843 $ rm -rf empty
844
827 845 Clone a local repository owned by another user
828 846 We have to simulate that here by setting $HOME and removing write permissions
829 847 $ ORIGHOME="$HOME"
830 848 $ mkdir alice
831 849 $ HOME="`pwd`/alice"
832 850 $ cd alice
833 851 $ hg init pubrepo
834 852 $ cd pubrepo
835 853 $ dd if=/dev/urandom bs=1k count=11k > a-large-file 2> /dev/null
836 854 $ hg add --large a-large-file
837 855 $ hg commit -m "Add a large file"
838 856 $ cd ..
839 857 $ chmod -R a-w pubrepo
840 858 $ cd ..
841 859 $ mkdir bob
842 860 $ HOME="`pwd`/bob"
843 861 $ cd bob
844 862 $ hg clone --pull ../alice/pubrepo pubrepo
845 863 requesting all changes
846 864 adding changesets
847 865 adding manifests
848 866 adding file changes
849 867 added 1 changesets with 1 changes to 1 files
850 868 updating to branch default
851 869 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
852 870 getting changed largefiles
853 871 1 largefiles updated, 0 removed
854 872 $ cd ..
855 873 $ chmod -R u+w alice/pubrepo
856 874 $ HOME="$ORIGHOME"
857 875
858 876 Symlink to a large largefile should behave the same as a symlink to a normal file
859 877 $ hg init largesymlink
860 878 $ cd largesymlink
861 879 $ dd if=/dev/zero bs=1k count=10k of=largefile 2>/dev/null
862 880 $ hg add --large largefile
863 881 $ hg commit -m "commit a large file"
864 882 $ ln -s largefile largelink
865 883 $ hg add largelink
866 884 $ hg commit -m "commit a large symlink"
867 885 $ rm -f largelink
868 886 $ hg up >/dev/null
869 887 $ test -f largelink
870 888 [1]
871 889 $ test -L largelink
872 890 [1]
873 891 $ rm -f largelink # make next part of the test independent of the previous
874 892 $ hg up -C >/dev/null
875 893 $ test -f largelink
876 894 $ test -L largelink
877 895 $ cd ..
878 896
879 897
General Comments 0
You need to be logged in to leave comments. Login now