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] |
|
|||
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: |
|
49 | if not exists: | |
58 | self.ui.warn( |
|
50 | self.ui.warn( | |
59 | _('changeset %s: %s references missing %s\n') |
|
51 | _('changeset %s: %s references missing %s\n') | |
60 | % (cset, filename, storepath)) |
|
52 | % (cset, filename, storepath)) | |
61 | return True # failed |
|
53 | failed = True | |
62 |
|
54 | elif contents: | ||
63 | if contents: |
|
|||
64 | actualhash = lfutil.hashfile(storepath) |
|
55 | actualhash = lfutil.hashfile(storepath) | |
65 | if actualhash != expecthash: |
|
56 | if actualhash != expectedhash: | |
66 | self.ui.warn( |
|
57 | self.ui.warn( | |
67 | _('changeset %s: %s references corrupted %s\n') |
|
58 | _('changeset %s: %s references corrupted %s\n') | |
68 | % (cset, filename, storepath)) |
|
59 | % (cset, filename, storepath)) | |
69 |
|
|
60 | failed = True | |
70 |
return |
|
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: |
|
|||
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( |
|
74 | self.ui.warn( | |
85 | _('changeset %s: %s: contents differ\n') |
|
75 | _('changeset %s: %s: contents differ\n') | |
86 | % (cset, filename)) |
|
76 | % (cset, filename)) | |
87 |
|
|
77 | failed = True | |
88 | elif stat == 2: |
|
78 | elif stat == 2: | |
89 | self.ui.warn( |
|
79 | self.ui.warn( | |
90 | _('changeset %s: %s missing\n') |
|
80 | _('changeset %s: %s missing\n') | |
91 | % (cset, filename)) |
|
81 | % (cset, filename)) | |
92 |
|
|
82 | failed = True | |
93 | else: |
|
83 | else: | |
94 |
raise RuntimeError('verify failed: unexpected response |
|
84 | raise RuntimeError('verify failed: unexpected response ' | |
95 | 'statlfile (%r)' % stat) |
|
85 | 'from statlfile (%r)' % stat) | |
|
86 | return failed | |||
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