comparison hgext/largefiles/basestore.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 19b4a2087dfc
children 814076f4ace3
comparison
equal deleted inserted replaced
29063:8ede973597fd 29067:207c0db08953
114 114
115 def verify(self, revs, contents=False): 115 def verify(self, revs, contents=False):
116 '''Verify the existence (and, optionally, contents) of every big 116 '''Verify the existence (and, optionally, contents) of every big
117 file revision referenced by every changeset in revs. 117 file revision referenced by every changeset in revs.
118 Return 0 if all is well, non-zero on any errors.''' 118 Return 0 if all is well, non-zero on any errors.'''
119 failed = False
120 119
121 self.ui.status(_('searching %d changesets for largefiles\n') % 120 self.ui.status(_('searching %d changesets for largefiles\n') %
122 len(revs)) 121 len(revs))
123 verified = set() # set of (filename, filenode) tuples 122 verified = set() # set of (filename, filenode) tuples
124 123 filestocheck = [] # list of (cset, filename, expectedhash)
125 for rev in revs: 124 for rev in revs:
126 cctx = self.repo[rev] 125 cctx = self.repo[rev]
127 cset = "%d:%s" % (cctx.rev(), node.short(cctx.node())) 126 cset = "%d:%s" % (cctx.rev(), node.short(cctx.node()))
128 127
129 for standin in cctx: 128 for standin in cctx:
130 if self._verifyfile(cctx, cset, contents, standin, verified): 129 filename = lfutil.splitstandin(standin)
131 failed = True 130 if filename:
131 fctx = cctx[standin]
132 key = (filename, fctx.filenode())
133 if key not in verified:
134 verified.add(key)
135 expectedhash = fctx.data()[0:40]
136 filestocheck.append((cset, filename, expectedhash))
137
138 failed = self._verifyfiles(contents, filestocheck)
132 139
133 numrevs = len(verified) 140 numrevs = len(verified)
134 numlfiles = len(set([fname for (fname, fnode) in verified])) 141 numlfiles = len(set([fname for (fname, fnode) in verified]))
135 if contents: 142 if contents:
136 self.ui.status( 143 self.ui.status(
148 downloads and return the hash. Close tmpfile. Raise 155 downloads and return the hash. Close tmpfile. Raise
149 StoreError if unable to download the file (e.g. it does not 156 StoreError if unable to download the file (e.g. it does not
150 exist in the store).''' 157 exist in the store).'''
151 raise NotImplementedError('abstract method') 158 raise NotImplementedError('abstract method')
152 159
153 def _verifyfile(self, cctx, cset, contents, standin, verified): 160 def _verifyfiles(self, contents, filestocheck):
154 '''Perform the actual verification of a file in the store. 161 '''Perform the actual verification of files in the store.
155 'cset' is only used in warnings.
156 'contents' controls verification of content hash. 162 'contents' controls verification of content hash.
157 'standin' is the standin path of the largefile to verify. 163 'filestocheck' is list of files to check.
158 'verified' is maintained as a set of already verified files. 164 Returns _true_ if any problems are found!
159 Returns _true_ if it is a standin and any problems are found!
160 ''' 165 '''
161 raise NotImplementedError('abstract method') 166 raise NotImplementedError('abstract method')
162 167
163 import localstore, wirestore 168 import localstore, wirestore
164 169