comparison hgext/largefiles/remotestore.py @ 29067:207c0db08953

largefiles: change basestore._verifyfile to take list of files to check Makes it easier to use batch stat calls in remotestore to decrease number of round trips.
author liscju <piotr.listkiewicz@gmail.com>
date Tue, 03 May 2016 23:31:32 +0200
parents 032c4c2f802a
children 305f9c36a0f5
comparison
equal deleted inserted replaced
29063:8ede973597fd 29067:207c0db08953
63 except IOError as e: 63 except IOError as e:
64 raise basestore.StoreError(filename, hash, self.url, str(e)) 64 raise basestore.StoreError(filename, hash, self.url, str(e))
65 65
66 return lfutil.copyandhash(chunks, tmpfile) 66 return lfutil.copyandhash(chunks, tmpfile)
67 67
68 def _verifyfile(self, cctx, cset, contents, standin, verified): 68 def _verifyfiles(self, contents, filestocheck):
69 filename = lfutil.splitstandin(standin) 69 failed = False
70 if not filename: 70 for cset, filename, expectedhash in filestocheck:
71 return False 71 stat = self._stat([expectedhash])[expectedhash]
72 fctx = cctx[standin] 72 if stat:
73 key = (filename, fctx.filenode()) 73 if stat == 1:
74 if key in verified: 74 self.ui.warn(
75 return False 75 _('changeset %s: %s: contents differ\n')
76 76 % (cset, filename))
77 verified.add(key) 77 failed = True
78 78 elif stat == 2:
79 expecthash = fctx.data()[0:40] 79 self.ui.warn(
80 stat = self._stat([expecthash])[expecthash] 80 _('changeset %s: %s missing\n')
81 if not stat: 81 % (cset, filename))
82 return False 82 failed = True
83 elif stat == 1: 83 else:
84 self.ui.warn( 84 raise RuntimeError('verify failed: unexpected response '
85 _('changeset %s: %s: contents differ\n') 85 'from statlfile (%r)' % stat)
86 % (cset, filename)) 86 return failed
87 return True # failed
88 elif stat == 2:
89 self.ui.warn(
90 _('changeset %s: %s missing\n')
91 % (cset, filename))
92 return True # failed
93 else:
94 raise RuntimeError('verify failed: unexpected response from '
95 'statlfile (%r)' % stat)
96 87
97 def batch(self): 88 def batch(self):
98 '''Support for remote batching.''' 89 '''Support for remote batching.'''
99 return wireproto.remotebatch(self) 90 return wireproto.remotebatch(self)
100 91