comparison mercurial/verify.py @ 25660:328739ea70c3

global: mass rewrite to use modern exception syntax Python 2.6 introduced the "except type as instance" syntax, replacing the "except type, instance" syntax that came before. Python 3 dropped support for the latter syntax. Since we no longer support Python 2.4 or 2.5, we have no need to continue supporting the "except type, instance". This patch mass rewrites the exception syntax to be Python 2.6+ and Python 3 compatible. This patch was produced by running `2to3 -f except -w -n .`.
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 23 Jun 2015 22:20:08 -0700
parents 9d1e04f5dca7
children c55eac3f388d
comparison
equal deleted inserted replaced
25659:d60678a567a9 25660:328739ea70c3
106 err(lr, _("unknown parent 1 %s of %s") % 106 err(lr, _("unknown parent 1 %s of %s") %
107 (short(p1), short(node)), f) 107 (short(p1), short(node)), f)
108 if p2 not in seen and p2 != nullid: 108 if p2 not in seen and p2 != nullid:
109 err(lr, _("unknown parent 2 %s of %s") % 109 err(lr, _("unknown parent 2 %s of %s") %
110 (short(p2), short(node)), f) 110 (short(p2), short(node)), f)
111 except Exception, inst: 111 except Exception as inst:
112 exc(lr, _("checking parents of %s") % short(node), inst, f) 112 exc(lr, _("checking parents of %s") % short(node), inst, f)
113 113
114 if node in seen: 114 if node in seen:
115 err(lr, _("duplicate revision %d (%d)") % (i, seen[node]), f) 115 err(lr, _("duplicate revision %d (%d)") % (i, seen[node]), f)
116 seen[node] = i 116 seen[node] = i
142 if changes[0] != nullid: 142 if changes[0] != nullid:
143 mflinkrevs.setdefault(changes[0], []).append(i) 143 mflinkrevs.setdefault(changes[0], []).append(i)
144 refersmf = True 144 refersmf = True
145 for f in changes[3]: 145 for f in changes[3]:
146 filelinkrevs.setdefault(_normpath(f), []).append(i) 146 filelinkrevs.setdefault(_normpath(f), []).append(i)
147 except Exception, inst: 147 except Exception as inst:
148 refersmf = True 148 refersmf = True
149 exc(i, _("unpacking changeset %s") % short(n), inst) 149 exc(i, _("unpacking changeset %s") % short(n), inst)
150 ui.progress(_('checking'), None) 150 ui.progress(_('checking'), None)
151 151
152 ui.status(_("checking manifests\n")) 152 ui.status(_("checking manifests\n"))
169 for f, fn in mf.readdelta(n).iteritems(): 169 for f, fn in mf.readdelta(n).iteritems():
170 if not f: 170 if not f:
171 err(lr, _("file without name in manifest")) 171 err(lr, _("file without name in manifest"))
172 elif f != "/dev/null": # ignore this in very old repos 172 elif f != "/dev/null": # ignore this in very old repos
173 filenodes.setdefault(_normpath(f), {}).setdefault(fn, lr) 173 filenodes.setdefault(_normpath(f), {}).setdefault(fn, lr)
174 except Exception, inst: 174 except Exception as inst:
175 exc(lr, _("reading manifest delta %s") % short(n), inst) 175 exc(lr, _("reading manifest delta %s") % short(n), inst)
176 ui.progress(_('checking'), None) 176 ui.progress(_('checking'), None)
177 177
178 ui.status(_("crosschecking files in changesets and manifests\n")) 178 ui.status(_("crosschecking files in changesets and manifests\n"))
179 179
235 else: 235 else:
236 lr = None 236 lr = None
237 237
238 try: 238 try:
239 fl = repo.file(f) 239 fl = repo.file(f)
240 except error.RevlogError, e: 240 except error.RevlogError as e:
241 err(lr, _("broken revlog! (%s)") % e, f) 241 err(lr, _("broken revlog! (%s)") % e, f)
242 continue 242 continue
243 243
244 for ff in fl.files(): 244 for ff in fl.files():
245 try: 245 try:
270 err(lr, _("unpacked size is %s, %s expected") % 270 err(lr, _("unpacked size is %s, %s expected") %
271 (l, fl.size(i)), f) 271 (l, fl.size(i)), f)
272 except error.CensoredNodeError: 272 except error.CensoredNodeError:
273 if ui.config("censor", "policy", "abort") == "abort": 273 if ui.config("censor", "policy", "abort") == "abort":
274 err(lr, _("censored file data"), f) 274 err(lr, _("censored file data"), f)
275 except Exception, inst: 275 except Exception as inst:
276 exc(lr, _("unpacking %s") % short(n), inst, f) 276 exc(lr, _("unpacking %s") % short(n), inst, f)
277 277
278 # check renames 278 # check renames
279 try: 279 try:
280 if rp: 280 if rp:
296 ui.note(_("warning: %s@%s: copy source" 296 ui.note(_("warning: %s@%s: copy source"
297 " revision is nullid %s:%s\n") 297 " revision is nullid %s:%s\n")
298 % (f, lr, rp[0], short(rp[1]))) 298 % (f, lr, rp[0], short(rp[1])))
299 else: 299 else:
300 fl2.rev(rp[1]) 300 fl2.rev(rp[1])
301 except Exception, inst: 301 except Exception as inst:
302 exc(lr, _("checking rename of %s") % short(n), inst, f) 302 exc(lr, _("checking rename of %s") % short(n), inst, f)
303 303
304 # cross-check 304 # cross-check
305 if f in filenodes: 305 if f in filenodes:
306 fns = [(lr, n) for n, lr in filenodes[f].iteritems()] 306 fns = [(lr, n) for n, lr in filenodes[f].iteritems()]