##// 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 import lfutil
15 import lfutil
16 import basestore
16 import basestore
17 import localstore
17
18
18 class remotestore(basestore.basestore):
19 class remotestore(basestore.basestore):
19 '''a largefile store accessed over a network'''
20 '''a largefile store accessed over a network'''
20 def __init__(self, ui, repo, url):
21 def __init__(self, ui, repo, url):
21 super(remotestore, self).__init__(ui, repo, url)
22 super(remotestore, self).__init__(ui, repo, url)
23 self._lstore = localstore.localstore(self.ui, self.repo, self.repo)
22
24
23 def put(self, source, hash):
25 def put(self, source, hash):
24 if self.sendfile(source, hash):
26 if self.sendfile(source, hash):
@@ -65,12 +67,27 b' class remotestore(basestore.basestore):'
65
67
66 return lfutil.copyandhash(chunks, tmpfile)
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 def _verifyfiles(self, contents, filestocheck):
75 def _verifyfiles(self, contents, filestocheck):
69 failed = False
76 failed = False
70 expectedhashes = [expectedhash
77 expectedhashes = [expectedhash
71 for cset, filename, expectedhash in filestocheck]
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 for cset, filename, expectedhash in filestocheck:
83 for cset, filename, expectedhash in filestocheck:
84 if expectedhash in localhashes:
85 filetocheck = (cset, filename, expectedhash)
86 verifyresult = self._lstore._verifyfiles(contents,
87 [filetocheck])
88 if verifyresult:
89 failed = True
90 else:
74 stat = stats[expectedhash]
91 stat = stats[expectedhash]
75 if stat:
92 if stat:
76 if stat == 1:
93 if stat == 1:
@@ -324,27 +324,59 b' largefiles should batch verify remote ca'
324 $ hg serve -R batchverifymain -d -p $HGPORT --pid-file hg.pid \
324 $ hg serve -R batchverifymain -d -p $HGPORT --pid-file hg.pid \
325 > -A access.log
325 > -A access.log
326 $ cat hg.pid >> $DAEMON_PIDS
326 $ cat hg.pid >> $DAEMON_PIDS
327 $ hg clone http://localhost:$HGPORT batchverifyclone
327 $ hg clone --noupdate http://localhost:$HGPORT batchverifyclone
328 requesting all changes
328 requesting all changes
329 adding changesets
329 adding changesets
330 adding manifests
330 adding manifests
331 adding file changes
331 adding file changes
332 added 2 changesets with 2 changes to 2 files
332 added 2 changesets with 2 changes to 2 files
333 updating to branch default
333 $ hg -R batchverifyclone verify --large --lfa
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
338 checking changesets
334 checking changesets
339 checking manifests
335 checking manifests
340 crosschecking files in changesets and manifests
336 crosschecking files in changesets and manifests
341 checking files
337 checking files
342 2 files, 2 changesets, 2 total revisions
338 2 files, 2 changesets, 2 total revisions
343 searching 1 changesets for largefiles
339 searching 2 changesets for largefiles
344 verified existence of 2 revisions of 2 largefiles
340 verified existence of 2 revisions of 2 largefiles
345 $ tail -1 access.log
341 $ tail -1 access.log
346 127.0.0.1 - - [*] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3D972a1a11f19934401291cc99117ec614933374ce%3Bstatlfile+sha%3Dc801c9cfe94400963fcb683246217d5db77f9a9a (glob)
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 $ killdaemons.py
381 $ killdaemons.py
350
382
General Comments 0
You need to be logged in to leave comments. Login now