equal
deleted
inserted
replaced
13 from .utils import stringutil |
13 from .utils import stringutil |
14 |
14 |
15 from . import ( |
15 from . import ( |
16 error, |
16 error, |
17 pycompat, |
17 pycompat, |
|
18 requirements, |
18 revlog, |
19 revlog, |
19 util, |
20 util, |
20 ) |
21 ) |
21 |
22 |
22 VERIFY_DEFAULT = 0 |
23 VERIFY_DEFAULT = 0 |
208 filenodes = self._verifymanifest(mflinkrevs) |
209 filenodes = self._verifymanifest(mflinkrevs) |
209 del mflinkrevs |
210 del mflinkrevs |
210 self._crosscheckfiles(filelinkrevs, filenodes) |
211 self._crosscheckfiles(filelinkrevs, filenodes) |
211 totalfiles, filerevisions = self._verifyfiles(filenodes, filelinkrevs) |
212 totalfiles, filerevisions = self._verifyfiles(filenodes, filelinkrevs) |
212 |
213 |
|
214 if self.errors: |
|
215 ui.warn(_(b"not checking dirstate because of previous errors\n")) |
|
216 dirstate_errors = 0 |
|
217 else: |
|
218 dirstate_errors = self._verify_dirstate() |
|
219 |
213 # final report |
220 # final report |
214 ui.status( |
221 ui.status( |
215 _(b"checked %d changesets with %d changes to %d files\n") |
222 _(b"checked %d changesets with %d changes to %d files\n") |
216 % (len(repo.changelog), filerevisions, totalfiles) |
223 % (len(repo.changelog), filerevisions, totalfiles) |
217 ) |
224 ) |
223 ui.warn(_(b"%d integrity errors encountered!\n") % self.errors) |
230 ui.warn(_(b"%d integrity errors encountered!\n") % self.errors) |
224 if self.badrevs: |
231 if self.badrevs: |
225 msg = _(b"(first damaged changeset appears to be %d)\n") |
232 msg = _(b"(first damaged changeset appears to be %d)\n") |
226 msg %= min(self.badrevs) |
233 msg %= min(self.badrevs) |
227 ui.warn(msg) |
234 ui.warn(msg) |
|
235 if dirstate_errors: |
|
236 ui.warn( |
|
237 _(b"dirstate inconsistent with current parent's manifest\n") |
|
238 ) |
|
239 ui.warn(_(b"%d dirstate errors\n") % dirstate_errors) |
228 return 1 |
240 return 1 |
229 return 0 |
241 return 0 |
230 |
242 |
231 def _verifychangelog(self): |
243 def _verifychangelog(self): |
232 """verify the changelog of a repository |
244 """verify the changelog of a repository |
583 if self.warnorphanstorefiles: |
595 if self.warnorphanstorefiles: |
584 for f in sorted(storefiles): |
596 for f in sorted(storefiles): |
585 self._warn(_(b"warning: orphan data file '%s'") % f) |
597 self._warn(_(b"warning: orphan data file '%s'") % f) |
586 |
598 |
587 return len(files), revisions |
599 return len(files), revisions |
|
600 |
|
601 def _verify_dirstate(self): |
|
602 """Check that the dirstate is consistent with the parent's manifest""" |
|
603 repo = self.repo |
|
604 ui = self.ui |
|
605 ui.status(_(b"checking dirstate\n")) |
|
606 |
|
607 parent1, parent2 = repo.dirstate.parents() |
|
608 m1 = repo[parent1].manifest() |
|
609 m2 = repo[parent2].manifest() |
|
610 dirstate_errors = 0 |
|
611 |
|
612 is_narrow = requirements.NARROW_REQUIREMENT in repo.requirements |
|
613 narrow_matcher = repo.narrowmatch() if is_narrow else None |
|
614 |
|
615 for err in repo.dirstate.verify(m1, m2, narrow_matcher): |
|
616 ui.error(err) |
|
617 dirstate_errors += 1 |
|
618 |
|
619 if dirstate_errors: |
|
620 self.errors += dirstate_errors |
|
621 return dirstate_errors |