##// END OF EJS Templates
largefiles: send statlfile remote calls only for nonexisting locally files...
liscju -
r29218:fd288d11 default
parent child Browse files
Show More
@@ -14,11 +14,13 b' urlreq = util.urlreq'
14 14
15 15 import lfutil
16 16 import basestore
17 import localstore
17 18
18 19 class remotestore(basestore.basestore):
19 20 '''a largefile store accessed over a network'''
20 21 def __init__(self, ui, repo, url):
21 22 super(remotestore, self).__init__(ui, repo, url)
23 self._lstore = localstore.localstore(self.ui, self.repo, self.repo)
22 24
23 25 def put(self, source, hash):
24 26 if self.sendfile(source, hash):
@@ -65,27 +67,42 b' class remotestore(basestore.basestore):'
65 67
66 68 return lfutil.copyandhash(chunks, tmpfile)
67 69
70 def _hashesavailablelocally(self, hashes):
71 existslocallymap = self._lstore.exists(hashes)
72 localhashes = [hash for hash in hashes if existslocallymap[hash]]
73 return localhashes
74
68 75 def _verifyfiles(self, contents, filestocheck):
69 76 failed = False
70 77 expectedhashes = [expectedhash
71 78 for cset, filename, expectedhash in filestocheck]
72 stats = self._stat(expectedhashes)
79 localhashes = self._hashesavailablelocally(expectedhashes)
80 stats = self._stat([expectedhash for expectedhash in expectedhashes
81 if expectedhash not in localhashes])
82
73 83 for cset, filename, expectedhash in filestocheck:
74 stat = stats[expectedhash]
75 if stat:
76 if stat == 1:
77 self.ui.warn(
78 _('changeset %s: %s: contents differ\n')
79 % (cset, filename))
84 if expectedhash in localhashes:
85 filetocheck = (cset, filename, expectedhash)
86 verifyresult = self._lstore._verifyfiles(contents,
87 [filetocheck])
88 if verifyresult:
80 89 failed = True
81 elif stat == 2:
82 self.ui.warn(
83 _('changeset %s: %s missing\n')
84 % (cset, filename))
85 failed = True
86 else:
87 raise RuntimeError('verify failed: unexpected response '
88 'from statlfile (%r)' % stat)
90 else:
91 stat = stats[expectedhash]
92 if stat:
93 if stat == 1:
94 self.ui.warn(
95 _('changeset %s: %s: contents differ\n')
96 % (cset, filename))
97 failed = True
98 elif stat == 2:
99 self.ui.warn(
100 _('changeset %s: %s missing\n')
101 % (cset, filename))
102 failed = True
103 else:
104 raise RuntimeError('verify failed: unexpected response '
105 'from statlfile (%r)' % stat)
89 106 return failed
90 107
91 108 def batch(self):
@@ -324,27 +324,59 b' largefiles should batch verify remote ca'
324 324 $ hg serve -R batchverifymain -d -p $HGPORT --pid-file hg.pid \
325 325 > -A access.log
326 326 $ cat hg.pid >> $DAEMON_PIDS
327 $ hg clone http://localhost:$HGPORT batchverifyclone
327 $ hg clone --noupdate http://localhost:$HGPORT batchverifyclone
328 328 requesting all changes
329 329 adding changesets
330 330 adding manifests
331 331 adding file changes
332 332 added 2 changesets with 2 changes to 2 files
333 updating to branch default
334 getting changed largefiles
335 2 largefiles updated, 0 removed
336 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
337 $ hg -R batchverifyclone verify --large
333 $ hg -R batchverifyclone verify --large --lfa
338 334 checking changesets
339 335 checking manifests
340 336 crosschecking files in changesets and manifests
341 337 checking files
342 338 2 files, 2 changesets, 2 total revisions
343 searching 1 changesets for largefiles
339 searching 2 changesets for largefiles
344 340 verified existence of 2 revisions of 2 largefiles
345 341 $ tail -1 access.log
346 342 127.0.0.1 - - [*] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3D972a1a11f19934401291cc99117ec614933374ce%3Bstatlfile+sha%3Dc801c9cfe94400963fcb683246217d5db77f9a9a (glob)
347 $ rm access.log
343 $ hg -R batchverifyclone update
344 getting changed largefiles
345 2 largefiles updated, 0 removed
346 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
347
348 Clear log file before next test
349
350 $ printf "" > access.log
351
352 Verify should check file on remote server only when file is not
353 available locally.
354
355 $ echo "ccc" >> batchverifymain/c
356 $ hg -R batchverifymain status
357 ? c
358 $ hg -R batchverifymain add --large batchverifymain/c
359 $ hg -R batchverifymain commit -m "c"
360 Invoking status precommit hook
361 A c
362 $ hg -R batchverifyclone pull
363 pulling from http://localhost:$HGPORT/
364 searching for changes
365 adding changesets
366 adding manifests
367 adding file changes
368 added 1 changesets with 1 changes to 1 files
369 (run 'hg update' to get a working copy)
370 $ hg -R batchverifyclone verify --lfa
371 checking changesets
372 checking manifests
373 crosschecking files in changesets and manifests
374 checking files
375 3 files, 3 changesets, 3 total revisions
376 searching 3 changesets for largefiles
377 verified existence of 3 revisions of 3 largefiles
378 $ tail -1 access.log
379 127.0.0.1 - - [*] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3Dc8559c3c9cfb42131794b7d8009230403b9b454c (glob)
348 380
349 381 $ killdaemons.py
350 382
General Comments 0
You need to be logged in to leave comments. Login now