##// END OF EJS Templates
verify: also check dirstate...
Raphaël Gomès -
r50721:c84844cd default
parent child Browse files
Show More
@@ -87,6 +87,7 b' from . import ('
87 87 upgrade,
88 88 url as urlmod,
89 89 util,
90 verify,
90 91 vfs as vfsmod,
91 92 wireprotoframing,
92 93 wireprotoserver,
@@ -554,15 +555,9 b' def debugchangedfiles(ui, repo, rev, **o'
554 555 @command(b'debugcheckstate', [], b'')
555 556 def debugcheckstate(ui, repo):
556 557 """validate the correctness of the current dirstate"""
557 parent1, parent2 = repo.dirstate.parents()
558 m1 = repo[parent1].manifest()
559 m2 = repo[parent2].manifest()
560 errors = 0
561 for err in repo.dirstate.verify(m1, m2):
562 ui.warn(err)
563 errors += 1
558 errors = verify.verifier(repo)._verify_dirstate()
564 559 if errors:
565 errstr = _(b".hg/dirstate inconsistent with current parent's manifest")
560 errstr = _(b"dirstate inconsistent with current parent's manifest")
566 561 raise error.Abort(errstr)
567 562
568 563
@@ -15,6 +15,7 b' from .utils import stringutil'
15 15 from . import (
16 16 error,
17 17 pycompat,
18 requirements,
18 19 revlog,
19 20 util,
20 21 )
@@ -210,6 +211,12 b' class verifier:'
210 211 self._crosscheckfiles(filelinkrevs, filenodes)
211 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 220 # final report
214 221 ui.status(
215 222 _(b"checked %d changesets with %d changes to %d files\n")
@@ -225,6 +232,11 b' class verifier:'
225 232 msg = _(b"(first damaged changeset appears to be %d)\n")
226 233 msg %= min(self.badrevs)
227 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 240 return 1
229 241 return 0
230 242
@@ -585,3 +597,25 b' class verifier:'
585 597 self._warn(_(b"warning: orphan data file '%s'") % f)
586 598
587 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
@@ -190,6 +190,7 b' broken repositories will refuse to push'
190 190 checking manifests
191 191 crosschecking files in changesets and manifests
192 192 checking files
193 checking dirstate
193 194 checked 5 changesets with 12 changes to 4 files
194 195 checking subrepo links
195 196 subrepo 't' not found in revision 04aa62396ec6
@@ -121,6 +121,7 b' Verify should succeed:'
121 121 checking manifests
122 122 crosschecking files in changesets and manifests
123 123 checking files
124 checking dirstate
124 125 checked 1 changesets with 1 changes to 1 files
125 126
126 127 Repository root:
@@ -175,6 +175,7 b' Repo fails verification due to censorshi'
175 175 checking files
176 176 target@1: censored file data
177 177 target@2: censored file data
178 not checking dirstate because of previous errors
178 179 checked 5 changesets with 7 changes to 2 files
179 180 2 integrity errors encountered!
180 181 (first damaged changeset appears to be 1)
@@ -541,6 +541,7 b' changelog and manifest would have invali'
541 541 checking manifests
542 542 crosschecking files in changesets and manifests
543 543 checking files
544 checking dirstate
544 545 checked 2 changesets with 2 changes to 1 files
545 546 $ hg revert --no-backup -aq
546 547
@@ -825,6 +826,7 b' structured message channel:'
825 826 message: '\xa6Ditem@Cpos\xf6EtopicMcrosscheckingEtotal\xf6DtypeHprogressDunit@'
826 827 message: '\xa2DdataOchecking files\nDtypeFstatus'
827 828 message: '\xa6Ditem@Cpos\xf6EtopicHcheckingEtotal\xf6DtypeHprogressDunit@'
829 message: '\xa2DdataRchecking dirstate\nDtypeFstatus'
828 830 message: '\xa2DdataX/checked 0 changesets with 0 changes to 0 files\nDtypeFstatus'
829 831
830 832 >>> from hgclient import checkwith, readchannel, runcommand, stringio
@@ -61,6 +61,7 b' Testing verify:'
61 61 warning: revlog 'data/a.i' not in fncache!
62 62 warning: revlog 'data/a.i.hg/c.i' not in fncache!
63 63 warning: revlog 'data/a.i/b.i' not in fncache!
64 checking dirstate
64 65 checked 3 changesets with 3 changes to 3 files
65 66 3 warnings encountered!
66 67 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
@@ -349,6 +350,7 b' Clean cached versions'
349 350 checking manifests
350 351 crosschecking files in changesets and manifests
351 352 checking files
353 checking dirstate
352 354 checked 1 changesets with 1 changes to 1 files
353 355 $ cat .hg/store/fncache
354 356 data/y.i
@@ -242,6 +242,7 b" test 'verify' with remotestore:"
242 242 checking manifests
243 243 crosschecking files in changesets and manifests
244 244 checking files
245 checking dirstate
245 246 checked 1 changesets with 1 changes to 1 files
246 247 searching 1 changesets for largefiles
247 248 changeset 0:cf03e5bb9936: f1 missing
@@ -1545,6 +1545,7 b' revert some files to an older revision'
1545 1545 checking manifests
1546 1546 crosschecking files in changesets and manifests
1547 1547 checking files
1548 checking dirstate
1548 1549 checked 10 changesets with 28 changes to 10 files
1549 1550 searching 1 changesets for largefiles
1550 1551 verified existence of 3 revisions of 3 largefiles
@@ -345,6 +345,7 b' process.'
345 345 checking manifests
346 346 crosschecking files in changesets and manifests
347 347 checking files
348 checking dirstate
348 349 checked 8 changesets with 13 changes to 9 files
349 350 searching 7 changesets for largefiles
350 351 changeset 0:d4892ec57ce2: large references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/2e000fa7e85759c7f4c254d4d9c33ef481e459a7
@@ -789,6 +789,7 b' Repo with damaged lfs objects in any rev'
789 789 checking files
790 790 l@1: unpacking 46a2f24864bc: integrity check failed on l:0
791 791 large@0: unpacking 2c531e0992ff: integrity check failed on large:0
792 not checking dirstate because of previous errors
792 793 checked 5 changesets with 10 changes to 4 files
793 794 2 integrity errors encountered!
794 795 (first damaged changeset appears to be 0)
@@ -851,6 +852,7 b" blob, and the output shows that it isn't"
851 852 checking files
852 853 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
853 854 lfs blob sha256:66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e renamed large -> l
855 checking dirstate
854 856 checked 5 changesets with 10 changes to 4 files
855 857
856 858 Verify will not try to download lfs blobs, if told not to by the config option
@@ -865,6 +867,7 b' Verify will not try to download lfs blob'
865 867 checking files
866 868 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
867 869 lfs blob sha256:66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e renamed large -> l
870 checking dirstate
868 871 checked 5 changesets with 10 changes to 4 files
869 872
870 873 Verify will copy/link all lfs objects into the local store that aren't already
@@ -885,6 +888,7 b' the (uncorrupted) remote store.'
885 888 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
886 889 lfs: adding b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c to the usercache
887 890 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
891 checking dirstate
888 892 checked 5 changesets with 10 changes to 4 files
889 893
890 894 Verify will not copy/link a corrupted file from the usercache into the local
@@ -902,6 +906,7 b' store, and poison it. (The verify with '
902 906 large@0: unpacking 2c531e0992ff: integrity check failed on large:0
903 907 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
904 908 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
909 not checking dirstate because of previous errors
905 910 checked 5 changesets with 10 changes to 4 files
906 911 2 integrity errors encountered!
907 912 (first damaged changeset appears to be 0)
@@ -917,6 +922,7 b' store, and poison it. (The verify with '
917 922 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
918 923 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
919 924 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
925 checking dirstate
920 926 checked 5 changesets with 10 changes to 4 files
921 927
922 928 Damaging a file required by the update destination fails the update.
@@ -943,6 +949,7 b' usercache or local store.'
943 949 checking files
944 950 l@1: unpacking 46a2f24864bc: integrity check failed on l:0
945 951 large@0: unpacking 2c531e0992ff: integrity check failed on large:0
952 not checking dirstate because of previous errors
946 953 checked 5 changesets with 10 changes to 4 files
947 954 2 integrity errors encountered!
948 955 (first damaged changeset appears to be 0)
@@ -972,6 +979,7 b' avoids the corrupt lfs object in the ori'
972 979 large@0: unpacking 2c531e0992ff: integrity check failed on large:0
973 980 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
974 981 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
982 not checking dirstate because of previous errors
975 983 checked 5 changesets with 10 changes to 4 files
976 984 2 integrity errors encountered!
977 985 (first damaged changeset appears to be 0)
@@ -101,4 +101,5 b' Checking that repository has all the req'
101 101 checking directory manifests (tree !)
102 102 crosschecking files in changesets and manifests
103 103 checking files
104 checking dirstate
104 105 checked 40 changesets with 1 changes to 1 files
@@ -141,6 +141,7 b' Expected to fail:'
141 141
142 142 $ hg verify -q
143 143 beta@1: dddc47b3ba30 not in manifests
144 not checking dirstate because of previous errors
144 145 1 integrity errors encountered!
145 146 (first damaged changeset appears to be 1)
146 147 [1]
@@ -171,6 +172,7 b' Expected to fail:'
171 172
172 173 $ hg verify -q
173 174 beta@1: manifest refers to unknown revision dddc47b3ba30
175 not checking dirstate because of previous errors
174 176 1 integrity errors encountered!
175 177 (first damaged changeset appears to be 1)
176 178 [1]
@@ -66,6 +66,7 b''
66 66 (expected 1)
67 67 b@?: 736c29771fba not in manifests
68 68 warning: orphan data file 'data/c.i'
69 not checking dirstate because of previous errors
69 70 checked 2 changesets with 3 changes to 2 files
70 71 2 warnings encountered!
71 72 2 integrity errors encountered!
@@ -79,6 +80,7 b''
79 80 checking manifests
80 81 crosschecking files in changesets and manifests
81 82 checking files
83 checking dirstate
82 84 checked 2 changesets with 2 changes to 2 files
83 85 $ teststrip 0 2 r .hg/store/data/b.i
84 86 % before update 0, strip 2
@@ -93,6 +95,7 b''
93 95 checking manifests
94 96 crosschecking files in changesets and manifests
95 97 checking files
98 checking dirstate
96 99 checked 4 changesets with 4 changes to 3 files
97 100 % journal contents
98 101 (no journal)
@@ -124,6 +127,7 b''
124 127 b@?: rev 1 points to nonexistent changeset 2
125 128 (expected 1)
126 129 c@?: rev 0 points to nonexistent changeset 3
130 not checking dirstate because of previous errors
127 131 checked 2 changesets with 4 changes to 3 files
128 132 1 warnings encountered!
129 133 7 integrity errors encountered!
@@ -138,6 +142,7 b''
138 142 checking manifests
139 143 crosschecking files in changesets and manifests
140 144 checking files
145 checking dirstate
141 146 checked 2 changesets with 2 changes to 2 files
142 147
143 148 $ cd ..
@@ -619,6 +619,7 b' Verify reports missing dirlog'
619 619 b/bar/orange/fly/housefly.txt@0: in changeset but not in manifest
620 620 b/foo/apple/bees/flower.py@0: in changeset but not in manifest
621 621 checking files
622 not checking dirstate because of previous errors
622 623 checked 4 changesets with 18 changes to 8 files
623 624 6 warnings encountered! (reporevlogstore !)
624 625 9 integrity errors encountered!
@@ -644,6 +645,7 b' Verify reports missing dirlog entry'
644 645 (expected None)
645 646 crosschecking files in changesets and manifests
646 647 checking files
648 not checking dirstate because of previous errors
647 649 checked 4 changesets with 18 changes to 8 files
648 650 2 warnings encountered!
649 651 8 integrity errors encountered!
@@ -20,6 +20,7 b' verify'
20 20 checking manifests
21 21 crosschecking files in changesets and manifests
22 22 checking files
23 checking dirstate
23 24 checked 1 changesets with 3 changes to 3 files
24 25
25 26 verify with journal
@@ -31,6 +32,7 b' verify with journal'
31 32 checking manifests
32 33 crosschecking files in changesets and manifests
33 34 checking files
35 checking dirstate
34 36 checked 1 changesets with 3 changes to 3 files
35 37 $ rm .hg/store/journal
36 38
@@ -55,6 +57,7 b' introduce some bugs in repo'
55 57 warning: revlog 'data/bar.txt.i' not in fncache!
56 58 0: empty or missing bar.txt
57 59 bar.txt@0: manifest refers to unknown revision 256559129457
60 not checking dirstate because of previous errors
58 61 checked 1 changesets with 0 changes to 3 files
59 62 3 warnings encountered!
60 63 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
@@ -83,6 +86,7 b' Entire changelog missing'
83 86 0: empty or missing changelog
84 87 manifest@0: d0b6632564d4 not in changesets
85 88 manifest@1: 941fc4534185 not in changesets
89 not checking dirstate because of previous errors
86 90 3 integrity errors encountered!
87 91 (first damaged changeset appears to be 0)
88 92 [1]
@@ -93,6 +97,7 b' Entire manifest log missing'
93 97 $ rm .hg/store/00manifest.*
94 98 $ hg verify -q
95 99 0: empty or missing manifest
100 not checking dirstate because of previous errors
96 101 1 integrity errors encountered!
97 102 (first damaged changeset appears to be 0)
98 103 [1]
@@ -106,6 +111,7 b' Entire filelog missing'
106 111 0: empty or missing file
107 112 file@0: manifest refers to unknown revision 362fef284ce2
108 113 file@1: manifest refers to unknown revision c10f2164107d
114 not checking dirstate because of previous errors
109 115 1 warnings encountered!
110 116 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
111 117 3 integrity errors encountered!
@@ -119,7 +125,13 b' Entire changelog and manifest log missin'
119 125 $ rm .hg/store/00manifest.*
120 126 $ hg verify -q
121 127 warning: orphan data file 'data/file.i'
128 warning: ignoring unknown working parent c5ddb05ab828!
129 file marked as tracked in p1 but not in manifest1
122 130 1 warnings encountered!
131 1 integrity errors encountered!
132 dirstate inconsistent with current parent's manifest
133 1 dirstate errors
134 [1]
123 135 $ cp -R .hg/store-full/. .hg/store
124 136
125 137 Entire changelog and filelog missing
@@ -134,6 +146,7 b' Entire changelog and filelog missing'
134 146 ?: empty or missing file
135 147 file@0: manifest refers to unknown revision 362fef284ce2
136 148 file@1: manifest refers to unknown revision c10f2164107d
149 not checking dirstate because of previous errors
137 150 1 warnings encountered!
138 151 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
139 152 6 integrity errors encountered!
@@ -149,6 +162,7 b' Entire manifest log and filelog missing'
149 162 0: empty or missing manifest
150 163 warning: revlog 'data/file.i' not in fncache!
151 164 0: empty or missing file
165 not checking dirstate because of previous errors
152 166 1 warnings encountered!
153 167 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
154 168 2 integrity errors encountered!
@@ -164,6 +178,7 b' Changelog missing entry'
164 178 manifest@?: 941fc4534185 not in changesets
165 179 file@?: rev 1 points to nonexistent changeset 1
166 180 (expected 0)
181 not checking dirstate because of previous errors
167 182 1 warnings encountered!
168 183 3 integrity errors encountered!
169 184 [1]
@@ -175,6 +190,7 b' Manifest log missing entry'
175 190 $ hg verify -q
176 191 manifest@1: changeset refers to unknown revision 941fc4534185
177 192 file@1: c10f2164107d not in manifests
193 not checking dirstate because of previous errors
178 194 2 integrity errors encountered!
179 195 (first damaged changeset appears to be 1)
180 196 [1]
@@ -185,6 +201,7 b' Filelog missing entry'
185 201 $ cp -f .hg/store-partial/data/file.* .hg/store/data
186 202 $ hg verify -q
187 203 file@1: manifest refers to unknown revision c10f2164107d
204 not checking dirstate because of previous errors
188 205 1 integrity errors encountered!
189 206 (first damaged changeset appears to be 1)
190 207 [1]
@@ -198,6 +215,7 b' Changelog and manifest log missing entry'
198 215 file@?: rev 1 points to nonexistent changeset 1
199 216 (expected 0)
200 217 file@?: c10f2164107d not in manifests
218 not checking dirstate because of previous errors
201 219 1 warnings encountered!
202 220 2 integrity errors encountered!
203 221 [1]
@@ -211,6 +229,7 b' Changelog and filelog missing entry'
211 229 manifest@?: rev 1 points to nonexistent changeset 1
212 230 manifest@?: 941fc4534185 not in changesets
213 231 file@?: manifest refers to unknown revision c10f2164107d
232 not checking dirstate because of previous errors
214 233 3 integrity errors encountered!
215 234 [1]
216 235 $ cp -R .hg/store-full/. .hg/store
@@ -221,6 +240,7 b' Manifest and filelog missing entry'
221 240 $ cp -f .hg/store-partial/data/file.* .hg/store/data
222 241 $ hg verify -q
223 242 manifest@1: changeset refers to unknown revision 941fc4534185
243 not checking dirstate because of previous errors
224 244 1 integrity errors encountered!
225 245 (first damaged changeset appears to be 1)
226 246 [1]
@@ -236,6 +256,7 b' Corrupt changelog base node to cause fai'
236 256 manifest@?: d0b6632564d4 not in changesets
237 257 file@?: rev 0 points to unexpected changeset 0
238 258 (expected 1)
259 not checking dirstate because of previous errors
239 260 1 warnings encountered!
240 261 4 integrity errors encountered!
241 262 (first damaged changeset appears to be 0)
@@ -249,6 +270,7 b' Corrupt manifest log base node to cause '
249 270 $ hg verify -q
250 271 manifest@0: reading delta d0b6632564d4: * (glob)
251 272 file@0: 362fef284ce2 not in manifests
273 not checking dirstate because of previous errors
252 274 2 integrity errors encountered!
253 275 (first damaged changeset appears to be 0)
254 276 [1]
@@ -260,6 +282,7 b' Corrupt filelog base node to cause failu'
260 282 > 2> /dev/null
261 283 $ hg verify -q
262 284 file@0: unpacking 362fef284ce2: * (glob)
285 not checking dirstate because of previous errors
263 286 1 integrity errors encountered!
264 287 (first damaged changeset appears to be 0)
265 288 [1]
@@ -290,6 +313,7 b' test revlog corruption'
290 313 $ hg verify -q
291 314 a@1: broken revlog! (index a is corrupted)
292 315 warning: orphan data file 'data/a.i'
316 not checking dirstate because of previous errors
293 317 1 warnings encountered!
294 318 1 integrity errors encountered!
295 319 (first damaged changeset appears to be 1)
@@ -307,6 +331,7 b' test revlog format 0'
307 331 checking manifests
308 332 crosschecking files in changesets and manifests
309 333 checking files
334 checking dirstate
310 335 checked 1 changesets with 1 changes to 1 files
311 336 $ cd ..
312 337
@@ -332,6 +357,7 b' test flag processor and skipflags'
332 357
333 358 $ hg verify -q
334 359 base64@0: unpacking 794cee7777cb: integrity check failed on base64:0
360 not checking dirstate because of previous errors
335 361 1 integrity errors encountered!
336 362 (first damaged changeset appears to be 0)
337 363 [1]
General Comments 0
You need to be logged in to leave comments. Login now