Show More
@@ -116,19 +116,26 b' class basestore(object):' | |||||
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 |
|
|
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])) | |
@@ -150,13 +157,11 b' class basestore(object):' | |||||
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 |
|
160 | def _verifyfiles(self, contents, filestocheck): | |
154 |
'''Perform the actual verification of |
|
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 |
@@ -42,29 +42,20 b' class localstore(basestore.basestore):' | |||||
42 | with open(path, 'rb') as fd: |
|
42 | with open(path, 'rb') as fd: | |
43 | return lfutil.copyandhash(fd, tmpfile) |
|
43 | return lfutil.copyandhash(fd, tmpfile) | |
44 |
|
44 | |||
45 |
def _verifyfile(self |
|
45 | def _verifyfiles(self, contents, filestocheck): | |
46 | filename = lfutil.splitstandin(standin) |
|
46 | failed = False | |
47 | if not filename: |
|
47 | for cset, filename, expectedhash in filestocheck: | |
48 | return False |
|
48 | storepath, exists = lfutil.findstorepath(self.remote, expectedhash) | |
49 | fctx = cctx[standin] |
|
49 | if not exists: | |
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: |
|
|||
66 | self.ui.warn( |
|
50 | self.ui.warn( | |
67 |
_('changeset %s: %s references |
|
51 | _('changeset %s: %s references missing %s\n') | |
68 | % (cset, filename, storepath)) |
|
52 | % (cset, filename, storepath)) | |
69 | return True # failed |
|
53 | failed = True | |
70 | return False |
|
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 | return lfutil.copyandhash(chunks, tmpfile) |
|
66 | return lfutil.copyandhash(chunks, tmpfile) | |
67 |
|
67 | |||
68 |
def _verifyfile(self |
|
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.''' |
General Comments 0
You need to be logged in to leave comments.
Login now