##// END OF EJS Templates
verify: move err() to be a class function...
Durham Goode -
r27447:d1b91c10 default
parent child Browse files
Show More
@@ -64,6 +64,17 b' class verifier(object):'
64 64 self.ui.warn(msg + "\n")
65 65 self.warnings[0] += 1
66 66
67 def err(self, linkrev, msg, filename=None):
68 if linkrev is not None:
69 self.badrevs.add(linkrev)
70 else:
71 linkrev = '?'
72 msg = "%s: %s" % (linkrev, msg)
73 if filename:
74 msg = "%s@%s" % (filename, msg)
75 self.ui.warn(" " + msg + "\n")
76 self.errors[0] += 1
77
67 78 def verify(self):
68 79 repo = self.repo
69 80 mflinkrevs = {}
@@ -81,16 +92,6 b' class verifier(object):'
81 92 if not repo.url().startswith('file:'):
82 93 raise error.Abort(_("cannot verify bundle or remote repos"))
83 94
84 def err(linkrev, msg, filename=None):
85 if linkrev is not None:
86 badrevs.add(linkrev)
87 else:
88 linkrev = '?'
89 msg = "%s: %s" % (linkrev, msg)
90 if filename:
91 msg = "%s@%s" % (filename, msg)
92 ui.warn(" " + msg + "\n")
93 errors[0] += 1
94 95
95 96 def exc(linkrev, msg, inst, filename=None):
96 97 if isinstance(inst, KeyboardInterrupt):
@@ -98,19 +99,19 b' class verifier(object):'
98 99 raise
99 100 if not str(inst):
100 101 inst = repr(inst)
101 err(linkrev, "%s: %s" % (msg, inst), filename)
102 self.err(linkrev, "%s: %s" % (msg, inst), filename)
102 103
103 104
104 105 def checklog(obj, name, linkrev):
105 106 if not len(obj) and (havecl or havemf):
106 err(linkrev, _("empty or missing %s") % name)
107 self.err(linkrev, _("empty or missing %s") % name)
107 108 return
108 109
109 110 d = obj.checksize()
110 111 if d[0]:
111 err(None, _("data length off by %d bytes") % d[0], name)
112 self.err(None, _("data length off by %d bytes") % d[0], name)
112 113 if d[1]:
113 err(None, _("index contains %d extra bytes") % d[1], name)
114 self.err(None, _("index contains %d extra bytes") % d[1], name)
114 115
115 116 if obj.version != revlog.REVLOGV0:
116 117 if not revlogv1:
@@ -125,7 +126,7 b' class verifier(object):'
125 126 msg = _("rev %d points to nonexistent changeset %d")
126 127 else:
127 128 msg = _("rev %d points to unexpected changeset %d")
128 err(None, msg % (i, lr), f)
129 self.err(None, msg % (i, lr), f)
129 130 if linkrevs:
130 131 if f and len(linkrevs) > 1:
131 132 try:
@@ -141,16 +142,17 b' class verifier(object):'
141 142 try:
142 143 p1, p2 = obj.parents(node)
143 144 if p1 not in seen and p1 != nullid:
144 err(lr, _("unknown parent 1 %s of %s") %
145 (short(p1), short(node)), f)
145 self.err(lr, _("unknown parent 1 %s of %s") %
146 (short(p1), short(node)), f)
146 147 if p2 not in seen and p2 != nullid:
147 err(lr, _("unknown parent 2 %s of %s") %
148 (short(p2), short(node)), f)
148 self.err(lr, _("unknown parent 2 %s of %s") %
149 (short(p2), short(node)), f)
149 150 except Exception as inst:
150 151 exc(lr, _("checking parents of %s") % short(node), inst, f)
151 152
152 153 if node in seen:
153 err(lr, _("duplicate revision %d (%d)") % (i, seen[node]), f)
154 self.err(lr, _("duplicate revision %d (%d)") %
155 (i, seen[node]), f)
154 156 seen[node] = i
155 157 return lr
156 158
@@ -201,12 +203,12 b' class verifier(object):'
201 203 if n in mflinkrevs:
202 204 del mflinkrevs[n]
203 205 else:
204 err(lr, _("%s not in changesets") % short(n), "manifest")
206 self.err(lr, _("%s not in changesets") % short(n), "manifest")
205 207
206 208 try:
207 209 for f, fn in mf.readdelta(n).iteritems():
208 210 if not f:
209 err(lr, _("file without name in manifest"))
211 self.err(lr, _("file without name in manifest"))
210 212 elif f != "/dev/null": # ignore this in very old repos
211 213 if _validpath(repo, f):
212 214 filenodes.setdefault(
@@ -226,7 +228,8 b' class verifier(object):'
226 228 if m == nullid:
227 229 continue
228 230 ui.progress(_('crosschecking'), count, total=total)
229 err(c, _("changeset refers to unknown manifest %s") % short(m))
231 self.err(c, _("changeset refers to unknown manifest %s") %
232 short(m))
230 233 mflinkrevs = None # del is bad here due to scope issues
231 234
232 235 for f in sorted(filelinkrevs):
@@ -234,7 +237,7 b' class verifier(object):'
234 237 ui.progress(_('crosschecking'), count, total=total)
235 238 if f not in filenodes:
236 239 lr = filelinkrevs[f][0]
237 err(lr, _("in changeset but not in manifest"), f)
240 self.err(lr, _("in changeset but not in manifest"), f)
238 241
239 242 if havecl:
240 243 for f in sorted(filenodes):
@@ -246,7 +249,7 b' class verifier(object):'
246 249 lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]])
247 250 except Exception:
248 251 lr = None
249 err(lr, _("in manifest but not in changeset"), f)
252 self.err(lr, _("in manifest but not in changeset"), f)
250 253
251 254 ui.progress(_('crosschecking'), None)
252 255
@@ -255,7 +258,7 b' class verifier(object):'
255 258 storefiles = set()
256 259 for f, f2, size in repo.store.datafiles():
257 260 if not f:
258 err(None, _("cannot decode filename '%s'") % f2)
261 self.err(None, _("cannot decode filename '%s'") % f2)
259 262 elif size > 0 or not revlogv1:
260 263 storefiles.add(_normpath(f))
261 264
@@ -277,7 +280,7 b' class verifier(object):'
277 280 try:
278 281 fl = repo.file(f)
279 282 except error.RevlogError as e:
280 err(lr, _("broken revlog! (%s)") % e, f)
283 self.err(lr, _("broken revlog! (%s)") % e, f)
281 284 continue
282 285
283 286 for ff in fl.files():
@@ -296,7 +299,7 b' class verifier(object):'
296 299 lr = checkentry(fl, i, n, seen, linkrevs, f)
297 300 if f in filenodes:
298 301 if havemf and n not in filenodes[f]:
299 err(lr, _("%s not in manifests") % (short(n)), f)
302 self.err(lr, _("%s not in manifests") % (short(n)), f)
300 303 else:
301 304 del filenodes[f][n]
302 305
@@ -306,12 +309,12 b' class verifier(object):'
306 309 rp = fl.renamed(n)
307 310 if l != fl.size(i):
308 311 if len(fl.revision(n)) != fl.size(i):
309 err(lr, _("unpacked size is %s, %s expected") %
310 (l, fl.size(i)), f)
312 self.err(lr, _("unpacked size is %s, %s expected") %
313 (l, fl.size(i)), f)
311 314 except error.CensoredNodeError:
312 315 # experimental config: censor.policy
313 316 if ui.config("censor", "policy", "abort") == "abort":
314 err(lr, _("censored file data"), f)
317 self.err(lr, _("censored file data"), f)
315 318 except Exception as inst:
316 319 exc(lr, _("unpacking %s") % short(n), inst, f)
317 320
@@ -330,8 +333,8 b' class verifier(object):'
330 333 " in parents of %s") % (f, ctx))
331 334 fl2 = repo.file(rp[0])
332 335 if not len(fl2):
333 err(lr, _("empty or missing copy source revlog "
334 "%s:%s") % (rp[0], short(rp[1])), f)
336 self.err(lr, _("empty or missing copy source "
337 "revlog %s:%s") % (rp[0], short(rp[1])), f)
335 338 elif rp[1] == nullid:
336 339 ui.note(_("warning: %s@%s: copy source"
337 340 " revision is nullid %s:%s\n")
@@ -345,7 +348,8 b' class verifier(object):'
345 348 if f in filenodes:
346 349 fns = [(lr, n) for n, lr in filenodes[f].iteritems()]
347 350 for lr, node in sorted(fns):
348 err(lr, _("%s in manifests not found") % short(node), f)
351 self.err(lr, _("%s in manifests not found") % short(node),
352 f)
349 353 ui.progress(_('checking'), None)
350 354
351 355 for f in storefiles:
General Comments 0
You need to be logged in to leave comments. Login now