##// END OF EJS Templates
largefiles: change basestore._verifyfile to take list of files to check...
liscju -
r29067:207c0db0 default
parent child Browse files
Show More
@@ -116,19 +116,26 b' class basestore(object):'
116 116 '''Verify the existence (and, optionally, contents) of every big
117 117 file revision referenced by every changeset in revs.
118 118 Return 0 if all is well, non-zero on any errors.'''
119 failed = False
120 119
121 120 self.ui.status(_('searching %d changesets for largefiles\n') %
122 121 len(revs))
123 122 verified = set() # set of (filename, filenode) tuples
124
123 filestocheck = [] # list of (cset, filename, expectedhash)
125 124 for rev in revs:
126 125 cctx = self.repo[rev]
127 126 cset = "%d:%s" % (cctx.rev(), node.short(cctx.node()))
128 127
129 128 for standin in cctx:
130 if self._verifyfile(cctx, cset, contents, standin, verified):
131 failed = True
129 filename = lfutil.splitstandin(standin)
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 140 numrevs = len(verified)
134 141 numlfiles = len(set([fname for (fname, fnode) in verified]))
@@ -150,13 +157,11 b' class basestore(object):'
150 157 exist in the store).'''
151 158 raise NotImplementedError('abstract method')
152 159
153 def _verifyfile(self, cctx, cset, contents, standin, verified):
154 '''Perform the actual verification of a file in the store.
155 'cset' is only used in warnings.
160 def _verifyfiles(self, contents, filestocheck):
161 '''Perform the actual verification of files in the store.
156 162 'contents' controls verification of content hash.
157 'standin' is the standin path of the largefile to verify.
158 'verified' is maintained as a set of already verified files.
159 Returns _true_ if it is a standin and any problems are found!
163 'filestocheck' is list of files to check.
164 Returns _true_ if any problems are found!
160 165 '''
161 166 raise NotImplementedError('abstract method')
162 167
@@ -42,29 +42,20 b' class localstore(basestore.basestore):'
42 42 with open(path, 'rb') as fd:
43 43 return lfutil.copyandhash(fd, tmpfile)
44 44
45 def _verifyfile(self, cctx, cset, contents, standin, verified):
46 filename = lfutil.splitstandin(standin)
47 if not filename:
48 return False
49 fctx = cctx[standin]
50 key = (filename, fctx.filenode())
51 if key in verified:
52 return False
53
54 expecthash = fctx.data()[0:40]
55 storepath, exists = lfutil.findstorepath(self.remote, expecthash)
56 verified.add(key)
57 if not exists:
58 self.ui.warn(
59 _('changeset %s: %s references missing %s\n')
60 % (cset, filename, storepath))
61 return True # failed
62
63 if contents:
64 actualhash = lfutil.hashfile(storepath)
65 if actualhash != expecthash:
45 def _verifyfiles(self, contents, filestocheck):
46 failed = False
47 for cset, filename, expectedhash in filestocheck:
48 storepath, exists = lfutil.findstorepath(self.remote, expectedhash)
49 if not exists:
66 50 self.ui.warn(
67 _('changeset %s: %s references corrupted %s\n')
51 _('changeset %s: %s references missing %s\n')
68 52 % (cset, filename, storepath))
69 return True # failed
70 return False
53 failed = True
54 elif contents:
55 actualhash = lfutil.hashfile(storepath)
56 if actualhash != expectedhash:
57 self.ui.warn(
58 _('changeset %s: %s references corrupted %s\n')
59 % (cset, filename, storepath))
60 failed = True
61 return failed
@@ -65,34 +65,25 b' class remotestore(basestore.basestore):'
65 65
66 66 return lfutil.copyandhash(chunks, tmpfile)
67 67
68 def _verifyfile(self, cctx, cset, contents, standin, verified):
69 filename = lfutil.splitstandin(standin)
70 if not filename:
71 return False
72 fctx = cctx[standin]
73 key = (filename, fctx.filenode())
74 if key in verified:
75 return False
76
77 verified.add(key)
78
79 expecthash = fctx.data()[0:40]
80 stat = self._stat([expecthash])[expecthash]
81 if not stat:
82 return False
83 elif stat == 1:
84 self.ui.warn(
85 _('changeset %s: %s: contents differ\n')
86 % (cset, filename))
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)
68 def _verifyfiles(self, contents, filestocheck):
69 failed = False
70 for cset, filename, expectedhash in filestocheck:
71 stat = self._stat([expectedhash])[expectedhash]
72 if stat:
73 if stat == 1:
74 self.ui.warn(
75 _('changeset %s: %s: contents differ\n')
76 % (cset, filename))
77 failed = True
78 elif stat == 2:
79 self.ui.warn(
80 _('changeset %s: %s missing\n')
81 % (cset, filename))
82 failed = True
83 else:
84 raise RuntimeError('verify failed: unexpected response '
85 'from statlfile (%r)' % stat)
86 return failed
96 87
97 88 def batch(self):
98 89 '''Support for remote batching.'''
General Comments 0
You need to be logged in to leave comments. Login now