Show More
@@ -20,12 +20,23 b' def _verify(repo):' | |||
|
20 | 20 | filelinkrevs = {} |
|
21 | 21 | filenodes = {} |
|
22 | 22 | changesets = revisions = files = 0 |
|
23 | firstbad = [None] | |
|
23 | 24 | errors = [0] |
|
24 | 25 | warnings = [0] |
|
25 | 26 | neededmanifests = {} |
|
26 | 27 | |
|
27 | def err(msg): | |
|
28 | repo.ui.warn(msg + "\n") | |
|
28 | def err(linkrev, msg, filename=None): | |
|
29 | if linkrev != None: | |
|
30 | if firstbad[0] != None: | |
|
31 | firstbad[0] = min(firstbad[0], linkrev) | |
|
32 | else: | |
|
33 | firstbad[0] = linkrev | |
|
34 | else: | |
|
35 | linkrev = "?" | |
|
36 | msg = "%s: %s" % (linkrev, msg) | |
|
37 | if filename: | |
|
38 | msg = "%s@%s" % (filename, msg) | |
|
39 | repo.ui.warn(" " + msg + "\n") | |
|
29 | 40 | errors[0] += 1 |
|
30 | 41 | |
|
31 | 42 | def warn(msg): |
@@ -35,9 +46,9 b' def _verify(repo):' | |||
|
35 | 46 | def checksize(obj, name): |
|
36 | 47 | d = obj.checksize() |
|
37 | 48 | if d[0]: |
|
38 |
err(_(" |
|
|
49 | err(None, _("data length off by %d bytes") % d[0], name) | |
|
39 | 50 | if d[1]: |
|
40 |
err(_(" |
|
|
51 | err(None, _("index contains %d extra bytes") % d[1], name) | |
|
41 | 52 | |
|
42 | 53 | def checkversion(obj, name): |
|
43 | 54 | if obj.version != revlog.REVLOGV0: |
@@ -60,25 +71,25 b' def _verify(repo):' | |||
|
60 | 71 | n = repo.changelog.node(i) |
|
61 | 72 | l = repo.changelog.linkrev(n) |
|
62 | 73 | if l != i: |
|
63 |
err(_("incorrect link (%d) for changeset |
|
|
74 | err(i, _("incorrect link (%d) for changeset") %(l)) | |
|
64 | 75 | if n in seen: |
|
65 |
err(_("duplicate changeset at revision %d") % |
|
|
66 |
seen[n] = |
|
|
76 | err(i, _("duplicates changeset at revision %d") % seen[n]) | |
|
77 | seen[n] = i | |
|
67 | 78 | |
|
68 | 79 | for p in repo.changelog.parents(n): |
|
69 | 80 | if p not in repo.changelog.nodemap: |
|
70 |
err(_("changeset |
|
|
71 | (short(n), short(p))) | |
|
81 | err(i, _("changeset has unknown parent %s") % short(p)) | |
|
72 | 82 | try: |
|
73 | 83 | changes = repo.changelog.read(n) |
|
74 | 84 | except KeyboardInterrupt: |
|
75 | 85 | repo.ui.warn(_("interrupted")) |
|
76 | 86 | raise |
|
77 | 87 | except Exception, inst: |
|
78 |
err(_("unpacking changeset |
|
|
88 | err(i, _("unpacking changeset: %s") % inst) | |
|
79 | 89 | continue |
|
80 | 90 | |
|
81 | neededmanifests[changes[0]] = n | |
|
91 | if changes[0] not in neededmanifests: | |
|
92 | neededmanifests[changes[0]] = i | |
|
82 | 93 | |
|
83 | 94 | for f in changes[3]: |
|
84 | 95 | filelinkrevs.setdefault(f, []).append(i) |
@@ -93,45 +104,50 b' def _verify(repo):' | |||
|
93 | 104 | l = repo.manifest.linkrev(n) |
|
94 | 105 | |
|
95 | 106 | if l < 0 or l >= repo.changelog.count(): |
|
96 |
err(_("bad |
|
|
107 | err(None, _("bad link (%d) at manifest revision %d") % (l, i)) | |
|
97 | 108 | |
|
98 | 109 | if n in neededmanifests: |
|
99 | 110 | del neededmanifests[n] |
|
100 | 111 | |
|
101 | 112 | if n in seen: |
|
102 |
err(_("duplicate manifest |
|
|
113 | err(l, _("duplicates manifest from %d") % seen[n]) | |
|
103 | 114 | |
|
104 |
seen[n] = |
|
|
115 | seen[n] = l | |
|
105 | 116 | |
|
106 | 117 | for p in repo.manifest.parents(n): |
|
107 | 118 | if p not in repo.manifest.nodemap: |
|
108 |
err(_("manifest |
|
|
109 | (short(n), short(p))) | |
|
119 | err(l, _("manifest has unknown parent %s") % short(p)) | |
|
110 | 120 | |
|
111 | 121 | try: |
|
112 | 122 | for f, fn in repo.manifest.readdelta(n).iteritems(): |
|
113 |
filenodes.setdefault(f, {}) |
|
|
123 | fns = filenodes.setdefault(f, {}) | |
|
124 | if fn not in fns: | |
|
125 | fns[fn] = n | |
|
114 | 126 | except KeyboardInterrupt: |
|
115 | 127 | repo.ui.warn(_("interrupted")) |
|
116 | 128 | raise |
|
117 | 129 | except Exception, inst: |
|
118 |
err(_("reading |
|
|
130 | err(l, _("reading manifest delta: %s") % inst) | |
|
119 | 131 | continue |
|
120 | 132 | |
|
121 | 133 | repo.ui.status(_("crosschecking files in changesets and manifests\n")) |
|
122 | 134 | |
|
123 |
|
|
|
124 | err(_("Changeset %s refers to unknown manifest %s") % | |
|
125 | (short(m), short(c))) | |
|
126 | del neededmanifests | |
|
135 | nm = neededmanifests.items() | |
|
136 | nm.sort() | |
|
137 | for m, c in nm: | |
|
138 | err(m, _("changeset refers to unknown manifest %s") % short(c)) | |
|
139 | del neededmanifests, nm | |
|
127 | 140 | |
|
128 | 141 | for f in filenodes: |
|
129 | 142 | if f not in filelinkrevs: |
|
130 | err(_("file %s in manifest but not in changesets") % f) | |
|
143 | lrs = [repo.manifest.linkrev(n) for n in filenodes[f]] | |
|
144 | lrs.sort() | |
|
145 | err(lrs[0], _("in manifest but not in changeset"), f) | |
|
131 | 146 | |
|
132 | 147 | for f in filelinkrevs: |
|
133 | 148 | if f not in filenodes: |
|
134 | err(_("file %s in changeset but not in manifest") % f) | |
|
149 | lr = filelinkrevs[f][0] | |
|
150 | err(lr, _("in changeset but not in manifest"), f) | |
|
135 | 151 | |
|
136 | 152 | repo.ui.status(_("checking files\n")) |
|
137 | 153 | ff = filenodes.keys() |
@@ -141,33 +157,40 b' def _verify(repo):' | |||
|
141 | 157 | continue |
|
142 | 158 | files += 1 |
|
143 | 159 | if not f: |
|
144 | err(_("file without name in manifest %s") % short(n)) | |
|
160 | lr = repo.manifest.linkrev(filenodes[f][0]) | |
|
161 | err(lr, _("file without name in manifest %s") % short(ff[n])) | |
|
145 | 162 | continue |
|
146 | 163 | fl = repo.file(f) |
|
147 | 164 | checkversion(fl, f) |
|
148 | 165 | checksize(fl, f) |
|
149 | 166 | |
|
167 | seen = {} | |
|
150 | 168 | nodes = {nullid: 1} |
|
151 | seen = {} | |
|
152 | 169 | for i in xrange(fl.count()): |
|
153 | 170 | revisions += 1 |
|
154 | 171 | n = fl.node(i) |
|
172 | flr = fl.linkrev(n) | |
|
173 | ||
|
174 | if flr not in filelinkrevs.get(f, []): | |
|
175 | if flr < 0 or flr >= repo.changelog.count(): | |
|
176 | err(None, _("rev %d point to nonexistent changeset %d") | |
|
177 | % (i, flr), f) | |
|
178 | else: | |
|
179 | err(None, _("rev %d points to unexpected changeset %d") | |
|
180 | % (i, flr), f) | |
|
181 | if f in filelinkrevs: | |
|
182 | warn(_(" (expected %s)") % filelinkrevs[f][0]) | |
|
183 | flr = None # can't be trusted | |
|
184 | else: | |
|
185 | filelinkrevs[f].remove(flr) | |
|
155 | 186 | |
|
156 | 187 | if n in seen: |
|
157 |
err(_(" |
|
|
188 | err(flr, _("duplicate revision %d") % i, f) | |
|
158 | 189 | if n not in filenodes[f]: |
|
159 |
err(_(" |
|
|
190 | err(flr, _("%s not in manifests") % (short(n)), f) | |
|
160 | 191 | else: |
|
161 | 192 | del filenodes[f][n] |
|
162 | 193 | |
|
163 | flr = fl.linkrev(n) | |
|
164 | if flr not in filelinkrevs.get(f, []): | |
|
165 | err(_("%s:%s points to unexpected changeset %d") | |
|
166 | % (f, short(n), flr)) | |
|
167 | err(_("expecting one of %s" % filelinkrevs.get(f, []))) | |
|
168 | else: | |
|
169 | filelinkrevs[f].remove(flr) | |
|
170 | ||
|
171 | 194 | # verify contents |
|
172 | 195 | try: |
|
173 | 196 | t = fl.read(n) |
@@ -175,16 +198,22 b' def _verify(repo):' | |||
|
175 | 198 | repo.ui.warn(_("interrupted")) |
|
176 | 199 | raise |
|
177 | 200 | except Exception, inst: |
|
178 |
err(_("unpacking |
|
|
201 | err(flr, _("unpacking %s: %s") % (short(n), inst), f) | |
|
179 | 202 | |
|
180 | 203 | # verify parents |
|
181 | (p1, p2) = fl.parents(n) | |
|
182 | if p1 not in nodes: | |
|
183 | err(_("file %s:%s unknown parent 1 %s") % | |
|
184 | (f, short(n), short(p1))) | |
|
185 | if p2 not in nodes: | |
|
186 | err(_("file %s:%s unknown parent 2 %s") % | |
|
187 | (f, short(n), short(p1))) | |
|
204 | try: | |
|
205 | (p1, p2) = fl.parents(n) | |
|
206 | if p1 not in nodes: | |
|
207 | err(flr, _("unknown parent 1 %s of %s") % | |
|
208 | (short(p1), short(n)), f) | |
|
209 | if p2 not in nodes: | |
|
210 | err(flr, _("unknown parent 2 %s of %s") % | |
|
211 | (short(p2), short(p1)), f) | |
|
212 | except KeyboardInterrupt: | |
|
213 | repo.ui.warn(_("interrupted")) | |
|
214 | raise | |
|
215 | except Exception, inst: | |
|
216 | err(flr, _("checking parents of %s: %s") % (short(n), inst), f) | |
|
188 | 217 | nodes[n] = 1 |
|
189 | 218 | |
|
190 | 219 | # check renames |
@@ -197,11 +226,15 b' def _verify(repo):' | |||
|
197 | 226 | repo.ui.warn(_("interrupted")) |
|
198 | 227 | raise |
|
199 | 228 | except Exception, inst: |
|
200 |
err(_("checking rename o |
|
|
229 | err(flr, _("checking rename of %s: %s") % | |
|
230 | (short(n), inst), f) | |
|
201 | 231 | |
|
202 | 232 | # cross-check |
|
203 | for node in filenodes[f]: | |
|
204 | err(_("node %s in manifests not in %s") % (hex(node), f)) | |
|
233 | fns = [(repo.manifest.linkrev(filenodes[f][n]), n) | |
|
234 | for n in filenodes[f]] | |
|
235 | fns.sort() | |
|
236 | for lr, node in fns: | |
|
237 | err(lr, _("%s in manifests not found") % short(node), f) | |
|
205 | 238 | |
|
206 | 239 | repo.ui.status(_("%d files, %d changesets, %d total revisions\n") % |
|
207 | 240 | (files, changesets, revisions)) |
@@ -210,5 +243,8 b' def _verify(repo):' | |||
|
210 | 243 | repo.ui.warn(_("%d warnings encountered!\n") % warnings[0]) |
|
211 | 244 | if errors[0]: |
|
212 | 245 | repo.ui.warn(_("%d integrity errors encountered!\n") % errors[0]) |
|
246 | if firstbad[0]: | |
|
247 | repo.ui.warn(_("(first damaged changeset appears to be %d)\n") | |
|
248 | % firstbad[0]) | |
|
213 | 249 | return 1 |
|
214 | 250 |
General Comments 0
You need to be logged in to leave comments.
Login now