Mercurial > public > mercurial-scm > hg
comparison mercurial/verify.py @ 27645:df8973e1fb45
verify: move file cross checking to its own function
This is part of making verify more modular so extensions can hook into it.
author | Durham Goode <durham@fb.com> |
---|---|
date | Tue, 05 Jan 2016 18:31:51 -0800 |
parents | 331e5c28f5f0 |
children | 8f43793382c6 |
comparison
equal
deleted
inserted
replaced
27644:331e5c28f5f0 | 27645:df8973e1fb45 |
---|---|
152 revlogv1 = self.revlogv1 | 152 revlogv1 = self.revlogv1 |
153 if ui.verbose or not revlogv1: | 153 if ui.verbose or not revlogv1: |
154 ui.status(_("repository uses revlog format %d\n") % | 154 ui.status(_("repository uses revlog format %d\n") % |
155 (revlogv1 and 1 or 0)) | 155 (revlogv1 and 1 or 0)) |
156 | 156 |
157 havecl = self.havecl | |
158 havemf = self.havemf | |
159 | |
160 ui.status(_("checking changesets\n")) | 157 ui.status(_("checking changesets\n")) |
161 seen = {} | 158 seen = {} |
162 self.checklog(cl, "changelog", 0) | 159 self.checklog(cl, "changelog", 0) |
163 total = len(repo) | 160 total = len(repo) |
164 for i in repo: | 161 for i in repo: |
206 _normpath(f), {}).setdefault(fn, lr) | 203 _normpath(f), {}).setdefault(fn, lr) |
207 except Exception as inst: | 204 except Exception as inst: |
208 self.exc(lr, _("reading manifest delta %s") % short(n), inst) | 205 self.exc(lr, _("reading manifest delta %s") % short(n), inst) |
209 ui.progress(_('checking'), None) | 206 ui.progress(_('checking'), None) |
210 | 207 |
211 ui.status(_("crosschecking files in changesets and manifests\n")) | 208 self._crosscheckfiles(mflinkrevs, filelinkrevs, filenodes) |
212 | |
213 total = len(mflinkrevs) + len(filelinkrevs) + len(filenodes) | |
214 count = 0 | |
215 if havemf: | |
216 for c, m in sorted([(c, m) for m in mflinkrevs | |
217 for c in mflinkrevs[m]]): | |
218 count += 1 | |
219 if m == nullid: | |
220 continue | |
221 ui.progress(_('crosschecking'), count, total=total) | |
222 self.err(c, _("changeset refers to unknown manifest %s") % | |
223 short(m)) | |
224 mflinkrevs = None # del is bad here due to scope issues | |
225 | |
226 for f in sorted(filelinkrevs): | |
227 count += 1 | |
228 ui.progress(_('crosschecking'), count, total=total) | |
229 if f not in filenodes: | |
230 lr = filelinkrevs[f][0] | |
231 self.err(lr, _("in changeset but not in manifest"), f) | |
232 | |
233 if havecl: | |
234 for f in sorted(filenodes): | |
235 count += 1 | |
236 ui.progress(_('crosschecking'), count, total=total) | |
237 if f not in filelinkrevs: | |
238 try: | |
239 fl = repo.file(f) | |
240 lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]]) | |
241 except Exception: | |
242 lr = None | |
243 self.err(lr, _("in manifest but not in changeset"), f) | |
244 | |
245 ui.progress(_('crosschecking'), None) | |
246 | 209 |
247 totalfiles, filerevisions = self._verifyfiles(filenodes, filelinkrevs) | 210 totalfiles, filerevisions = self._verifyfiles(filenodes, filelinkrevs) |
248 revisions += filerevisions | 211 revisions += filerevisions |
249 | 212 |
250 ui.status(_("%d files, %d changesets, %d total revisions\n") % | 213 ui.status(_("%d files, %d changesets, %d total revisions\n") % |
258 ui.warn(_("%d integrity errors encountered!\n") % self.errors) | 221 ui.warn(_("%d integrity errors encountered!\n") % self.errors) |
259 if badrevs: | 222 if badrevs: |
260 ui.warn(_("(first damaged changeset appears to be %d)\n") | 223 ui.warn(_("(first damaged changeset appears to be %d)\n") |
261 % min(badrevs)) | 224 % min(badrevs)) |
262 return 1 | 225 return 1 |
226 | |
227 def _crosscheckfiles(self, mflinkrevs, filelinkrevs, filenodes): | |
228 repo = self.repo | |
229 ui = self.ui | |
230 ui.status(_("crosschecking files in changesets and manifests\n")) | |
231 | |
232 total = len(mflinkrevs) + len(filelinkrevs) + len(filenodes) | |
233 count = 0 | |
234 if self.havemf: | |
235 for c, m in sorted([(c, m) for m in mflinkrevs | |
236 for c in mflinkrevs[m]]): | |
237 count += 1 | |
238 if m == nullid: | |
239 continue | |
240 ui.progress(_('crosschecking'), count, total=total) | |
241 self.err(c, _("changeset refers to unknown manifest %s") % | |
242 short(m)) | |
243 mflinkrevs = None # del is bad here due to scope issues | |
244 | |
245 for f in sorted(filelinkrevs): | |
246 count += 1 | |
247 ui.progress(_('crosschecking'), count, total=total) | |
248 if f not in filenodes: | |
249 lr = filelinkrevs[f][0] | |
250 self.err(lr, _("in changeset but not in manifest"), f) | |
251 | |
252 if self.havecl: | |
253 for f in sorted(filenodes): | |
254 count += 1 | |
255 ui.progress(_('crosschecking'), count, total=total) | |
256 if f not in filelinkrevs: | |
257 try: | |
258 fl = repo.file(f) | |
259 lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]]) | |
260 except Exception: | |
261 lr = None | |
262 self.err(lr, _("in manifest but not in changeset"), f) | |
263 | |
264 ui.progress(_('crosschecking'), None) | |
263 | 265 |
264 def _verifyfiles(self, filenodes, filelinkrevs): | 266 def _verifyfiles(self, filenodes, filelinkrevs): |
265 repo = self.repo | 267 repo = self.repo |
266 ui = self.ui | 268 ui = self.ui |
267 lrugetctx = self.lrugetctx | 269 lrugetctx = self.lrugetctx |