Show More
@@ -1,491 +1,486 b'' | |||
|
1 | 1 | # verify.py - repository integrity checking for Mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import os |
|
11 | 11 | |
|
12 | 12 | from .i18n import _ |
|
13 | 13 | from .node import ( |
|
14 | 14 | nullid, |
|
15 | 15 | short, |
|
16 | 16 | ) |
|
17 | 17 | |
|
18 | 18 | from . import ( |
|
19 | 19 | error, |
|
20 | 20 | pycompat, |
|
21 | 21 | revlog, |
|
22 | 22 | scmutil, |
|
23 | 23 | util, |
|
24 | 24 | ) |
|
25 | 25 | |
|
26 | 26 | def verify(repo): |
|
27 | 27 | with repo.lock(): |
|
28 | 28 | return verifier(repo).verify() |
|
29 | 29 | |
|
30 | 30 | def _normpath(f): |
|
31 | 31 | # under hg < 2.4, convert didn't sanitize paths properly, so a |
|
32 | 32 | # converted repo may contain repeated slashes |
|
33 | 33 | while '//' in f: |
|
34 | 34 | f = f.replace('//', '/') |
|
35 | 35 | return f |
|
36 | 36 | |
|
37 | 37 | class verifier(object): |
|
38 | 38 | # The match argument is always None in hg core, but e.g. the narrowhg |
|
39 | 39 | # extension will pass in a matcher here. |
|
40 | 40 | def __init__(self, repo, match=None): |
|
41 | 41 | self.repo = repo.unfiltered() |
|
42 | 42 | self.ui = repo.ui |
|
43 | 43 | self.match = match or scmutil.matchall(repo) |
|
44 | 44 | self.badrevs = set() |
|
45 | 45 | self.errors = 0 |
|
46 | 46 | self.warnings = 0 |
|
47 | 47 | self.havecl = len(repo.changelog) > 0 |
|
48 | 48 | self.havemf = len(repo.manifestlog._revlog) > 0 |
|
49 | 49 | self.revlogv1 = repo.changelog.version != revlog.REVLOGV0 |
|
50 | 50 | self.lrugetctx = util.lrucachefunc(repo.changectx) |
|
51 | 51 | self.refersmf = False |
|
52 | 52 | self.fncachewarned = False |
|
53 | 53 | # developer config: verify.skipflags |
|
54 | 54 | self.skipflags = repo.ui.configint('verify', 'skipflags') |
|
55 | 55 | |
|
56 | 56 | def warn(self, msg): |
|
57 | 57 | self.ui.warn(msg + "\n") |
|
58 | 58 | self.warnings += 1 |
|
59 | 59 | |
|
60 | 60 | def err(self, linkrev, msg, filename=None): |
|
61 | 61 | if linkrev is not None: |
|
62 | 62 | self.badrevs.add(linkrev) |
|
63 | 63 | linkrev = "%d" % linkrev |
|
64 | 64 | else: |
|
65 | 65 | linkrev = '?' |
|
66 | 66 | msg = "%s: %s" % (linkrev, msg) |
|
67 | 67 | if filename: |
|
68 | 68 | msg = "%s@%s" % (filename, msg) |
|
69 | 69 | self.ui.warn(" " + msg + "\n") |
|
70 | 70 | self.errors += 1 |
|
71 | 71 | |
|
72 | 72 | def exc(self, linkrev, msg, inst, filename=None): |
|
73 | 73 | if not str(inst): |
|
74 | 74 | inst = repr(inst) |
|
75 | 75 | self.err(linkrev, "%s: %s" % (msg, inst), filename) |
|
76 | 76 | |
|
77 | 77 | def checklog(self, obj, name, linkrev): |
|
78 | 78 | if not len(obj) and (self.havecl or self.havemf): |
|
79 | 79 | self.err(linkrev, _("empty or missing %s") % name) |
|
80 | 80 | return |
|
81 | 81 | |
|
82 | 82 | d = obj.checksize() |
|
83 | 83 | if d[0]: |
|
84 | 84 | self.err(None, _("data length off by %d bytes") % d[0], name) |
|
85 | 85 | if d[1]: |
|
86 | 86 | self.err(None, _("index contains %d extra bytes") % d[1], name) |
|
87 | 87 | |
|
88 | 88 | if obj.version != revlog.REVLOGV0: |
|
89 | 89 | if not self.revlogv1: |
|
90 | 90 | self.warn(_("warning: `%s' uses revlog format 1") % name) |
|
91 | 91 | elif self.revlogv1: |
|
92 | 92 | self.warn(_("warning: `%s' uses revlog format 0") % name) |
|
93 | 93 | |
|
94 | 94 | def checkentry(self, obj, i, node, seen, linkrevs, f): |
|
95 | 95 | lr = obj.linkrev(obj.rev(node)) |
|
96 | 96 | if lr < 0 or (self.havecl and lr not in linkrevs): |
|
97 | 97 | if lr < 0 or lr >= len(self.repo.changelog): |
|
98 | 98 | msg = _("rev %d points to nonexistent changeset %d") |
|
99 | 99 | else: |
|
100 | 100 | msg = _("rev %d points to unexpected changeset %d") |
|
101 | 101 | self.err(None, msg % (i, lr), f) |
|
102 | 102 | if linkrevs: |
|
103 | 103 | if f and len(linkrevs) > 1: |
|
104 | 104 | try: |
|
105 | 105 | # attempt to filter down to real linkrevs |
|
106 | 106 | linkrevs = [l for l in linkrevs |
|
107 | 107 | if self.lrugetctx(l)[f].filenode() == node] |
|
108 | 108 | except Exception: |
|
109 | 109 | pass |
|
110 | 110 | self.warn(_(" (expected %s)") % " ".join |
|
111 | 111 | (map(pycompat.bytestr, linkrevs))) |
|
112 | 112 | lr = None # can't be trusted |
|
113 | 113 | |
|
114 | 114 | try: |
|
115 | 115 | p1, p2 = obj.parents(node) |
|
116 | 116 | if p1 not in seen and p1 != nullid: |
|
117 | 117 | self.err(lr, _("unknown parent 1 %s of %s") % |
|
118 | 118 | (short(p1), short(node)), f) |
|
119 | 119 | if p2 not in seen and p2 != nullid: |
|
120 | 120 | self.err(lr, _("unknown parent 2 %s of %s") % |
|
121 | 121 | (short(p2), short(node)), f) |
|
122 | 122 | except Exception as inst: |
|
123 | 123 | self.exc(lr, _("checking parents of %s") % short(node), inst, f) |
|
124 | 124 | |
|
125 | 125 | if node in seen: |
|
126 | 126 | self.err(lr, _("duplicate revision %d (%d)") % (i, seen[node]), f) |
|
127 | 127 | seen[node] = i |
|
128 | 128 | return lr |
|
129 | 129 | |
|
130 | 130 | def verify(self): |
|
131 | 131 | repo = self.repo |
|
132 | 132 | |
|
133 | 133 | ui = repo.ui |
|
134 | 134 | |
|
135 | 135 | if not repo.url().startswith('file:'): |
|
136 | 136 | raise error.Abort(_("cannot verify bundle or remote repos")) |
|
137 | 137 | |
|
138 | 138 | if os.path.exists(repo.sjoin("journal")): |
|
139 | 139 | ui.warn(_("abandoned transaction found - run hg recover\n")) |
|
140 | 140 | |
|
141 | 141 | if ui.verbose or not self.revlogv1: |
|
142 | 142 | ui.status(_("repository uses revlog format %d\n") % |
|
143 | 143 | (self.revlogv1 and 1 or 0)) |
|
144 | 144 | |
|
145 | 145 | mflinkrevs, filelinkrevs = self._verifychangelog() |
|
146 | 146 | |
|
147 | 147 | filenodes = self._verifymanifest(mflinkrevs) |
|
148 | 148 | del mflinkrevs |
|
149 | 149 | |
|
150 | 150 | self._crosscheckfiles(filelinkrevs, filenodes) |
|
151 | 151 | |
|
152 | 152 | totalfiles, filerevisions = self._verifyfiles(filenodes, filelinkrevs) |
|
153 | 153 | |
|
154 | 154 | ui.status(_("%d files, %d changesets, %d total revisions\n") % |
|
155 | 155 | (totalfiles, len(repo.changelog), filerevisions)) |
|
156 | 156 | if self.warnings: |
|
157 | 157 | ui.warn(_("%d warnings encountered!\n") % self.warnings) |
|
158 | 158 | if self.fncachewarned: |
|
159 | 159 | ui.warn(_('hint: run "hg debugrebuildfncache" to recover from ' |
|
160 | 160 | 'corrupt fncache\n')) |
|
161 | 161 | if self.errors: |
|
162 | 162 | ui.warn(_("%d integrity errors encountered!\n") % self.errors) |
|
163 | 163 | if self.badrevs: |
|
164 | 164 | ui.warn(_("(first damaged changeset appears to be %d)\n") |
|
165 | 165 | % min(self.badrevs)) |
|
166 | 166 | return 1 |
|
167 | 167 | |
|
168 | 168 | def _verifychangelog(self): |
|
169 | 169 | ui = self.ui |
|
170 | 170 | repo = self.repo |
|
171 | 171 | match = self.match |
|
172 | 172 | cl = repo.changelog |
|
173 | 173 | |
|
174 | 174 | ui.status(_("checking changesets\n")) |
|
175 | 175 | mflinkrevs = {} |
|
176 | 176 | filelinkrevs = {} |
|
177 | 177 | seen = {} |
|
178 | 178 | self.checklog(cl, "changelog", 0) |
|
179 | 179 | total = len(repo) |
|
180 | 180 | for i in repo: |
|
181 | 181 | ui.progress(_('checking'), i, total=total, unit=_('changesets')) |
|
182 | 182 | n = cl.node(i) |
|
183 | 183 | self.checkentry(cl, i, n, seen, [i], "changelog") |
|
184 | 184 | |
|
185 | 185 | try: |
|
186 | 186 | changes = cl.read(n) |
|
187 | 187 | if changes[0] != nullid: |
|
188 | 188 | mflinkrevs.setdefault(changes[0], []).append(i) |
|
189 | 189 | self.refersmf = True |
|
190 | 190 | for f in changes[3]: |
|
191 | 191 | if match(f): |
|
192 | 192 | filelinkrevs.setdefault(_normpath(f), []).append(i) |
|
193 | 193 | except Exception as inst: |
|
194 | 194 | self.refersmf = True |
|
195 | 195 | self.exc(i, _("unpacking changeset %s") % short(n), inst) |
|
196 | 196 | ui.progress(_('checking'), None) |
|
197 | 197 | return mflinkrevs, filelinkrevs |
|
198 | 198 | |
|
199 | 199 | def _verifymanifest(self, mflinkrevs, dir="", storefiles=None, |
|
200 | 200 | progress=None): |
|
201 | 201 | repo = self.repo |
|
202 | 202 | ui = self.ui |
|
203 | 203 | match = self.match |
|
204 | 204 | mfl = self.repo.manifestlog |
|
205 | 205 | mf = mfl._revlog.dirlog(dir) |
|
206 | 206 | |
|
207 | 207 | if not dir: |
|
208 | 208 | self.ui.status(_("checking manifests\n")) |
|
209 | 209 | |
|
210 | 210 | filenodes = {} |
|
211 | 211 | subdirnodes = {} |
|
212 | 212 | seen = {} |
|
213 | 213 | label = "manifest" |
|
214 | 214 | if dir: |
|
215 | 215 | label = dir |
|
216 | 216 | revlogfiles = mf.files() |
|
217 | 217 | storefiles.difference_update(revlogfiles) |
|
218 | 218 | if progress: # should be true since we're in a subdirectory |
|
219 | 219 | progress() |
|
220 | 220 | if self.refersmf: |
|
221 | 221 | # Do not check manifest if there are only changelog entries with |
|
222 | 222 | # null manifests. |
|
223 | 223 | self.checklog(mf, label, 0) |
|
224 | 224 | total = len(mf) |
|
225 | 225 | for i in mf: |
|
226 | 226 | if not dir: |
|
227 | 227 | ui.progress(_('checking'), i, total=total, unit=_('manifests')) |
|
228 | 228 | n = mf.node(i) |
|
229 | 229 | lr = self.checkentry(mf, i, n, seen, mflinkrevs.get(n, []), label) |
|
230 | 230 | if n in mflinkrevs: |
|
231 | 231 | del mflinkrevs[n] |
|
232 | 232 | elif dir: |
|
233 | 233 | self.err(lr, _("%s not in parent-directory manifest") % |
|
234 | 234 | short(n), label) |
|
235 | 235 | else: |
|
236 | 236 | self.err(lr, _("%s not in changesets") % short(n), label) |
|
237 | 237 | |
|
238 | 238 | try: |
|
239 | 239 | mfdelta = mfl.get(dir, n).readdelta(shallow=True) |
|
240 | 240 | for f, fn, fl in mfdelta.iterentries(): |
|
241 | 241 | if not f: |
|
242 | 242 | self.err(lr, _("entry without name in manifest")) |
|
243 | 243 | elif f == "/dev/null": # ignore this in very old repos |
|
244 | 244 | continue |
|
245 | 245 | fullpath = dir + _normpath(f) |
|
246 | 246 | if fl == 't': |
|
247 | 247 | if not match.visitdir(fullpath): |
|
248 | 248 | continue |
|
249 | 249 | subdirnodes.setdefault(fullpath + '/', {}).setdefault( |
|
250 | 250 | fn, []).append(lr) |
|
251 | 251 | else: |
|
252 | 252 | if not match(fullpath): |
|
253 | 253 | continue |
|
254 | 254 | filenodes.setdefault(fullpath, {}).setdefault(fn, lr) |
|
255 | 255 | except Exception as inst: |
|
256 | 256 | self.exc(lr, _("reading delta %s") % short(n), inst, label) |
|
257 | 257 | if not dir: |
|
258 | 258 | ui.progress(_('checking'), None) |
|
259 | 259 | |
|
260 | 260 | if self.havemf: |
|
261 | 261 | for c, m in sorted([(c, m) for m in mflinkrevs |
|
262 | 262 | for c in mflinkrevs[m]]): |
|
263 | 263 | if dir: |
|
264 | 264 | self.err(c, _("parent-directory manifest refers to unknown " |
|
265 | 265 | "revision %s") % short(m), label) |
|
266 | 266 | else: |
|
267 | 267 | self.err(c, _("changeset refers to unknown revision %s") % |
|
268 | 268 | short(m), label) |
|
269 | 269 | |
|
270 | 270 | if not dir and subdirnodes: |
|
271 | 271 | self.ui.status(_("checking directory manifests\n")) |
|
272 | 272 | storefiles = set() |
|
273 | 273 | subdirs = set() |
|
274 | 274 | revlogv1 = self.revlogv1 |
|
275 | 275 | for f, f2, size in repo.store.datafiles(): |
|
276 | 276 | if not f: |
|
277 | 277 | self.err(None, _("cannot decode filename '%s'") % f2) |
|
278 | 278 | elif (size > 0 or not revlogv1) and f.startswith('meta/'): |
|
279 | 279 | storefiles.add(_normpath(f)) |
|
280 | 280 | subdirs.add(os.path.dirname(f)) |
|
281 | 281 | subdircount = len(subdirs) |
|
282 | 282 | currentsubdir = [0] |
|
283 | 283 | def progress(): |
|
284 | 284 | currentsubdir[0] += 1 |
|
285 | 285 | ui.progress(_('checking'), currentsubdir[0], total=subdircount, |
|
286 | 286 | unit=_('manifests')) |
|
287 | 287 | |
|
288 | 288 | for subdir, linkrevs in subdirnodes.iteritems(): |
|
289 | 289 | subdirfilenodes = self._verifymanifest(linkrevs, subdir, storefiles, |
|
290 | 290 | progress) |
|
291 | 291 | for f, onefilenodes in subdirfilenodes.iteritems(): |
|
292 | 292 | filenodes.setdefault(f, {}).update(onefilenodes) |
|
293 | 293 | |
|
294 | 294 | if not dir and subdirnodes: |
|
295 | 295 | ui.progress(_('checking'), None) |
|
296 | 296 | for f in sorted(storefiles): |
|
297 | 297 | self.warn(_("warning: orphan revlog '%s'") % f) |
|
298 | 298 | |
|
299 | 299 | return filenodes |
|
300 | 300 | |
|
301 | 301 | def _crosscheckfiles(self, filelinkrevs, filenodes): |
|
302 | 302 | repo = self.repo |
|
303 | 303 | ui = self.ui |
|
304 | 304 | ui.status(_("crosschecking files in changesets and manifests\n")) |
|
305 | 305 | |
|
306 | 306 | total = len(filelinkrevs) + len(filenodes) |
|
307 | 307 | count = 0 |
|
308 | 308 | if self.havemf: |
|
309 | 309 | for f in sorted(filelinkrevs): |
|
310 | 310 | count += 1 |
|
311 | 311 | ui.progress(_('crosschecking'), count, total=total) |
|
312 | 312 | if f not in filenodes: |
|
313 | 313 | lr = filelinkrevs[f][0] |
|
314 | 314 | self.err(lr, _("in changeset but not in manifest"), f) |
|
315 | 315 | |
|
316 | 316 | if self.havecl: |
|
317 | 317 | for f in sorted(filenodes): |
|
318 | 318 | count += 1 |
|
319 | 319 | ui.progress(_('crosschecking'), count, total=total) |
|
320 | 320 | if f not in filelinkrevs: |
|
321 | 321 | try: |
|
322 | 322 | fl = repo.file(f) |
|
323 | 323 | lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]]) |
|
324 | 324 | except Exception: |
|
325 | 325 | lr = None |
|
326 | 326 | self.err(lr, _("in manifest but not in changeset"), f) |
|
327 | 327 | |
|
328 | 328 | ui.progress(_('crosschecking'), None) |
|
329 | 329 | |
|
330 | 330 | def _verifyfiles(self, filenodes, filelinkrevs): |
|
331 | 331 | repo = self.repo |
|
332 | 332 | ui = self.ui |
|
333 | 333 | lrugetctx = self.lrugetctx |
|
334 | 334 | revlogv1 = self.revlogv1 |
|
335 | 335 | havemf = self.havemf |
|
336 | 336 | ui.status(_("checking files\n")) |
|
337 | 337 | |
|
338 | 338 | storefiles = set() |
|
339 | 339 | for f, f2, size in repo.store.datafiles(): |
|
340 | 340 | if not f: |
|
341 | 341 | self.err(None, _("cannot decode filename '%s'") % f2) |
|
342 | 342 | elif (size > 0 or not revlogv1) and f.startswith('data/'): |
|
343 | 343 | storefiles.add(_normpath(f)) |
|
344 | 344 | |
|
345 | 345 | files = sorted(set(filenodes) | set(filelinkrevs)) |
|
346 | 346 | total = len(files) |
|
347 | 347 | revisions = 0 |
|
348 | 348 | for i, f in enumerate(files): |
|
349 | 349 | ui.progress(_('checking'), i, item=f, total=total, unit=_('files')) |
|
350 | 350 | try: |
|
351 | 351 | linkrevs = filelinkrevs[f] |
|
352 | 352 | except KeyError: |
|
353 | 353 | # in manifest but not in changelog |
|
354 | 354 | linkrevs = [] |
|
355 | 355 | |
|
356 | 356 | if linkrevs: |
|
357 | 357 | lr = linkrevs[0] |
|
358 | 358 | else: |
|
359 | 359 | lr = None |
|
360 | 360 | |
|
361 | 361 | try: |
|
362 | 362 | fl = repo.file(f) |
|
363 | 363 | except error.RevlogError as e: |
|
364 | 364 | self.err(lr, _("broken revlog! (%s)") % e, f) |
|
365 | 365 | continue |
|
366 | 366 | |
|
367 | 367 | for ff in fl.files(): |
|
368 | 368 | try: |
|
369 | 369 | storefiles.remove(ff) |
|
370 | 370 | except KeyError: |
|
371 | 371 | self.warn(_(" warning: revlog '%s' not in fncache!") % ff) |
|
372 | 372 | self.fncachewarned = True |
|
373 | 373 | |
|
374 | 374 | self.checklog(fl, f, lr) |
|
375 | 375 | seen = {} |
|
376 | 376 | rp = None |
|
377 | 377 | for i in fl: |
|
378 | 378 | revisions += 1 |
|
379 | 379 | n = fl.node(i) |
|
380 | 380 | lr = self.checkentry(fl, i, n, seen, linkrevs, f) |
|
381 | 381 | if f in filenodes: |
|
382 | 382 | if havemf and n not in filenodes[f]: |
|
383 | 383 | self.err(lr, _("%s not in manifests") % (short(n)), f) |
|
384 | 384 | else: |
|
385 | 385 | del filenodes[f][n] |
|
386 | 386 | |
|
387 | 387 | # Verify contents. 4 cases to care about: |
|
388 | 388 | # |
|
389 | 389 | # common: the most common case |
|
390 | 390 | # rename: with a rename |
|
391 | 391 | # meta: file content starts with b'\1\n', the metadata |
|
392 | 392 | # header defined in filelog.py, but without a rename |
|
393 | 393 | # ext: content stored externally |
|
394 | 394 | # |
|
395 | 395 | # More formally, their differences are shown below: |
|
396 | 396 | # |
|
397 | 397 | # | common | rename | meta | ext |
|
398 | 398 | # ------------------------------------------------------- |
|
399 | 399 | # flags() | 0 | 0 | 0 | not 0 |
|
400 | 400 | # renamed() | False | True | False | ? |
|
401 | 401 | # rawtext[0:2]=='\1\n'| False | True | True | ? |
|
402 | 402 | # |
|
403 | 403 | # "rawtext" means the raw text stored in revlog data, which |
|
404 | 404 | # could be retrieved by "revision(rev, raw=True)". "text" |
|
405 | 405 | # mentioned below is "revision(rev, raw=False)". |
|
406 | 406 | # |
|
407 | 407 | # There are 3 different lengths stored physically: |
|
408 | 408 | # 1. L1: rawsize, stored in revlog index |
|
409 | 409 | # 2. L2: len(rawtext), stored in revlog data |
|
410 | 410 | # 3. L3: len(text), stored in revlog data if flags==0, or |
|
411 | 411 | # possibly somewhere else if flags!=0 |
|
412 | 412 | # |
|
413 | 413 | # L1 should be equal to L2. L3 could be different from them. |
|
414 | 414 | # "text" may or may not affect commit hash depending on flag |
|
415 | 415 | # processors (see revlog.addflagprocessor). |
|
416 | 416 | # |
|
417 | 417 | # | common | rename | meta | ext |
|
418 | 418 | # ------------------------------------------------- |
|
419 | 419 | # rawsize() | L1 | L1 | L1 | L1 |
|
420 | 420 | # size() | L1 | L2-LM | L1(*) | L1 (?) |
|
421 | 421 | # len(rawtext) | L2 | L2 | L2 | L2 |
|
422 | 422 | # len(text) | L2 | L2 | L2 | L3 |
|
423 | 423 | # len(read()) | L2 | L2-LM | L2-LM | L3 (?) |
|
424 | 424 | # |
|
425 | 425 | # LM: length of metadata, depending on rawtext |
|
426 | 426 | # (*): not ideal, see comment in filelog.size |
|
427 | 427 | # (?): could be "- len(meta)" if the resolved content has |
|
428 | 428 | # rename metadata |
|
429 | 429 | # |
|
430 | 430 | # Checks needed to be done: |
|
431 | 431 | # 1. length check: L1 == L2, in all cases. |
|
432 | 432 | # 2. hash check: depending on flag processor, we may need to |
|
433 | 433 | # use either "text" (external), or "rawtext" (in revlog). |
|
434 | 434 | try: |
|
435 | 435 | skipflags = self.skipflags |
|
436 | 436 | if skipflags: |
|
437 | 437 | skipflags &= fl.flags(i) |
|
438 | 438 | if not skipflags: |
|
439 | 439 | fl.read(n) # side effect: read content and do checkhash |
|
440 | 440 | rp = fl.renamed(n) |
|
441 | 441 | # the "L1 == L2" check |
|
442 | 442 | l1 = fl.rawsize(i) |
|
443 | 443 | l2 = len(fl.revision(n, raw=True)) |
|
444 | 444 | if l1 != l2: |
|
445 | 445 | self.err(lr, _("unpacked size is %s, %s expected") % |
|
446 | 446 | (l2, l1), f) |
|
447 | 447 | except error.CensoredNodeError: |
|
448 | 448 | # experimental config: censor.policy |
|
449 | 449 | if ui.config("censor", "policy") == "abort": |
|
450 | 450 | self.err(lr, _("censored file data"), f) |
|
451 | 451 | except Exception as inst: |
|
452 | 452 | self.exc(lr, _("unpacking %s") % short(n), inst, f) |
|
453 | 453 | |
|
454 | 454 | # check renames |
|
455 | 455 | try: |
|
456 | 456 | if rp: |
|
457 | 457 | if lr is not None and ui.verbose: |
|
458 | 458 | ctx = lrugetctx(lr) |
|
459 | found = False | |
|
460 | for pctx in ctx.parents(): | |
|
461 | if rp[0] in pctx: | |
|
462 | found = True | |
|
463 | break | |
|
464 | if not found: | |
|
459 | if not any(rp[0] in pctx for pctx in ctx.parents()): | |
|
465 | 460 | self.warn(_("warning: copy source of '%s' not" |
|
466 | 461 | " in parents of %s") % (f, ctx)) |
|
467 | 462 | fl2 = repo.file(rp[0]) |
|
468 | 463 | if not len(fl2): |
|
469 | 464 | self.err(lr, _("empty or missing copy source " |
|
470 | 465 | "revlog %s:%s") % (rp[0], short(rp[1])), f) |
|
471 | 466 | elif rp[1] == nullid: |
|
472 | 467 | ui.note(_("warning: %s@%s: copy source" |
|
473 | 468 | " revision is nullid %s:%s\n") |
|
474 | 469 | % (f, lr, rp[0], short(rp[1]))) |
|
475 | 470 | else: |
|
476 | 471 | fl2.rev(rp[1]) |
|
477 | 472 | except Exception as inst: |
|
478 | 473 | self.exc(lr, _("checking rename of %s") % short(n), inst, f) |
|
479 | 474 | |
|
480 | 475 | # cross-check |
|
481 | 476 | if f in filenodes: |
|
482 | 477 | fns = [(v, k) for k, v in filenodes[f].iteritems()] |
|
483 | 478 | for lr, node in sorted(fns): |
|
484 | 479 | self.err(lr, _("manifest refers to unknown revision %s") % |
|
485 | 480 | short(node), f) |
|
486 | 481 | ui.progress(_('checking'), None) |
|
487 | 482 | |
|
488 | 483 | for f in sorted(storefiles): |
|
489 | 484 | self.warn(_("warning: orphan revlog '%s'") % f) |
|
490 | 485 | |
|
491 | 486 | return len(files), revisions |
General Comments 0
You need to be logged in to leave comments.
Login now