Show More
@@ -455,7 +455,7 b' def checkfile(f, logfunc=_defaultlogger.' | |||||
455 |
|
455 | |||
456 | try: |
|
456 | try: | |
457 | fp = open(f) |
|
457 | fp = open(f) | |
458 |
except IOError |
|
458 | except IOError as e: | |
459 | print "Skipping %s, %s" % (f, str(e).split(':', 1)[0]) |
|
459 | print "Skipping %s, %s" % (f, str(e).split(':', 1)[0]) | |
460 | return result |
|
460 | return result | |
461 | pre = post = fp.read() |
|
461 | pre = post = fp.read() |
@@ -328,7 +328,7 b' def find_cycles(imports):' | |||||
328 | for mod in sorted(imports.iterkeys()): |
|
328 | for mod in sorted(imports.iterkeys()): | |
329 | try: |
|
329 | try: | |
330 | checkmod(mod, imports) |
|
330 | checkmod(mod, imports) | |
331 |
except CircularImport |
|
331 | except CircularImport as e: | |
332 | cycle = e.args[0] |
|
332 | cycle = e.args[0] | |
333 | cycles.add(" -> ".join(rotatecycle(cycle))) |
|
333 | cycles.add(" -> ".join(rotatecycle(cycle))) | |
334 | return cycles |
|
334 | return cycles |
@@ -33,7 +33,7 b' def update(rev):' | |||||
33 | """update the repo to a revision""" |
|
33 | """update the repo to a revision""" | |
34 | try: |
|
34 | try: | |
35 | check_call(['hg', 'update', '--quiet', '--check', str(rev)]) |
|
35 | check_call(['hg', 'update', '--quiet', '--check', str(rev)]) | |
36 |
except CalledProcessError |
|
36 | except CalledProcessError as exc: | |
37 | print >> sys.stderr, 'update to revision %s failed, aborting' % rev |
|
37 | print >> sys.stderr, 'update to revision %s failed, aborting' % rev | |
38 | sys.exit(exc.returncode) |
|
38 | sys.exit(exc.returncode) | |
39 |
|
39 | |||
@@ -56,7 +56,7 b' def perf(revset, target=None):' | |||||
56 | try: |
|
56 | try: | |
57 | output = hg(['perfrevset', revset], repo=target) |
|
57 | output = hg(['perfrevset', revset], repo=target) | |
58 | return parseoutput(output) |
|
58 | return parseoutput(output) | |
59 |
except CalledProcessError |
|
59 | except CalledProcessError as exc: | |
60 | print >> sys.stderr, 'abort: cannot run revset benchmark: %s' % exc.cmd |
|
60 | print >> sys.stderr, 'abort: cannot run revset benchmark: %s' % exc.cmd | |
61 | if exc.output is None: |
|
61 | if exc.output is None: | |
62 | print >> sys.stderr, '(no ouput)' |
|
62 | print >> sys.stderr, '(no ouput)' | |
@@ -201,7 +201,7 b' def getrevs(spec):' | |||||
201 | """get the list of rev matched by a revset""" |
|
201 | """get the list of rev matched by a revset""" | |
202 | try: |
|
202 | try: | |
203 | out = check_output(['hg', 'log', '--template={rev}\n', '--rev', spec]) |
|
203 | out = check_output(['hg', 'log', '--template={rev}\n', '--rev', spec]) | |
204 |
except CalledProcessError |
|
204 | except CalledProcessError as exc: | |
205 | print >> sys.stderr, "abort, can't get revision from %s" % spec |
|
205 | print >> sys.stderr, "abort, can't get revision from %s" % spec | |
206 | sys.exit(exc.returncode) |
|
206 | sys.exit(exc.returncode) | |
207 | return [r for r in out.split() if r] |
|
207 | return [r for r in out.split() if r] |
@@ -253,7 +253,7 b' def synthesize(ui, repo, descpath, **opt' | |||||
253 | ''' |
|
253 | ''' | |
254 | try: |
|
254 | try: | |
255 | fp = hg.openpath(ui, descpath) |
|
255 | fp = hg.openpath(ui, descpath) | |
256 |
except Exception |
|
256 | except Exception as err: | |
257 | raise util.Abort('%s: %s' % (descpath, err[0].strerror)) |
|
257 | raise util.Abort('%s: %s' % (descpath, err[0].strerror)) | |
258 | desc = json.load(fp) |
|
258 | desc = json.load(fp) | |
259 | fp.close() |
|
259 | fp.close() | |
@@ -285,7 +285,7 b' def synthesize(ui, repo, descpath, **opt' | |||||
285 | dictfile = opts.get('dict') or '/usr/share/dict/words' |
|
285 | dictfile = opts.get('dict') or '/usr/share/dict/words' | |
286 | try: |
|
286 | try: | |
287 | fp = open(dictfile, 'rU') |
|
287 | fp = open(dictfile, 'rU') | |
288 |
except IOError |
|
288 | except IOError as err: | |
289 | raise util.Abort('%s: %s' % (dictfile, err.strerror)) |
|
289 | raise util.Abort('%s: %s' % (dictfile, err.strerror)) | |
290 | words = fp.read().splitlines() |
|
290 | words = fp.read().splitlines() | |
291 | fp.close() |
|
291 | fp.close() |
@@ -52,14 +52,14 b' def wrapui(ui):' | |||||
52 | def rotate(oldpath, newpath): |
|
52 | def rotate(oldpath, newpath): | |
53 | try: |
|
53 | try: | |
54 | os.unlink(newpath) |
|
54 | os.unlink(newpath) | |
55 |
except OSError |
|
55 | except OSError as err: | |
56 | if err.errno != errno.ENOENT: |
|
56 | if err.errno != errno.ENOENT: | |
57 | self.debug("warning: cannot remove '%s': %s\n" % |
|
57 | self.debug("warning: cannot remove '%s': %s\n" % | |
58 | (newpath, err.strerror)) |
|
58 | (newpath, err.strerror)) | |
59 | try: |
|
59 | try: | |
60 | if newpath: |
|
60 | if newpath: | |
61 | os.rename(oldpath, newpath) |
|
61 | os.rename(oldpath, newpath) | |
62 |
except OSError |
|
62 | except OSError as err: | |
63 | if err.errno != errno.ENOENT: |
|
63 | if err.errno != errno.ENOENT: | |
64 | self.debug("warning: cannot rename '%s' to '%s': %s\n" % |
|
64 | self.debug("warning: cannot rename '%s' to '%s': %s\n" % | |
65 | (newpath, oldpath, err.strerror)) |
|
65 | (newpath, oldpath, err.strerror)) | |
@@ -92,7 +92,7 b' def wrapui(ui):' | |||||
92 | elif util.safehasattr(self, '_bbopener'): |
|
92 | elif util.safehasattr(self, '_bbopener'): | |
93 | try: |
|
93 | try: | |
94 | self._blackbox = self._openlogfile() |
|
94 | self._blackbox = self._openlogfile() | |
95 |
except (IOError, OSError) |
|
95 | except (IOError, OSError) as err: | |
96 | self.debug('warning: cannot write to blackbox.log: %s\n' % |
|
96 | self.debug('warning: cannot write to blackbox.log: %s\n' % | |
97 | err.strerror) |
|
97 | err.strerror) | |
98 | del self._bbopener |
|
98 | del self._bbopener | |
@@ -110,7 +110,7 b' def wrapui(ui):' | |||||
110 | formattedmsg = msg[0] % msg[1:] |
|
110 | formattedmsg = msg[0] % msg[1:] | |
111 | try: |
|
111 | try: | |
112 | blackbox.write('%s %s> %s' % (date, user, formattedmsg)) |
|
112 | blackbox.write('%s %s> %s' % (date, user, formattedmsg)) | |
113 |
except IOError |
|
113 | except IOError as err: | |
114 | self.debug('warning: cannot write to blackbox.log: %s\n' % |
|
114 | self.debug('warning: cannot write to blackbox.log: %s\n' % | |
115 | err.strerror) |
|
115 | err.strerror) | |
116 | lastblackbox = blackbox |
|
116 | lastblackbox = blackbox |
@@ -357,7 +357,7 b' class bzmysql(bzaccess):' | |||||
357 | try: |
|
357 | try: | |
358 | import MySQLdb as mysql |
|
358 | import MySQLdb as mysql | |
359 | bzmysql._MySQLdb = mysql |
|
359 | bzmysql._MySQLdb = mysql | |
360 |
except ImportError |
|
360 | except ImportError as err: | |
361 | raise util.Abort(_('python mysql support not available: %s') % err) |
|
361 | raise util.Abort(_('python mysql support not available: %s') % err) | |
362 |
|
362 | |||
363 | bzaccess.__init__(self, ui) |
|
363 | bzaccess.__init__(self, ui) | |
@@ -910,5 +910,5 b' def hook(ui, repo, hooktype, node=None, ' | |||||
910 | for bug in bugs: |
|
910 | for bug in bugs: | |
911 | bz.update(bug, bugs[bug], ctx) |
|
911 | bz.update(bug, bugs[bug], ctx) | |
912 | bz.notify(bugs, util.email(ctx.user())) |
|
912 | bz.notify(bugs, util.email(ctx.user())) | |
913 |
except Exception |
|
913 | except Exception as e: | |
914 | raise util.Abort(_('Bugzilla error: %s') % e) |
|
914 | raise util.Abort(_('Bugzilla error: %s') % e) |
@@ -147,7 +147,7 b" def censor(ui, repo, path, rev='', tombs" | |||||
147 | # Immediate children of censored node must be re-added as fulltext. |
|
147 | # Immediate children of censored node must be re-added as fulltext. | |
148 | try: |
|
148 | try: | |
149 | revdata = flog.revision(srev) |
|
149 | revdata = flog.revision(srev) | |
150 |
except error.CensoredNodeError |
|
150 | except error.CensoredNodeError as e: | |
151 | revdata = e.tombstone |
|
151 | revdata = e.tombstone | |
152 | dlen = rewrite(srev, offset, revdata) |
|
152 | dlen = rewrite(srev, offset, revdata) | |
153 | else: |
|
153 | else: |
@@ -26,7 +26,7 b' def maketemplater(ui, repo, tmpl):' | |||||
26 | try: |
|
26 | try: | |
27 | t = cmdutil.changeset_templater(ui, repo, False, None, tmpl, |
|
27 | t = cmdutil.changeset_templater(ui, repo, False, None, tmpl, | |
28 | None, False) |
|
28 | None, False) | |
29 |
except SyntaxError |
|
29 | except SyntaxError as inst: | |
30 | raise util.Abort(inst.args[0]) |
|
30 | raise util.Abort(inst.args[0]) | |
31 | return t |
|
31 | return t | |
32 |
|
32 |
@@ -194,7 +194,7 b' def _terminfosetup(ui, mode):' | |||||
194 |
|
194 | |||
195 | try: |
|
195 | try: | |
196 | curses.setupterm() |
|
196 | curses.setupterm() | |
197 |
except curses.error |
|
197 | except curses.error as e: | |
198 | _terminfo_params = {} |
|
198 | _terminfo_params = {} | |
199 | return |
|
199 | return | |
200 |
|
200 |
@@ -427,7 +427,7 b' class mapfile(dict):' | |||||
427 | return |
|
427 | return | |
428 | try: |
|
428 | try: | |
429 | fp = open(self.path, 'r') |
|
429 | fp = open(self.path, 'r') | |
430 |
except IOError |
|
430 | except IOError as err: | |
431 | if err.errno != errno.ENOENT: |
|
431 | if err.errno != errno.ENOENT: | |
432 | raise |
|
432 | raise | |
433 | return |
|
433 | return | |
@@ -451,7 +451,7 b' class mapfile(dict):' | |||||
451 | if self.fp is None: |
|
451 | if self.fp is None: | |
452 | try: |
|
452 | try: | |
453 | self.fp = open(self.path, 'a') |
|
453 | self.fp = open(self.path, 'a') | |
454 |
except IOError |
|
454 | except IOError as err: | |
455 | raise util.Abort(_('could not open map file %r: %s') % |
|
455 | raise util.Abort(_('could not open map file %r: %s') % | |
456 | (self.path, err.strerror)) |
|
456 | (self.path, err.strerror)) | |
457 | self.fp.write('%s %s\n' % (key, value)) |
|
457 | self.fp.write('%s %s\n' % (key, value)) |
@@ -54,7 +54,7 b' def convertsource(ui, path, type, rev):' | |||||
54 | try: |
|
54 | try: | |
55 | if not type or name == type: |
|
55 | if not type or name == type: | |
56 | return source(ui, path, rev), sortmode |
|
56 | return source(ui, path, rev), sortmode | |
57 |
except (NoRepo, MissingTool) |
|
57 | except (NoRepo, MissingTool) as inst: | |
58 | exceptions.append(inst) |
|
58 | exceptions.append(inst) | |
59 | if not ui.quiet: |
|
59 | if not ui.quiet: | |
60 | for inst in exceptions: |
|
60 | for inst in exceptions: | |
@@ -68,9 +68,9 b' def convertsink(ui, path, type):' | |||||
68 | try: |
|
68 | try: | |
69 | if not type or name == type: |
|
69 | if not type or name == type: | |
70 | return sink(ui, path) |
|
70 | return sink(ui, path) | |
71 |
except NoRepo |
|
71 | except NoRepo as inst: | |
72 | ui.note(_("convert: %s\n") % inst) |
|
72 | ui.note(_("convert: %s\n") % inst) | |
73 |
except MissingTool |
|
73 | except MissingTool as inst: | |
74 | raise util.Abort('%s\n' % inst) |
|
74 | raise util.Abort('%s\n' % inst) | |
75 | raise util.Abort(_('%s: unknown repository type') % path) |
|
75 | raise util.Abort(_('%s: unknown repository type') % path) | |
76 |
|
76 |
@@ -136,7 +136,7 b' class convert_cvs(converter_source):' | |||||
136 | passw = part2 |
|
136 | passw = part2 | |
137 | break |
|
137 | break | |
138 | pf.close() |
|
138 | pf.close() | |
139 |
except IOError |
|
139 | except IOError as inst: | |
140 | if inst.errno != errno.ENOENT: |
|
140 | if inst.errno != errno.ENOENT: | |
141 | if not getattr(inst, 'filename', None): |
|
141 | if not getattr(inst, 'filename', None): | |
142 | inst.filename = cvspass |
|
142 | inst.filename = cvspass |
@@ -179,7 +179,7 b' def createlog(ui, directory=None, root="' | |||||
179 | break |
|
179 | break | |
180 |
|
180 | |||
181 | ui.note(_('cache has %d log entries\n') % len(oldlog)) |
|
181 | ui.note(_('cache has %d log entries\n') % len(oldlog)) | |
182 |
except Exception |
|
182 | except Exception as e: | |
183 | ui.note(_('error reading cache: %r\n') % e) |
|
183 | ui.note(_('error reading cache: %r\n') % e) | |
184 |
|
184 | |||
185 | if oldlog: |
|
185 | if oldlog: | |
@@ -824,7 +824,7 b' def debugcvsps(ui, *args, **opts):' | |||||
824 | log += createlog(ui, d, root=opts["root"], cache=cache) |
|
824 | log += createlog(ui, d, root=opts["root"], cache=cache) | |
825 | else: |
|
825 | else: | |
826 | log = createlog(ui, root=opts["root"], cache=cache) |
|
826 | log = createlog(ui, root=opts["root"], cache=cache) | |
827 |
except logerror |
|
827 | except logerror as e: | |
828 | ui.write("%r\n"%e) |
|
828 | ui.write("%r\n"%e) | |
829 | return |
|
829 | return | |
830 |
|
830 |
@@ -197,7 +197,7 b' class darcs_source(converter_source, com' | |||||
197 | try: |
|
197 | try: | |
198 | data = util.readfile(path) |
|
198 | data = util.readfile(path) | |
199 | mode = os.lstat(path).st_mode |
|
199 | mode = os.lstat(path).st_mode | |
200 |
except IOError |
|
200 | except IOError as inst: | |
201 | if inst.errno == errno.ENOENT: |
|
201 | if inst.errno == errno.ENOENT: | |
202 | return None, None |
|
202 | return None, None | |
203 | raise |
|
203 | raise |
@@ -42,7 +42,7 b' class mercurial_sink(converter_sink):' | |||||
42 | if not self.repo.local(): |
|
42 | if not self.repo.local(): | |
43 | raise NoRepo(_('%s is not a local Mercurial repository') |
|
43 | raise NoRepo(_('%s is not a local Mercurial repository') | |
44 | % path) |
|
44 | % path) | |
45 |
except error.RepoError |
|
45 | except error.RepoError as err: | |
46 | ui.traceback() |
|
46 | ui.traceback() | |
47 | raise NoRepo(err.args[0]) |
|
47 | raise NoRepo(err.args[0]) | |
48 | else: |
|
48 | else: | |
@@ -487,7 +487,7 b' class mercurial_source(converter_source)' | |||||
487 | copies[name] = copysource |
|
487 | copies[name] = copysource | |
488 | except TypeError: |
|
488 | except TypeError: | |
489 | pass |
|
489 | pass | |
490 |
except error.LookupError |
|
490 | except error.LookupError as e: | |
491 | if not self.ignoreerrors: |
|
491 | if not self.ignoreerrors: | |
492 | raise |
|
492 | raise | |
493 | self.ignored.add(name) |
|
493 | self.ignored.add(name) |
@@ -126,7 +126,7 b' def get_log_child(fp, url, paths, start,' | |||||
126 | except IOError: |
|
126 | except IOError: | |
127 | # Caller may interrupt the iteration |
|
127 | # Caller may interrupt the iteration | |
128 | pickle.dump(None, fp, protocol) |
|
128 | pickle.dump(None, fp, protocol) | |
129 |
except Exception |
|
129 | except Exception as inst: | |
130 | pickle.dump(str(inst), fp, protocol) |
|
130 | pickle.dump(str(inst), fp, protocol) | |
131 | else: |
|
131 | else: | |
132 | pickle.dump(None, fp, protocol) |
|
132 | pickle.dump(None, fp, protocol) | |
@@ -216,7 +216,7 b' def httpcheck(ui, path, proto):' | |||||
216 | opener = urllib2.build_opener() |
|
216 | opener = urllib2.build_opener() | |
217 | rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path)) |
|
217 | rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path)) | |
218 | data = rsp.read() |
|
218 | data = rsp.read() | |
219 |
except urllib2.HTTPError |
|
219 | except urllib2.HTTPError as inst: | |
220 | if inst.code != 404: |
|
220 | if inst.code != 404: | |
221 | # Except for 404 we cannot know for sure this is not an svn repo |
|
221 | # Except for 404 we cannot know for sure this is not an svn repo | |
222 | ui.warn(_('svn: cannot probe remote repository, assume it could ' |
|
222 | ui.warn(_('svn: cannot probe remote repository, assume it could ' | |
@@ -944,7 +944,8 b' class svn_source(converter_source):' | |||||
944 | firstcset.parents.append(latest) |
|
944 | firstcset.parents.append(latest) | |
945 | except SvnPathNotFound: |
|
945 | except SvnPathNotFound: | |
946 | pass |
|
946 | pass | |
947 |
except SubversionException |
|
947 | except SubversionException as xxx_todo_changeme: | |
|
948 | (inst, num) = xxx_todo_changeme.args | |||
948 | if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION: |
|
949 | if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION: | |
949 | raise util.Abort(_('svn: branch has no revision %s') |
|
950 | raise util.Abort(_('svn: branch has no revision %s') | |
950 | % to_revnum) |
|
951 | % to_revnum) | |
@@ -970,7 +971,7 b' class svn_source(converter_source):' | |||||
970 | info = info[-1] |
|
971 | info = info[-1] | |
971 | mode = ("svn:executable" in info) and 'x' or '' |
|
972 | mode = ("svn:executable" in info) and 'x' or '' | |
972 | mode = ("svn:special" in info) and 'l' or mode |
|
973 | mode = ("svn:special" in info) and 'l' or mode | |
973 |
except SubversionException |
|
974 | except SubversionException as e: | |
974 | notfound = (svn.core.SVN_ERR_FS_NOT_FOUND, |
|
975 | notfound = (svn.core.SVN_ERR_FS_NOT_FOUND, | |
975 | svn.core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) |
|
976 | svn.core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) | |
976 | if e.apr_err in notfound: # File not found |
|
977 | if e.apr_err in notfound: # File not found |
@@ -87,7 +87,8 b' class SvnRaTransport(object):' | |||||
87 | self.ra = svn.client.open_ra_session( |
|
87 | self.ra = svn.client.open_ra_session( | |
88 | self.svn_url, |
|
88 | self.svn_url, | |
89 | self.client, self.pool) |
|
89 | self.client, self.pool) | |
90 |
except SubversionException |
|
90 | except SubversionException as xxx_todo_changeme: | |
|
91 | (inst, num) = xxx_todo_changeme.args | |||
91 | if num in (svn.core.SVN_ERR_RA_ILLEGAL_URL, |
|
92 | if num in (svn.core.SVN_ERR_RA_ILLEGAL_URL, | |
92 | svn.core.SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED, |
|
93 | svn.core.SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED, | |
93 | svn.core.SVN_ERR_BAD_URL): |
|
94 | svn.core.SVN_ERR_BAD_URL): |
@@ -218,7 +218,7 b' def parseeol(ui, repo, nodes):' | |||||
218 | return eolfile(ui, repo.root, data) |
|
218 | return eolfile(ui, repo.root, data) | |
219 | except (IOError, LookupError): |
|
219 | except (IOError, LookupError): | |
220 | pass |
|
220 | pass | |
221 |
except error.ParseError |
|
221 | except error.ParseError as inst: | |
222 | ui.warn(_("warning: ignoring .hgeol file due to parse error " |
|
222 | ui.warn(_("warning: ignoring .hgeol file due to parse error " | |
223 | "at %s: %s\n") % (inst.args[1], inst.args[0])) |
|
223 | "at %s: %s\n") % (inst.args[1], inst.args[0])) | |
224 | return None |
|
224 | return None |
@@ -283,7 +283,7 b' def sign(ui, repo, *revs, **opts):' | |||||
283 | editor = cmdutil.getcommiteditor(editform='gpg.sign', **opts) |
|
283 | editor = cmdutil.getcommiteditor(editform='gpg.sign', **opts) | |
284 | repo.commit(message, opts['user'], opts['date'], match=msigs, |
|
284 | repo.commit(message, opts['user'], opts['date'], match=msigs, | |
285 | editor=editor) |
|
285 | editor=editor) | |
286 |
except ValueError |
|
286 | except ValueError as inst: | |
287 | raise util.Abort(str(inst)) |
|
287 | raise util.Abort(str(inst)) | |
288 |
|
288 | |||
289 | def shortkey(ui, key): |
|
289 | def shortkey(ui, key): |
@@ -222,7 +222,7 b' class histeditstate(object):' | |||||
222 | """Load histedit state from disk and set fields appropriately.""" |
|
222 | """Load histedit state from disk and set fields appropriately.""" | |
223 | try: |
|
223 | try: | |
224 | fp = self.repo.vfs('histedit-state', 'r') |
|
224 | fp = self.repo.vfs('histedit-state', 'r') | |
225 |
except IOError |
|
225 | except IOError as err: | |
226 | if err.errno != errno.ENOENT: |
|
226 | if err.errno != errno.ENOENT: | |
227 | raise |
|
227 | raise | |
228 | raise util.Abort(_('no histedit in progress')) |
|
228 | raise util.Abort(_('no histedit in progress')) |
@@ -96,7 +96,7 b' class basestore(object):' | |||||
96 |
|
96 | |||
97 | try: |
|
97 | try: | |
98 | gothash = self._getfile(tmpfile, filename, hash) |
|
98 | gothash = self._getfile(tmpfile, filename, hash) | |
99 |
except StoreError |
|
99 | except StoreError as err: | |
100 | self.ui.warn(err.longmessage()) |
|
100 | self.ui.warn(err.longmessage()) | |
101 | gothash = "" |
|
101 | gothash = "" | |
102 | tmpfile.close() |
|
102 | tmpfile.close() |
@@ -391,7 +391,7 b' def cachelfiles(ui, repo, node, filelist' | |||||
391 | for lfile in lfiles: |
|
391 | for lfile in lfiles: | |
392 | try: |
|
392 | try: | |
393 | expectedhash = repo[node][lfutil.standin(lfile)].data().strip() |
|
393 | expectedhash = repo[node][lfutil.standin(lfile)].data().strip() | |
394 |
except IOError |
|
394 | except IOError as err: | |
395 | if err.errno == errno.ENOENT: |
|
395 | if err.errno == errno.ENOENT: | |
396 | continue # node must be None and standin wasn't found in wctx |
|
396 | continue # node must be None and standin wasn't found in wctx | |
397 | raise |
|
397 | raise |
@@ -580,7 +580,7 b' def overridecopy(orig, ui, repo, pats, o' | |||||
580 | installnormalfilesmatchfn(repo[None].manifest()) |
|
580 | installnormalfilesmatchfn(repo[None].manifest()) | |
581 | try: |
|
581 | try: | |
582 | result = orig(ui, repo, pats, opts, rename) |
|
582 | result = orig(ui, repo, pats, opts, rename) | |
583 |
except util.Abort |
|
583 | except util.Abort as e: | |
584 | if str(e) != _('no files to copy'): |
|
584 | if str(e) != _('no files to copy'): | |
585 | raise e |
|
585 | raise e | |
586 | else: |
|
586 | else: | |
@@ -682,7 +682,7 b' def overridecopy(orig, ui, repo, pats, o' | |||||
682 |
|
682 | |||
683 | lfdirstate.add(destlfile) |
|
683 | lfdirstate.add(destlfile) | |
684 | lfdirstate.write() |
|
684 | lfdirstate.write() | |
685 |
except util.Abort |
|
685 | except util.Abort as e: | |
686 | if str(e) != _('no files to copy'): |
|
686 | if str(e) != _('no files to copy'): | |
687 | raise e |
|
687 | raise e | |
688 | else: |
|
688 | else: |
@@ -37,7 +37,7 b' def putlfile(repo, proto, sha):' | |||||
37 | raise IOError(0, _('largefile contents do not match hash')) |
|
37 | raise IOError(0, _('largefile contents do not match hash')) | |
38 | tmpfp.close() |
|
38 | tmpfp.close() | |
39 | lfutil.linktousercache(repo, sha) |
|
39 | lfutil.linktousercache(repo, sha) | |
40 |
except IOError |
|
40 | except IOError as e: | |
41 | repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') % |
|
41 | repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') % | |
42 | (sha, e.strerror)) |
|
42 | (sha, e.strerror)) | |
43 | return wireproto.pushres(1) |
|
43 | return wireproto.pushres(1) |
@@ -38,7 +38,7 b' class remotestore(basestore.basestore):' | |||||
38 | try: |
|
38 | try: | |
39 | fd = lfutil.httpsendfile(self.ui, filename) |
|
39 | fd = lfutil.httpsendfile(self.ui, filename) | |
40 | return self._put(hash, fd) |
|
40 | return self._put(hash, fd) | |
41 |
except IOError |
|
41 | except IOError as e: | |
42 | raise util.Abort( |
|
42 | raise util.Abort( | |
43 | _('remotestore: could not open file %s: %s') |
|
43 | _('remotestore: could not open file %s: %s') | |
44 | % (filename, str(e))) |
|
44 | % (filename, str(e))) | |
@@ -49,17 +49,17 b' class remotestore(basestore.basestore):' | |||||
49 | def _getfile(self, tmpfile, filename, hash): |
|
49 | def _getfile(self, tmpfile, filename, hash): | |
50 | try: |
|
50 | try: | |
51 | chunks = self._get(hash) |
|
51 | chunks = self._get(hash) | |
52 |
except urllib2.HTTPError |
|
52 | except urllib2.HTTPError as e: | |
53 | # 401s get converted to util.Aborts; everything else is fine being |
|
53 | # 401s get converted to util.Aborts; everything else is fine being | |
54 | # turned into a StoreError |
|
54 | # turned into a StoreError | |
55 | raise basestore.StoreError(filename, hash, self.url, str(e)) |
|
55 | raise basestore.StoreError(filename, hash, self.url, str(e)) | |
56 |
except urllib2.URLError |
|
56 | except urllib2.URLError as e: | |
57 | # This usually indicates a connection problem, so don't |
|
57 | # This usually indicates a connection problem, so don't | |
58 | # keep trying with the other files... they will probably |
|
58 | # keep trying with the other files... they will probably | |
59 | # all fail too. |
|
59 | # all fail too. | |
60 | raise util.Abort('%s: %s' % |
|
60 | raise util.Abort('%s: %s' % | |
61 | (util.hidepassword(self.url), e.reason)) |
|
61 | (util.hidepassword(self.url), e.reason)) | |
62 |
except IOError |
|
62 | except IOError as e: | |
63 | raise basestore.StoreError(filename, hash, self.url, str(e)) |
|
63 | raise basestore.StoreError(filename, hash, self.url, str(e)) | |
64 |
|
64 | |||
65 | return lfutil.copyandhash(chunks, tmpfile) |
|
65 | return lfutil.copyandhash(chunks, tmpfile) |
@@ -448,7 +448,7 b' class queue(object):' | |||||
448 | try: |
|
448 | try: | |
449 | lines = self.opener.read(self.statuspath).splitlines() |
|
449 | lines = self.opener.read(self.statuspath).splitlines() | |
450 | return list(parselines(lines)) |
|
450 | return list(parselines(lines)) | |
451 |
except IOError |
|
451 | except IOError as e: | |
452 | if e.errno == errno.ENOENT: |
|
452 | if e.errno == errno.ENOENT: | |
453 | return [] |
|
453 | return [] | |
454 | raise |
|
454 | raise | |
@@ -457,7 +457,7 b' class queue(object):' | |||||
457 | def fullseries(self): |
|
457 | def fullseries(self): | |
458 | try: |
|
458 | try: | |
459 | return self.opener.read(self.seriespath).splitlines() |
|
459 | return self.opener.read(self.seriespath).splitlines() | |
460 |
except IOError |
|
460 | except IOError as e: | |
461 | if e.errno == errno.ENOENT: |
|
461 | if e.errno == errno.ENOENT: | |
462 | return [] |
|
462 | return [] | |
463 | raise |
|
463 | raise | |
@@ -574,7 +574,7 b' class queue(object):' | |||||
574 | self.activeguards = [] |
|
574 | self.activeguards = [] | |
575 | try: |
|
575 | try: | |
576 | guards = self.opener.read(self.guardspath).split() |
|
576 | guards = self.opener.read(self.guardspath).split() | |
577 |
except IOError |
|
577 | except IOError as err: | |
578 | if err.errno != errno.ENOENT: |
|
578 | if err.errno != errno.ENOENT: | |
579 | raise |
|
579 | raise | |
580 | guards = [] |
|
580 | guards = [] | |
@@ -675,7 +675,7 b' class queue(object):' | |||||
675 | return |
|
675 | return | |
676 | try: |
|
676 | try: | |
677 | os.unlink(undo) |
|
677 | os.unlink(undo) | |
678 |
except OSError |
|
678 | except OSError as inst: | |
679 | self.ui.warn(_('error removing undo: %s\n') % str(inst)) |
|
679 | self.ui.warn(_('error removing undo: %s\n') % str(inst)) | |
680 |
|
680 | |||
681 | def backup(self, repo, files, copy=False): |
|
681 | def backup(self, repo, files, copy=False): | |
@@ -804,7 +804,7 b' class queue(object):' | |||||
804 | fuzz = patchmod.patch(self.ui, repo, patchfile, strip=1, |
|
804 | fuzz = patchmod.patch(self.ui, repo, patchfile, strip=1, | |
805 | files=files, eolmode=None) |
|
805 | files=files, eolmode=None) | |
806 | return (True, list(files), fuzz) |
|
806 | return (True, list(files), fuzz) | |
807 |
except Exception |
|
807 | except Exception as inst: | |
808 | self.ui.note(str(inst) + '\n') |
|
808 | self.ui.note(str(inst) + '\n') | |
809 | if not self.ui.verbose: |
|
809 | if not self.ui.verbose: | |
810 | self.ui.warn(_("patch failed, unable to continue (try -v)\n")) |
|
810 | self.ui.warn(_("patch failed, unable to continue (try -v)\n")) | |
@@ -959,7 +959,7 b' class queue(object):' | |||||
959 | for p in patches: |
|
959 | for p in patches: | |
960 | try: |
|
960 | try: | |
961 | os.unlink(self.join(p)) |
|
961 | os.unlink(self.join(p)) | |
962 |
except OSError |
|
962 | except OSError as inst: | |
963 | if inst.errno != errno.ENOENT: |
|
963 | if inst.errno != errno.ENOENT: | |
964 | raise |
|
964 | raise | |
965 |
|
965 | |||
@@ -1159,7 +1159,7 b' class queue(object):' | |||||
1159 | try: |
|
1159 | try: | |
1160 | # if patch file write fails, abort early |
|
1160 | # if patch file write fails, abort early | |
1161 | p = self.opener(patchfn, "w") |
|
1161 | p = self.opener(patchfn, "w") | |
1162 |
except IOError |
|
1162 | except IOError as e: | |
1163 | raise util.Abort(_('cannot write patch "%s": %s') |
|
1163 | raise util.Abort(_('cannot write patch "%s": %s') | |
1164 | % (patchfn, e.strerror)) |
|
1164 | % (patchfn, e.strerror)) | |
1165 | try: |
|
1165 | try: | |
@@ -1816,7 +1816,7 b' class queue(object):' | |||||
1816 | raise util.Abort(_("patch queue directory already exists")) |
|
1816 | raise util.Abort(_("patch queue directory already exists")) | |
1817 | try: |
|
1817 | try: | |
1818 | os.mkdir(self.path) |
|
1818 | os.mkdir(self.path) | |
1819 |
except OSError |
|
1819 | except OSError as inst: | |
1820 | if inst.errno != errno.EEXIST or not create: |
|
1820 | if inst.errno != errno.EEXIST or not create: | |
1821 | raise |
|
1821 | raise | |
1822 | if create: |
|
1822 | if create: |
@@ -276,7 +276,7 b' class notifier(object):' | |||||
276 | p = email.Parser.Parser() |
|
276 | p = email.Parser.Parser() | |
277 | try: |
|
277 | try: | |
278 | msg = p.parsestr(data) |
|
278 | msg = p.parsestr(data) | |
279 |
except email.Errors.MessageParseError |
|
279 | except email.Errors.MessageParseError as inst: | |
280 | raise util.Abort(inst) |
|
280 | raise util.Abort(inst) | |
281 |
|
281 | |||
282 | # store sender and subject |
|
282 | # store sender and subject |
@@ -628,7 +628,7 b' def patchbomb(ui, repo, *revs, **opts):' | |||||
628 | try: |
|
628 | try: | |
629 | generator.flatten(m, 0) |
|
629 | generator.flatten(m, 0) | |
630 | fp.write('\n') |
|
630 | fp.write('\n') | |
631 |
except IOError |
|
631 | except IOError as inst: | |
632 | if inst.errno != errno.EPIPE: |
|
632 | if inst.errno != errno.EPIPE: | |
633 | raise |
|
633 | raise | |
634 | if fp is not ui: |
|
634 | if fp is not ui: |
@@ -838,7 +838,7 b' def restorestatus(repo):' | |||||
838 | _setrebasesetvisibility(repo, state.keys()) |
|
838 | _setrebasesetvisibility(repo, state.keys()) | |
839 | return (originalwd, target, state, skipped, |
|
839 | return (originalwd, target, state, skipped, | |
840 | collapse, keep, keepbranches, external, activebookmark) |
|
840 | collapse, keep, keepbranches, external, activebookmark) | |
841 |
except IOError |
|
841 | except IOError as err: | |
842 | if err.errno != errno.ENOENT: |
|
842 | if err.errno != errno.ENOENT: | |
843 | raise |
|
843 | raise | |
844 | raise util.Abort(_('no rebase in progress')) |
|
844 | raise util.Abort(_('no rebase in progress')) |
@@ -178,7 +178,7 b' def do_relink(src, dst, files, ui):' | |||||
178 | ui.progress(_('relinking'), pos, f, _('files'), total) |
|
178 | ui.progress(_('relinking'), pos, f, _('files'), total) | |
179 | relinked += 1 |
|
179 | relinked += 1 | |
180 | savedbytes += sz |
|
180 | savedbytes += sz | |
181 |
except OSError |
|
181 | except OSError as inst: | |
182 | ui.warn('%s: %s\n' % (tgt, str(inst))) |
|
182 | ui.warn('%s: %s\n' % (tgt, str(inst))) | |
183 |
|
183 | |||
184 | ui.progress(_('relinking'), None) |
|
184 | ui.progress(_('relinking'), None) |
@@ -84,7 +84,7 b' def _hassharedbookmarks(repo):' | |||||
84 | """Returns whether this repo has shared bookmarks""" |
|
84 | """Returns whether this repo has shared bookmarks""" | |
85 | try: |
|
85 | try: | |
86 | shared = repo.vfs.read('shared').splitlines() |
|
86 | shared = repo.vfs.read('shared').splitlines() | |
87 |
except IOError |
|
87 | except IOError as inst: | |
88 | if inst.errno != errno.ENOENT: |
|
88 | if inst.errno != errno.ENOENT: | |
89 | raise |
|
89 | raise | |
90 | return False |
|
90 | return False |
@@ -69,7 +69,7 b' class shelvedfile(object):' | |||||
69 | def opener(self, mode='rb'): |
|
69 | def opener(self, mode='rb'): | |
70 | try: |
|
70 | try: | |
71 | return self.vfs(self.fname, mode) |
|
71 | return self.vfs(self.fname, mode) | |
72 |
except IOError |
|
72 | except IOError as err: | |
73 | if err.errno != errno.ENOENT: |
|
73 | if err.errno != errno.ENOENT: | |
74 | raise |
|
74 | raise | |
75 | raise util.Abort(_("shelved change '%s' not found") % self.name) |
|
75 | raise util.Abort(_("shelved change '%s' not found") % self.name) | |
@@ -294,7 +294,7 b' def deletecmd(ui, repo, pats):' | |||||
294 | for name in pats: |
|
294 | for name in pats: | |
295 | for suffix in 'hg patch'.split(): |
|
295 | for suffix in 'hg patch'.split(): | |
296 | shelvedfile(repo, name, suffix).unlink() |
|
296 | shelvedfile(repo, name, suffix).unlink() | |
297 |
except OSError |
|
297 | except OSError as err: | |
298 | if err.errno != errno.ENOENT: |
|
298 | if err.errno != errno.ENOENT: | |
299 | raise |
|
299 | raise | |
300 | raise util.Abort(_("shelved change '%s' not found") % name) |
|
300 | raise util.Abort(_("shelved change '%s' not found") % name) | |
@@ -305,7 +305,7 b' def listshelves(repo):' | |||||
305 | """return all shelves in repo as list of (time, filename)""" |
|
305 | """return all shelves in repo as list of (time, filename)""" | |
306 | try: |
|
306 | try: | |
307 | names = repo.vfs.readdir('shelved') |
|
307 | names = repo.vfs.readdir('shelved') | |
308 |
except OSError |
|
308 | except OSError as err: | |
309 | if err.errno != errno.ENOENT: |
|
309 | if err.errno != errno.ENOENT: | |
310 | raise |
|
310 | raise | |
311 | return [] |
|
311 | return [] | |
@@ -532,7 +532,7 b' def unshelve(ui, repo, *shelved, **opts)' | |||||
532 |
|
532 | |||
533 | try: |
|
533 | try: | |
534 | state = shelvedstate.load(repo) |
|
534 | state = shelvedstate.load(repo) | |
535 |
except IOError |
|
535 | except IOError as err: | |
536 | if err.errno != errno.ENOENT: |
|
536 | if err.errno != errno.ENOENT: | |
537 | raise |
|
537 | raise | |
538 | raise util.Abort(_('no unshelve operation underway')) |
|
538 | raise util.Abort(_('no unshelve operation underway')) |
@@ -272,7 +272,7 b' class transplanter(object):' | |||||
272 | files = set() |
|
272 | files = set() | |
273 | patch.patch(self.ui, repo, patchfile, files=files, eolmode=None) |
|
273 | patch.patch(self.ui, repo, patchfile, files=files, eolmode=None) | |
274 | files = list(files) |
|
274 | files = list(files) | |
275 |
except Exception |
|
275 | except Exception as inst: | |
276 | seriespath = os.path.join(self.path, 'series') |
|
276 | seriespath = os.path.join(self.path, 'series') | |
277 | if os.path.exists(seriespath): |
|
277 | if os.path.exists(seriespath): | |
278 | os.unlink(seriespath) |
|
278 | os.unlink(seriespath) |
@@ -1276,7 +1276,7 b' class _POFileParser(object):' | |||||
1276 | (action, state) = self.transitions[(symbol, self.current_state)] |
|
1276 | (action, state) = self.transitions[(symbol, self.current_state)] | |
1277 | if action(): |
|
1277 | if action(): | |
1278 | self.current_state = state |
|
1278 | self.current_state = state | |
1279 |
except Exception |
|
1279 | except Exception as exc: | |
1280 | raise IOError('Syntax error in po file (line %s)' % linenum) |
|
1280 | raise IOError('Syntax error in po file (line %s)' % linenum) | |
1281 |
|
1281 | |||
1282 | # state handlers |
|
1282 | # state handlers |
@@ -45,7 +45,7 b' class bmstore(dict):' | |||||
45 | self[refspec] = repo.changelog.lookup(sha) |
|
45 | self[refspec] = repo.changelog.lookup(sha) | |
46 | except LookupError: |
|
46 | except LookupError: | |
47 | pass |
|
47 | pass | |
48 |
except IOError |
|
48 | except IOError as inst: | |
49 | if inst.errno != errno.ENOENT: |
|
49 | if inst.errno != errno.ENOENT: | |
50 | raise |
|
50 | raise | |
51 |
|
51 | |||
@@ -54,7 +54,7 b' class bmstore(dict):' | |||||
54 | if 'HG_PENDING' in os.environ: |
|
54 | if 'HG_PENDING' in os.environ: | |
55 | try: |
|
55 | try: | |
56 | bkfile = repo.vfs('bookmarks.pending') |
|
56 | bkfile = repo.vfs('bookmarks.pending') | |
57 |
except IOError |
|
57 | except IOError as inst: | |
58 | if inst.errno != errno.ENOENT: |
|
58 | if inst.errno != errno.ENOENT: | |
59 | raise |
|
59 | raise | |
60 | if bkfile is None: |
|
60 | if bkfile is None: | |
@@ -116,7 +116,7 b' def readactive(repo):' | |||||
116 | mark = None |
|
116 | mark = None | |
117 | try: |
|
117 | try: | |
118 | file = repo.vfs('bookmarks.current') |
|
118 | file = repo.vfs('bookmarks.current') | |
119 |
except IOError |
|
119 | except IOError as inst: | |
120 | if inst.errno != errno.ENOENT: |
|
120 | if inst.errno != errno.ENOENT: | |
121 | raise |
|
121 | raise | |
122 | return None |
|
122 | return None | |
@@ -159,7 +159,7 b' def deactivate(repo):' | |||||
159 | try: |
|
159 | try: | |
160 | repo.vfs.unlink('bookmarks.current') |
|
160 | repo.vfs.unlink('bookmarks.current') | |
161 | repo._activebookmark = None |
|
161 | repo._activebookmark = None | |
162 |
except OSError |
|
162 | except OSError as inst: | |
163 | if inst.errno != errno.ENOENT: |
|
163 | if inst.errno != errno.ENOENT: | |
164 | raise |
|
164 | raise | |
165 | finally: |
|
165 | finally: |
@@ -55,7 +55,7 b' def read(repo):' | |||||
55 | partial._closednodes.add(node) |
|
55 | partial._closednodes.add(node) | |
56 | except KeyboardInterrupt: |
|
56 | except KeyboardInterrupt: | |
57 | raise |
|
57 | raise | |
58 |
except Exception |
|
58 | except Exception as inst: | |
59 | if repo.ui.debugflag: |
|
59 | if repo.ui.debugflag: | |
60 | msg = 'invalid branchheads cache' |
|
60 | msg = 'invalid branchheads cache' | |
61 | if repo.filtername is not None: |
|
61 | if repo.filtername is not None: | |
@@ -203,7 +203,7 b' class branchcache(dict):' | |||||
203 | repo.ui.log('branchcache', |
|
203 | repo.ui.log('branchcache', | |
204 | 'wrote %s branch cache with %d labels and %d nodes\n', |
|
204 | 'wrote %s branch cache with %d labels and %d nodes\n', | |
205 | repo.filtername, len(self), nodecount) |
|
205 | repo.filtername, len(self), nodecount) | |
206 |
except (IOError, OSError, util.Abort) |
|
206 | except (IOError, OSError, util.Abort) as inst: | |
207 | repo.ui.debug("couldn't write branch cache: %s\n" % inst) |
|
207 | repo.ui.debug("couldn't write branch cache: %s\n" % inst) | |
208 | # Abort may be raise by read only opener |
|
208 | # Abort may be raise by read only opener | |
209 | pass |
|
209 | pass | |
@@ -315,7 +315,7 b' class revbranchcache(object):' | |||||
315 | bndata = repo.vfs.read(_rbcnames) |
|
315 | bndata = repo.vfs.read(_rbcnames) | |
316 | self._rbcsnameslen = len(bndata) # for verification before writing |
|
316 | self._rbcsnameslen = len(bndata) # for verification before writing | |
317 | self._names = [encoding.tolocal(bn) for bn in bndata.split('\0')] |
|
317 | self._names = [encoding.tolocal(bn) for bn in bndata.split('\0')] | |
318 |
except (IOError, OSError) |
|
318 | except (IOError, OSError) as inst: | |
319 | if readonly: |
|
319 | if readonly: | |
320 | # don't try to use cache - fall back to the slow path |
|
320 | # don't try to use cache - fall back to the slow path | |
321 | self.branchinfo = self._branchinfo |
|
321 | self.branchinfo = self._branchinfo | |
@@ -324,7 +324,7 b' class revbranchcache(object):' | |||||
324 | try: |
|
324 | try: | |
325 | data = repo.vfs.read(_rbcrevs) |
|
325 | data = repo.vfs.read(_rbcrevs) | |
326 | self._rbcrevs.fromstring(data) |
|
326 | self._rbcrevs.fromstring(data) | |
327 |
except (IOError, OSError) |
|
327 | except (IOError, OSError) as inst: | |
328 | repo.ui.debug("couldn't read revision branch cache: %s\n" % |
|
328 | repo.ui.debug("couldn't read revision branch cache: %s\n" % | |
329 | inst) |
|
329 | inst) | |
330 | # remember number of good records on disk |
|
330 | # remember number of good records on disk | |
@@ -418,7 +418,7 b' class revbranchcache(object):' | |||||
418 | for b in self._names[self._rbcnamescount:])) |
|
418 | for b in self._names[self._rbcnamescount:])) | |
419 | self._rbcsnameslen = f.tell() |
|
419 | self._rbcsnameslen = f.tell() | |
420 | f.close() |
|
420 | f.close() | |
421 |
except (IOError, OSError, util.Abort) |
|
421 | except (IOError, OSError, util.Abort) as inst: | |
422 | repo.ui.debug("couldn't write revision branch cache names: " |
|
422 | repo.ui.debug("couldn't write revision branch cache names: " | |
423 | "%s\n" % inst) |
|
423 | "%s\n" % inst) | |
424 | return |
|
424 | return | |
@@ -436,7 +436,7 b' class revbranchcache(object):' | |||||
436 | end = revs * _rbcrecsize |
|
436 | end = revs * _rbcrecsize | |
437 | f.write(self._rbcrevs[start:end]) |
|
437 | f.write(self._rbcrevs[start:end]) | |
438 | f.close() |
|
438 | f.close() | |
439 |
except (IOError, OSError, util.Abort) |
|
439 | except (IOError, OSError, util.Abort) as inst: | |
440 | repo.ui.debug("couldn't write revision branch cache: %s\n" % |
|
440 | repo.ui.debug("couldn't write revision branch cache: %s\n" % | |
441 | inst) |
|
441 | inst) | |
442 | return |
|
442 | return |
@@ -336,7 +336,7 b' def processbundle(repo, unbundler, trans' | |||||
336 | try: |
|
336 | try: | |
337 | for nbpart, part in iterparts: |
|
337 | for nbpart, part in iterparts: | |
338 | _processpart(op, part) |
|
338 | _processpart(op, part) | |
339 |
except BaseException |
|
339 | except BaseException as exc: | |
340 | for nbpart, part in iterparts: |
|
340 | for nbpart, part in iterparts: | |
341 | # consume the bundle content |
|
341 | # consume the bundle content | |
342 | part.seek(0, 2) |
|
342 | part.seek(0, 2) | |
@@ -380,7 +380,7 b' def _processpart(op, part):' | |||||
380 | raise error.UnsupportedPartError(parttype=part.type, |
|
380 | raise error.UnsupportedPartError(parttype=part.type, | |
381 | params=unknownparams) |
|
381 | params=unknownparams) | |
382 | status = 'supported' |
|
382 | status = 'supported' | |
383 |
except error.UnsupportedPartError |
|
383 | except error.UnsupportedPartError as exc: | |
384 | if part.mandatory: # mandatory parts |
|
384 | if part.mandatory: # mandatory parts | |
385 | raise |
|
385 | raise | |
386 | indebug(op.ui, 'ignoring unsupported advisory part %s' % exc) |
|
386 | indebug(op.ui, 'ignoring unsupported advisory part %s' % exc) | |
@@ -585,7 +585,7 b' class unpackermixin(object):' | |||||
585 | if self._seekable: |
|
585 | if self._seekable: | |
586 | try: |
|
586 | try: | |
587 | return self._fp.tell() |
|
587 | return self._fp.tell() | |
588 |
except IOError |
|
588 | except IOError as e: | |
589 | if e.errno == errno.ESPIPE: |
|
589 | if e.errno == errno.ESPIPE: | |
590 | self._seekable = False |
|
590 | self._seekable = False | |
591 | else: |
|
591 | else: | |
@@ -841,7 +841,7 b' class bundlepart(object):' | |||||
841 | outdebug(ui, 'payload chunk size: %i' % len(chunk)) |
|
841 | outdebug(ui, 'payload chunk size: %i' % len(chunk)) | |
842 | yield _pack(_fpayloadsize, len(chunk)) |
|
842 | yield _pack(_fpayloadsize, len(chunk)) | |
843 | yield chunk |
|
843 | yield chunk | |
844 |
except BaseException |
|
844 | except BaseException as exc: | |
845 | # backup exception data for later |
|
845 | # backup exception data for later | |
846 | ui.debug('bundle2-input-stream-interrupt: encoding exception %s' |
|
846 | ui.debug('bundle2-input-stream-interrupt: encoding exception %s' | |
847 | % exc) |
|
847 | % exc) | |
@@ -1248,7 +1248,7 b' def handleremotechangegroup(op, inpart):' | |||||
1248 | part.addparam('return', '%i' % ret, mandatory=False) |
|
1248 | part.addparam('return', '%i' % ret, mandatory=False) | |
1249 | try: |
|
1249 | try: | |
1250 | real_part.validate() |
|
1250 | real_part.validate() | |
1251 |
except util.Abort |
|
1251 | except util.Abort as e: | |
1252 | raise util.Abort(_('bundle at %s is corrupted:\n%s') % |
|
1252 | raise util.Abort(_('bundle at %s is corrupted:\n%s') % | |
1253 | (util.hidepassword(raw_url), str(e))) |
|
1253 | (util.hidepassword(raw_url), str(e))) | |
1254 | assert not inpart.read() |
|
1254 | assert not inpart.read() |
@@ -264,7 +264,7 b' class FTPRangeHandler(urllib2.FTPHandler' | |||||
264 |
|
264 | |||
265 | try: |
|
265 | try: | |
266 | host = socket.gethostbyname(host) |
|
266 | host = socket.gethostbyname(host) | |
267 |
except socket.error |
|
267 | except socket.error as msg: | |
268 | raise urllib2.URLError(msg) |
|
268 | raise urllib2.URLError(msg) | |
269 | path, attrs = splitattr(req.get_selector()) |
|
269 | path, attrs = splitattr(req.get_selector()) | |
270 | dirs = path.split('/') |
|
270 | dirs = path.split('/') | |
@@ -322,7 +322,7 b' class FTPRangeHandler(urllib2.FTPHandler' | |||||
322 | headers += "Content-Length: %d\n" % retrlen |
|
322 | headers += "Content-Length: %d\n" % retrlen | |
323 | headers = email.message_from_string(headers) |
|
323 | headers = email.message_from_string(headers) | |
324 | return addinfourl(fp, headers, req.get_full_url()) |
|
324 | return addinfourl(fp, headers, req.get_full_url()) | |
325 |
except ftplib.all_errors |
|
325 | except ftplib.all_errors as msg: | |
326 | raise IOError('ftp error', msg) |
|
326 | raise IOError('ftp error', msg) | |
327 |
|
327 | |||
328 | def connect_ftp(self, user, passwd, host, port, dirs): |
|
328 | def connect_ftp(self, user, passwd, host, port, dirs): | |
@@ -352,7 +352,7 b' class ftpwrapper(urllib.ftpwrapper):' | |||||
352 | # Use nlst to see if the file exists at all |
|
352 | # Use nlst to see if the file exists at all | |
353 | try: |
|
353 | try: | |
354 | self.ftp.nlst(file) |
|
354 | self.ftp.nlst(file) | |
355 |
except ftplib.error_perm |
|
355 | except ftplib.error_perm as reason: | |
356 | raise IOError('ftp error', reason) |
|
356 | raise IOError('ftp error', reason) | |
357 | # Restore the transfer mode! |
|
357 | # Restore the transfer mode! | |
358 | self.ftp.voidcmd(cmd) |
|
358 | self.ftp.voidcmd(cmd) | |
@@ -360,7 +360,7 b' class ftpwrapper(urllib.ftpwrapper):' | |||||
360 | try: |
|
360 | try: | |
361 | cmd = 'RETR ' + file |
|
361 | cmd = 'RETR ' + file | |
362 | conn = self.ftp.ntransfercmd(cmd, rest) |
|
362 | conn = self.ftp.ntransfercmd(cmd, rest) | |
363 |
except ftplib.error_perm |
|
363 | except ftplib.error_perm as reason: | |
364 | if str(reason).startswith('501'): |
|
364 | if str(reason).startswith('501'): | |
365 | # workaround for REST not supported error |
|
365 | # workaround for REST not supported error | |
366 | fp, retrlen = self.retrfile(file, type) |
|
366 | fp, retrlen = self.retrfile(file, type) |
@@ -491,7 +491,7 b' class cg1packer(object):' | |||||
491 | if revlog.iscensored(base) or revlog.iscensored(rev): |
|
491 | if revlog.iscensored(base) or revlog.iscensored(rev): | |
492 | try: |
|
492 | try: | |
493 | delta = revlog.revision(node) |
|
493 | delta = revlog.revision(node) | |
494 |
except error.CensoredNodeError |
|
494 | except error.CensoredNodeError as e: | |
495 | delta = e.tombstone |
|
495 | delta = e.tombstone | |
496 | if base == nullrev: |
|
496 | if base == nullrev: | |
497 | prefix = mdiff.trivialdiffheader(len(delta)) |
|
497 | prefix = mdiff.trivialdiffheader(len(delta)) | |
@@ -665,7 +665,7 b' def addchangegroupfiles(repo, source, re' | |||||
665 | try: |
|
665 | try: | |
666 | if not fl.addgroup(source, revmap, trp): |
|
666 | if not fl.addgroup(source, revmap, trp): | |
667 | raise util.Abort(_("received file revlog group is empty")) |
|
667 | raise util.Abort(_("received file revlog group is empty")) | |
668 |
except error.CensoredBaseError |
|
668 | except error.CensoredBaseError as e: | |
669 | raise util.Abort(_("received delta base is censored: %s") % e) |
|
669 | raise util.Abort(_("received delta base is censored: %s") % e) | |
670 | revisions += len(fl) - o |
|
670 | revisions += len(fl) - o | |
671 | files += 1 |
|
671 | files += 1 |
@@ -119,7 +119,7 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
119 | # 1. filter patch, so we have intending-to apply subset of it |
|
119 | # 1. filter patch, so we have intending-to apply subset of it | |
120 | try: |
|
120 | try: | |
121 | chunks = filterfn(ui, originalchunks) |
|
121 | chunks = filterfn(ui, originalchunks) | |
122 |
except patch.PatchError |
|
122 | except patch.PatchError as err: | |
123 | raise util.Abort(_('error parsing patch: %s') % err) |
|
123 | raise util.Abort(_('error parsing patch: %s') % err) | |
124 |
|
124 | |||
125 | # We need to keep a backup of files that have been newly added and |
|
125 | # We need to keep a backup of files that have been newly added and | |
@@ -153,7 +153,7 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
153 | backupdir = repo.join('record-backups') |
|
153 | backupdir = repo.join('record-backups') | |
154 | try: |
|
154 | try: | |
155 | os.mkdir(backupdir) |
|
155 | os.mkdir(backupdir) | |
156 |
except OSError |
|
156 | except OSError as err: | |
157 | if err.errno != errno.EEXIST: |
|
157 | if err.errno != errno.EEXIST: | |
158 | raise |
|
158 | raise | |
159 | try: |
|
159 | try: | |
@@ -189,7 +189,7 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
189 | ui.debug('applying patch\n') |
|
189 | ui.debug('applying patch\n') | |
190 | ui.debug(fp.getvalue()) |
|
190 | ui.debug(fp.getvalue()) | |
191 | patch.internalpatch(ui, repo, fp, 1, eolmode=None) |
|
191 | patch.internalpatch(ui, repo, fp, 1, eolmode=None) | |
192 |
except patch.PatchError |
|
192 | except patch.PatchError as err: | |
193 | raise util.Abort(str(err)) |
|
193 | raise util.Abort(str(err)) | |
194 | del fp |
|
194 | del fp | |
195 |
|
195 | |||
@@ -309,7 +309,7 b' def logmessage(ui, opts):' | |||||
309 | message = ui.fin.read() |
|
309 | message = ui.fin.read() | |
310 | else: |
|
310 | else: | |
311 | message = '\n'.join(util.readfile(logfile).splitlines()) |
|
311 | message = '\n'.join(util.readfile(logfile).splitlines()) | |
312 |
except IOError |
|
312 | except IOError as inst: | |
313 | raise util.Abort(_("can't read commit message '%s': %s") % |
|
313 | raise util.Abort(_("can't read commit message '%s': %s") % | |
314 | (logfile, inst.strerror)) |
|
314 | (logfile, inst.strerror)) | |
315 | return message |
|
315 | return message | |
@@ -418,7 +418,7 b' def makefilename(repo, pat, node, desc=N' | |||||
418 | newname.append(c) |
|
418 | newname.append(c) | |
419 | i += 1 |
|
419 | i += 1 | |
420 | return ''.join(newname) |
|
420 | return ''.join(newname) | |
421 |
except KeyError |
|
421 | except KeyError as inst: | |
422 | raise util.Abort(_("invalid format spec '%%%s' in output filename") % |
|
422 | raise util.Abort(_("invalid format spec '%%%s' in output filename") % | |
423 | inst.args[0]) |
|
423 | inst.args[0]) | |
424 |
|
424 | |||
@@ -605,7 +605,7 b' def copy(ui, repo, pats, opts, rename=Fa' | |||||
605 | else: |
|
605 | else: | |
606 | util.copyfile(src, target) |
|
606 | util.copyfile(src, target) | |
607 | srcexists = True |
|
607 | srcexists = True | |
608 |
except IOError |
|
608 | except IOError as inst: | |
609 | if inst.errno == errno.ENOENT: |
|
609 | if inst.errno == errno.ENOENT: | |
610 | ui.warn(_('%s: deleted in working directory\n') % relsrc) |
|
610 | ui.warn(_('%s: deleted in working directory\n') % relsrc) | |
611 | srcexists = False |
|
611 | srcexists = False | |
@@ -773,7 +773,7 b' def service(opts, parentfn=None, initfn=' | |||||
773 | finally: |
|
773 | finally: | |
774 | try: |
|
774 | try: | |
775 | os.unlink(lockpath) |
|
775 | os.unlink(lockpath) | |
776 |
except OSError |
|
776 | except OSError as e: | |
777 | if e.errno != errno.ENOENT: |
|
777 | if e.errno != errno.ENOENT: | |
778 | raise |
|
778 | raise | |
779 | if parentfn: |
|
779 | if parentfn: | |
@@ -898,7 +898,7 b' def tryimportone(ui, repo, hunk, parents' | |||||
898 | try: |
|
898 | try: | |
899 | patch.patch(ui, repo, tmpname, strip=strip, prefix=prefix, |
|
899 | patch.patch(ui, repo, tmpname, strip=strip, prefix=prefix, | |
900 | files=files, eolmode=None, similarity=sim / 100.0) |
|
900 | files=files, eolmode=None, similarity=sim / 100.0) | |
901 |
except patch.PatchError |
|
901 | except patch.PatchError as e: | |
902 | if not partial: |
|
902 | if not partial: | |
903 | raise util.Abort(str(e)) |
|
903 | raise util.Abort(str(e)) | |
904 | if partial: |
|
904 | if partial: | |
@@ -942,7 +942,7 b' def tryimportone(ui, repo, hunk, parents' | |||||
942 | try: |
|
942 | try: | |
943 | patch.patchrepo(ui, repo, p1, store, tmpname, strip, prefix, |
|
943 | patch.patchrepo(ui, repo, p1, store, tmpname, strip, prefix, | |
944 | files, eolmode=None) |
|
944 | files, eolmode=None) | |
945 |
except patch.PatchError |
|
945 | except patch.PatchError as e: | |
946 | raise util.Abort(str(e)) |
|
946 | raise util.Abort(str(e)) | |
947 | if opts.get('exact'): |
|
947 | if opts.get('exact'): | |
948 | editor = None |
|
948 | editor = None | |
@@ -1459,10 +1459,10 b' class changeset_templater(changeset_prin' | |||||
1459 | self.footer = templater.stringify(self.t(types['footer'], |
|
1459 | self.footer = templater.stringify(self.t(types['footer'], | |
1460 | **props)) |
|
1460 | **props)) | |
1461 |
|
1461 | |||
1462 |
except KeyError |
|
1462 | except KeyError as inst: | |
1463 | msg = _("%s: no key named '%s'") |
|
1463 | msg = _("%s: no key named '%s'") | |
1464 | raise util.Abort(msg % (self.t.mapfile, inst.args[0])) |
|
1464 | raise util.Abort(msg % (self.t.mapfile, inst.args[0])) | |
1465 |
except SyntaxError |
|
1465 | except SyntaxError as inst: | |
1466 | raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0])) |
|
1466 | raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0])) | |
1467 |
|
1467 | |||
1468 | def gettemplate(ui, tmpl, style): |
|
1468 | def gettemplate(ui, tmpl, style): | |
@@ -1523,7 +1523,7 b' def show_changeset(ui, repo, opts, buffe' | |||||
1523 | try: |
|
1523 | try: | |
1524 | t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile, |
|
1524 | t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile, | |
1525 | buffered) |
|
1525 | buffered) | |
1526 |
except SyntaxError |
|
1526 | except SyntaxError as inst: | |
1527 | raise util.Abort(inst.args[0]) |
|
1527 | raise util.Abort(inst.args[0]) | |
1528 | return t |
|
1528 | return t | |
1529 |
|
1529 | |||
@@ -2682,7 +2682,7 b' def buildcommittemplate(repo, ctx, subs,' | |||||
2682 |
|
2682 | |||
2683 | try: |
|
2683 | try: | |
2684 | t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False) |
|
2684 | t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False) | |
2685 |
except SyntaxError |
|
2685 | except SyntaxError as inst: | |
2686 | raise util.Abort(inst.args[0]) |
|
2686 | raise util.Abort(inst.args[0]) | |
2687 |
|
2687 | |||
2688 | for k, v in repo.ui.configitems('committemplate'): |
|
2688 | for k, v in repo.ui.configitems('committemplate'): | |
@@ -3115,7 +3115,7 b' def _performrevert(repo, parents, ctx, a' | |||||
3115 | if reversehunks: |
|
3115 | if reversehunks: | |
3116 | chunks = patch.reversehunks(chunks) |
|
3116 | chunks = patch.reversehunks(chunks) | |
3117 |
|
3117 | |||
3118 |
except patch.PatchError |
|
3118 | except patch.PatchError as err: | |
3119 | raise util.Abort(_('error parsing patch: %s') % err) |
|
3119 | raise util.Abort(_('error parsing patch: %s') % err) | |
3120 |
|
3120 | |||
3121 | newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) |
|
3121 | newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) | |
@@ -3128,7 +3128,7 b' def _performrevert(repo, parents, ctx, a' | |||||
3128 | if dopatch: |
|
3128 | if dopatch: | |
3129 | try: |
|
3129 | try: | |
3130 | patch.internalpatch(repo.ui, repo, fp, 1, eolmode=None) |
|
3130 | patch.internalpatch(repo.ui, repo, fp, 1, eolmode=None) | |
3131 |
except patch.PatchError |
|
3131 | except patch.PatchError as err: | |
3132 | raise util.Abort(str(err)) |
|
3132 | raise util.Abort(str(err)) | |
3133 | del fp |
|
3133 | del fp | |
3134 | else: |
|
3134 | else: |
@@ -2340,7 +2340,7 b' def debuginstall(ui):' | |||||
2340 | ui.status(_("checking encoding (%s)...\n") % encoding.encoding) |
|
2340 | ui.status(_("checking encoding (%s)...\n") % encoding.encoding) | |
2341 | try: |
|
2341 | try: | |
2342 | encoding.fromlocal("test") |
|
2342 | encoding.fromlocal("test") | |
2343 |
except util.Abort |
|
2343 | except util.Abort as inst: | |
2344 | ui.write(" %s\n" % inst) |
|
2344 | ui.write(" %s\n" % inst) | |
2345 | ui.write(_(" (check that your locale is properly set)\n")) |
|
2345 | ui.write(_(" (check that your locale is properly set)\n")) | |
2346 | problems += 1 |
|
2346 | problems += 1 | |
@@ -2358,7 +2358,7 b' def debuginstall(ui):' | |||||
2358 | try: |
|
2358 | try: | |
2359 | import bdiff, mpatch, base85, osutil |
|
2359 | import bdiff, mpatch, base85, osutil | |
2360 | dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes |
|
2360 | dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes | |
2361 |
except Exception |
|
2361 | except Exception as inst: | |
2362 | ui.write(" %s\n" % inst) |
|
2362 | ui.write(" %s\n" % inst) | |
2363 | ui.write(_(" One or more extensions could not be found")) |
|
2363 | ui.write(_(" One or more extensions could not be found")) | |
2364 | ui.write(_(" (check that you compiled the extensions)\n")) |
|
2364 | ui.write(_(" (check that you compiled the extensions)\n")) | |
@@ -2374,7 +2374,7 b' def debuginstall(ui):' | |||||
2374 | # template found, check if it is working |
|
2374 | # template found, check if it is working | |
2375 | try: |
|
2375 | try: | |
2376 | templater.templater(m) |
|
2376 | templater.templater(m) | |
2377 |
except Exception |
|
2377 | except Exception as inst: | |
2378 | ui.write(" %s\n" % inst) |
|
2378 | ui.write(" %s\n" % inst) | |
2379 | p = None |
|
2379 | p = None | |
2380 | else: |
|
2380 | else: | |
@@ -2406,7 +2406,7 b' def debuginstall(ui):' | |||||
2406 | ui.status(_("checking username...\n")) |
|
2406 | ui.status(_("checking username...\n")) | |
2407 | try: |
|
2407 | try: | |
2408 | ui.username() |
|
2408 | ui.username() | |
2409 |
except util.Abort |
|
2409 | except util.Abort as e: | |
2410 | ui.write(" %s\n" % e) |
|
2410 | ui.write(" %s\n" % e) | |
2411 | ui.write(_(" (specify a username in your configuration file)\n")) |
|
2411 | ui.write(_(" (specify a username in your configuration file)\n")) | |
2412 | problems += 1 |
|
2412 | problems += 1 | |
@@ -2517,7 +2517,7 b' def debuglocks(ui, repo, **opts):' | |||||
2517 | % (user, pid, host) |
|
2517 | % (user, pid, host) | |
2518 | ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age)) |
|
2518 | ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age)) | |
2519 | return 1 |
|
2519 | return 1 | |
2520 |
except OSError |
|
2520 | except OSError as e: | |
2521 | if e.errno != errno.ENOENT: |
|
2521 | if e.errno != errno.ENOENT: | |
2522 | raise |
|
2522 | raise | |
2523 |
|
2523 | |||
@@ -2581,7 +2581,7 b' def debugobsolete(ui, repo, precursor=No' | |||||
2581 | parents=parents, date=date, |
|
2581 | parents=parents, date=date, | |
2582 | metadata=metadata) |
|
2582 | metadata=metadata) | |
2583 | tr.close() |
|
2583 | tr.close() | |
2584 |
except ValueError |
|
2584 | except ValueError as exc: | |
2585 | raise util.Abort(_('bad obsmarker input: %s') % exc) |
|
2585 | raise util.Abort(_('bad obsmarker input: %s') % exc) | |
2586 | finally: |
|
2586 | finally: | |
2587 | tr.release() |
|
2587 | tr.release() | |
@@ -3470,7 +3470,7 b' def graft(ui, repo, *revs, **opts):' | |||||
3470 | try: |
|
3470 | try: | |
3471 | nodes = repo.vfs.read('graftstate').splitlines() |
|
3471 | nodes = repo.vfs.read('graftstate').splitlines() | |
3472 | revs = [repo[node].rev() for node in nodes] |
|
3472 | revs = [repo[node].rev() for node in nodes] | |
3473 |
except IOError |
|
3473 | except IOError as inst: | |
3474 | if inst.errno != errno.ENOENT: |
|
3474 | if inst.errno != errno.ENOENT: | |
3475 | raise |
|
3475 | raise | |
3476 | raise util.Abort(_("no graft state found, can't continue")) |
|
3476 | raise util.Abort(_("no graft state found, can't continue")) | |
@@ -3664,7 +3664,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
3664 | reflags |= re.I |
|
3664 | reflags |= re.I | |
3665 | try: |
|
3665 | try: | |
3666 | regexp = util.re.compile(pattern, reflags) |
|
3666 | regexp = util.re.compile(pattern, reflags) | |
3667 |
except re.error |
|
3667 | except re.error as inst: | |
3668 | ui.warn(_("grep: invalid match pattern: %s\n") % inst) |
|
3668 | ui.warn(_("grep: invalid match pattern: %s\n") % inst) | |
3669 | return 1 |
|
3669 | return 1 | |
3670 | sep, eol = ':', '\n' |
|
3670 | sep, eol = ':', '\n' | |
@@ -5083,7 +5083,7 b' def postincoming(ui, repo, modheads, opt' | |||||
5083 | checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout) |
|
5083 | checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout) | |
5084 | try: |
|
5084 | try: | |
5085 | ret = hg.update(repo, checkout) |
|
5085 | ret = hg.update(repo, checkout) | |
5086 |
except util.Abort |
|
5086 | except util.Abort as inst: | |
5087 | ui.warn(_("not updating: %s\n") % str(inst)) |
|
5087 | ui.warn(_("not updating: %s\n") % str(inst)) | |
5088 | if inst.hint: |
|
5088 | if inst.hint: | |
5089 | ui.warn(_("(%s)\n") % inst.hint) |
|
5089 | ui.warn(_("(%s)\n") % inst.hint) |
@@ -300,9 +300,9 b' class _requesthandler(SocketServer.Strea' | |||||
300 | sv.serve() |
|
300 | sv.serve() | |
301 | # handle exceptions that may be raised by command server. most of |
|
301 | # handle exceptions that may be raised by command server. most of | |
302 | # known exceptions are caught by dispatch. |
|
302 | # known exceptions are caught by dispatch. | |
303 |
except util.Abort |
|
303 | except util.Abort as inst: | |
304 | ui.warn(_('abort: %s\n') % inst) |
|
304 | ui.warn(_('abort: %s\n') % inst) | |
305 |
except IOError |
|
305 | except IOError as inst: | |
306 | if inst.errno != errno.EPIPE: |
|
306 | if inst.errno != errno.EPIPE: | |
307 | raise |
|
307 | raise | |
308 | except KeyboardInterrupt: |
|
308 | except KeyboardInterrupt: |
@@ -122,7 +122,7 b' class config(object):' | |||||
122 | try: |
|
122 | try: | |
123 | include(inc, remap=remap, sections=sections) |
|
123 | include(inc, remap=remap, sections=sections) | |
124 | break |
|
124 | break | |
125 |
except IOError |
|
125 | except IOError as inst: | |
126 | if inst.errno != errno.ENOENT: |
|
126 | if inst.errno != errno.ENOENT: | |
127 | raise error.ParseError(_("cannot include %s (%s)") |
|
127 | raise error.ParseError(_("cannot include %s (%s)") | |
128 | % (inc, inst.strerror), |
|
128 | % (inc, inst.strerror), |
@@ -1438,7 +1438,7 b' class workingctx(committablectx):' | |||||
1438 | def copy(self, source, dest): |
|
1438 | def copy(self, source, dest): | |
1439 | try: |
|
1439 | try: | |
1440 | st = self._repo.wvfs.lstat(dest) |
|
1440 | st = self._repo.wvfs.lstat(dest) | |
1441 |
except OSError |
|
1441 | except OSError as err: | |
1442 | if err.errno != errno.ENOENT: |
|
1442 | if err.errno != errno.ENOENT: | |
1443 | raise |
|
1443 | raise | |
1444 | self._repo.ui.warn(_("%s does not exist!\n") % dest) |
|
1444 | self._repo.ui.warn(_("%s does not exist!\n") % dest) | |
@@ -1684,7 +1684,7 b' class workingfilectx(committablefilectx)' | |||||
1684 | t, tz = self._changectx.date() |
|
1684 | t, tz = self._changectx.date() | |
1685 | try: |
|
1685 | try: | |
1686 | return (int(self._repo.wvfs.lstat(self._path).st_mtime), tz) |
|
1686 | return (int(self._repo.wvfs.lstat(self._path).st_mtime), tz) | |
1687 |
except OSError |
|
1687 | except OSError as err: | |
1688 | if err.errno != errno.ENOENT: |
|
1688 | if err.errno != errno.ENOENT: | |
1689 | raise |
|
1689 | raise | |
1690 | return (t, tz) |
|
1690 | return (t, tz) |
@@ -115,7 +115,7 b' class dirstate(object):' | |||||
115 | def _branch(self): |
|
115 | def _branch(self): | |
116 | try: |
|
116 | try: | |
117 | return self._opener.read("branch").strip() or "default" |
|
117 | return self._opener.read("branch").strip() or "default" | |
118 |
except IOError |
|
118 | except IOError as inst: | |
119 | if inst.errno != errno.ENOENT: |
|
119 | if inst.errno != errno.ENOENT: | |
120 | raise |
|
120 | raise | |
121 | return "default" |
|
121 | return "default" | |
@@ -131,7 +131,7 b' class dirstate(object):' | |||||
131 | return st[:20], st[20:40] |
|
131 | return st[:20], st[20:40] | |
132 | elif l > 0 and l < 40: |
|
132 | elif l > 0 and l < 40: | |
133 | raise util.Abort(_('working directory state appears damaged!')) |
|
133 | raise util.Abort(_('working directory state appears damaged!')) | |
134 |
except IOError |
|
134 | except IOError as err: | |
135 | if err.errno != errno.ENOENT: |
|
135 | if err.errno != errno.ENOENT: | |
136 | raise |
|
136 | raise | |
137 | return [nullid, nullid] |
|
137 | return [nullid, nullid] | |
@@ -331,7 +331,7 b' class dirstate(object):' | |||||
331 | st = fp.read() |
|
331 | st = fp.read() | |
332 | finally: |
|
332 | finally: | |
333 | fp.close() |
|
333 | fp.close() | |
334 |
except IOError |
|
334 | except IOError as err: | |
335 | if err.errno != errno.ENOENT: |
|
335 | if err.errno != errno.ENOENT: | |
336 | raise |
|
336 | raise | |
337 | return |
|
337 | return | |
@@ -717,7 +717,7 b' class dirstate(object):' | |||||
717 | badfn(ff, badtype(kind)) |
|
717 | badfn(ff, badtype(kind)) | |
718 | if nf in dmap: |
|
718 | if nf in dmap: | |
719 | results[nf] = None |
|
719 | results[nf] = None | |
720 |
except OSError |
|
720 | except OSError as inst: # nf not found on disk - it is dirstate only | |
721 | if nf in dmap: # does it exactly match a missing file? |
|
721 | if nf in dmap: # does it exactly match a missing file? | |
722 | results[nf] = None |
|
722 | results[nf] = None | |
723 | else: # does it match a missing directory? |
|
723 | else: # does it match a missing directory? | |
@@ -802,7 +802,7 b' class dirstate(object):' | |||||
802 | skip = '.hg' |
|
802 | skip = '.hg' | |
803 | try: |
|
803 | try: | |
804 | entries = listdir(join(nd), stat=True, skip=skip) |
|
804 | entries = listdir(join(nd), stat=True, skip=skip) | |
805 |
except OSError |
|
805 | except OSError as inst: | |
806 | if inst.errno in (errno.EACCES, errno.ENOENT): |
|
806 | if inst.errno in (errno.EACCES, errno.ENOENT): | |
807 | match.bad(self.pathto(nd), inst.strerror) |
|
807 | match.bad(self.pathto(nd), inst.strerror) | |
808 | continue |
|
808 | continue |
@@ -76,12 +76,12 b' def dispatch(req):' | |||||
76 | req.ui.fout = req.fout |
|
76 | req.ui.fout = req.fout | |
77 | if req.ferr: |
|
77 | if req.ferr: | |
78 | req.ui.ferr = req.ferr |
|
78 | req.ui.ferr = req.ferr | |
79 |
except util.Abort |
|
79 | except util.Abort as inst: | |
80 | ferr.write(_("abort: %s\n") % inst) |
|
80 | ferr.write(_("abort: %s\n") % inst) | |
81 | if inst.hint: |
|
81 | if inst.hint: | |
82 | ferr.write(_("(%s)\n") % inst.hint) |
|
82 | ferr.write(_("(%s)\n") % inst.hint) | |
83 | return -1 |
|
83 | return -1 | |
84 |
except error.ParseError |
|
84 | except error.ParseError as inst: | |
85 | _formatparse(ferr.write, inst) |
|
85 | _formatparse(ferr.write, inst) | |
86 | return -1 |
|
86 | return -1 | |
87 |
|
87 | |||
@@ -172,29 +172,29 b' def _runcatch(req):' | |||||
172 |
|
172 | |||
173 | # Global exception handling, alphabetically |
|
173 | # Global exception handling, alphabetically | |
174 | # Mercurial-specific first, followed by built-in and library exceptions |
|
174 | # Mercurial-specific first, followed by built-in and library exceptions | |
175 |
except error.AmbiguousCommand |
|
175 | except error.AmbiguousCommand as inst: | |
176 | ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") % |
|
176 | ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") % | |
177 | (inst.args[0], " ".join(inst.args[1]))) |
|
177 | (inst.args[0], " ".join(inst.args[1]))) | |
178 |
except error.ParseError |
|
178 | except error.ParseError as inst: | |
179 | _formatparse(ui.warn, inst) |
|
179 | _formatparse(ui.warn, inst) | |
180 | return -1 |
|
180 | return -1 | |
181 |
except error.LockHeld |
|
181 | except error.LockHeld as inst: | |
182 | if inst.errno == errno.ETIMEDOUT: |
|
182 | if inst.errno == errno.ETIMEDOUT: | |
183 | reason = _('timed out waiting for lock held by %s') % inst.locker |
|
183 | reason = _('timed out waiting for lock held by %s') % inst.locker | |
184 | else: |
|
184 | else: | |
185 | reason = _('lock held by %s') % inst.locker |
|
185 | reason = _('lock held by %s') % inst.locker | |
186 | ui.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason)) |
|
186 | ui.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason)) | |
187 |
except error.LockUnavailable |
|
187 | except error.LockUnavailable as inst: | |
188 | ui.warn(_("abort: could not lock %s: %s\n") % |
|
188 | ui.warn(_("abort: could not lock %s: %s\n") % | |
189 | (inst.desc or inst.filename, inst.strerror)) |
|
189 | (inst.desc or inst.filename, inst.strerror)) | |
190 |
except error.CommandError |
|
190 | except error.CommandError as inst: | |
191 | if inst.args[0]: |
|
191 | if inst.args[0]: | |
192 | ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) |
|
192 | ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) | |
193 | commands.help_(ui, inst.args[0], full=False, command=True) |
|
193 | commands.help_(ui, inst.args[0], full=False, command=True) | |
194 | else: |
|
194 | else: | |
195 | ui.warn(_("hg: %s\n") % inst.args[1]) |
|
195 | ui.warn(_("hg: %s\n") % inst.args[1]) | |
196 | commands.help_(ui, 'shortlist') |
|
196 | commands.help_(ui, 'shortlist') | |
197 |
except error.OutOfBandError |
|
197 | except error.OutOfBandError as inst: | |
198 | if inst.args: |
|
198 | if inst.args: | |
199 | msg = _("abort: remote error:\n") |
|
199 | msg = _("abort: remote error:\n") | |
200 | else: |
|
200 | else: | |
@@ -204,11 +204,11 b' def _runcatch(req):' | |||||
204 | ui.warn(''.join(inst.args)) |
|
204 | ui.warn(''.join(inst.args)) | |
205 | if inst.hint: |
|
205 | if inst.hint: | |
206 | ui.warn('(%s)\n' % inst.hint) |
|
206 | ui.warn('(%s)\n' % inst.hint) | |
207 |
except error.RepoError |
|
207 | except error.RepoError as inst: | |
208 | ui.warn(_("abort: %s!\n") % inst) |
|
208 | ui.warn(_("abort: %s!\n") % inst) | |
209 | if inst.hint: |
|
209 | if inst.hint: | |
210 | ui.warn(_("(%s)\n") % inst.hint) |
|
210 | ui.warn(_("(%s)\n") % inst.hint) | |
211 |
except error.ResponseError |
|
211 | except error.ResponseError as inst: | |
212 | ui.warn(_("abort: %s") % inst.args[0]) |
|
212 | ui.warn(_("abort: %s") % inst.args[0]) | |
213 | if not isinstance(inst.args[1], basestring): |
|
213 | if not isinstance(inst.args[1], basestring): | |
214 | ui.warn(" %r\n" % (inst.args[1],)) |
|
214 | ui.warn(" %r\n" % (inst.args[1],)) | |
@@ -216,13 +216,13 b' def _runcatch(req):' | |||||
216 | ui.warn(_(" empty string\n")) |
|
216 | ui.warn(_(" empty string\n")) | |
217 | else: |
|
217 | else: | |
218 | ui.warn("\n%r\n" % util.ellipsis(inst.args[1])) |
|
218 | ui.warn("\n%r\n" % util.ellipsis(inst.args[1])) | |
219 |
except error.CensoredNodeError |
|
219 | except error.CensoredNodeError as inst: | |
220 | ui.warn(_("abort: file censored %s!\n") % inst) |
|
220 | ui.warn(_("abort: file censored %s!\n") % inst) | |
221 |
except error.RevlogError |
|
221 | except error.RevlogError as inst: | |
222 | ui.warn(_("abort: %s!\n") % inst) |
|
222 | ui.warn(_("abort: %s!\n") % inst) | |
223 | except error.SignalInterrupt: |
|
223 | except error.SignalInterrupt: | |
224 | ui.warn(_("killed!\n")) |
|
224 | ui.warn(_("killed!\n")) | |
225 |
except error.UnknownCommand |
|
225 | except error.UnknownCommand as inst: | |
226 | ui.warn(_("hg: unknown command '%s'\n") % inst.args[0]) |
|
226 | ui.warn(_("hg: unknown command '%s'\n") % inst.args[0]) | |
227 | try: |
|
227 | try: | |
228 | # check if the command is in a disabled extension |
|
228 | # check if the command is in a disabled extension | |
@@ -238,21 +238,21 b' def _runcatch(req):' | |||||
238 | suggested = True |
|
238 | suggested = True | |
239 | if not suggested: |
|
239 | if not suggested: | |
240 | commands.help_(ui, 'shortlist') |
|
240 | commands.help_(ui, 'shortlist') | |
241 |
except error.InterventionRequired |
|
241 | except error.InterventionRequired as inst: | |
242 | ui.warn("%s\n" % inst) |
|
242 | ui.warn("%s\n" % inst) | |
243 | return 1 |
|
243 | return 1 | |
244 |
except util.Abort |
|
244 | except util.Abort as inst: | |
245 | ui.warn(_("abort: %s\n") % inst) |
|
245 | ui.warn(_("abort: %s\n") % inst) | |
246 | if inst.hint: |
|
246 | if inst.hint: | |
247 | ui.warn(_("(%s)\n") % inst.hint) |
|
247 | ui.warn(_("(%s)\n") % inst.hint) | |
248 |
except ImportError |
|
248 | except ImportError as inst: | |
249 | ui.warn(_("abort: %s!\n") % inst) |
|
249 | ui.warn(_("abort: %s!\n") % inst) | |
250 | m = str(inst).split()[-1] |
|
250 | m = str(inst).split()[-1] | |
251 | if m in "mpatch bdiff".split(): |
|
251 | if m in "mpatch bdiff".split(): | |
252 | ui.warn(_("(did you forget to compile extensions?)\n")) |
|
252 | ui.warn(_("(did you forget to compile extensions?)\n")) | |
253 | elif m in "zlib".split(): |
|
253 | elif m in "zlib".split(): | |
254 | ui.warn(_("(is your Python install correct?)\n")) |
|
254 | ui.warn(_("(is your Python install correct?)\n")) | |
255 |
except IOError |
|
255 | except IOError as inst: | |
256 | if util.safehasattr(inst, "code"): |
|
256 | if util.safehasattr(inst, "code"): | |
257 | ui.warn(_("abort: %s\n") % inst) |
|
257 | ui.warn(_("abort: %s\n") % inst) | |
258 | elif util.safehasattr(inst, "reason"): |
|
258 | elif util.safehasattr(inst, "reason"): | |
@@ -276,7 +276,7 b' def _runcatch(req):' | |||||
276 | ui.warn(_("abort: %s\n") % inst.strerror) |
|
276 | ui.warn(_("abort: %s\n") % inst.strerror) | |
277 | else: |
|
277 | else: | |
278 | raise |
|
278 | raise | |
279 |
except OSError |
|
279 | except OSError as inst: | |
280 | if getattr(inst, "filename", None) is not None: |
|
280 | if getattr(inst, "filename", None) is not None: | |
281 | ui.warn(_("abort: %s: '%s'\n") % (inst.strerror, inst.filename)) |
|
281 | ui.warn(_("abort: %s: '%s'\n") % (inst.strerror, inst.filename)) | |
282 | else: |
|
282 | else: | |
@@ -284,7 +284,7 b' def _runcatch(req):' | |||||
284 | except KeyboardInterrupt: |
|
284 | except KeyboardInterrupt: | |
285 | try: |
|
285 | try: | |
286 | ui.warn(_("interrupted!\n")) |
|
286 | ui.warn(_("interrupted!\n")) | |
287 |
except IOError |
|
287 | except IOError as inst: | |
288 | if inst.errno == errno.EPIPE: |
|
288 | if inst.errno == errno.EPIPE: | |
289 | if ui.debugflag: |
|
289 | if ui.debugflag: | |
290 | ui.warn(_("\nbroken pipe\n")) |
|
290 | ui.warn(_("\nbroken pipe\n")) | |
@@ -292,11 +292,11 b' def _runcatch(req):' | |||||
292 | raise |
|
292 | raise | |
293 | except MemoryError: |
|
293 | except MemoryError: | |
294 | ui.warn(_("abort: out of memory\n")) |
|
294 | ui.warn(_("abort: out of memory\n")) | |
295 |
except SystemExit |
|
295 | except SystemExit as inst: | |
296 | # Commands shouldn't sys.exit directly, but give a return code. |
|
296 | # Commands shouldn't sys.exit directly, but give a return code. | |
297 | # Just in case catch this and and pass exit code to caller. |
|
297 | # Just in case catch this and and pass exit code to caller. | |
298 | return inst.code |
|
298 | return inst.code | |
299 |
except socket.error |
|
299 | except socket.error as inst: | |
300 | ui.warn(_("abort: %s\n") % inst.args[-1]) |
|
300 | ui.warn(_("abort: %s\n") % inst.args[-1]) | |
301 | except: # re-raises |
|
301 | except: # re-raises | |
302 | myver = util.version() |
|
302 | myver = util.version() | |
@@ -452,7 +452,7 b' class cmdalias(object):' | |||||
452 |
|
452 | |||
453 | try: |
|
453 | try: | |
454 | args = shlex.split(self.definition) |
|
454 | args = shlex.split(self.definition) | |
455 |
except ValueError |
|
455 | except ValueError as inst: | |
456 | self.badalias = (_("error in definition for alias '%s': %s") |
|
456 | self.badalias = (_("error in definition for alias '%s': %s") | |
457 | % (self.name, inst)) |
|
457 | % (self.name, inst)) | |
458 | return |
|
458 | return | |
@@ -543,7 +543,7 b' def _parse(ui, args):' | |||||
543 |
|
543 | |||
544 | try: |
|
544 | try: | |
545 | args = fancyopts.fancyopts(args, commands.globalopts, options) |
|
545 | args = fancyopts.fancyopts(args, commands.globalopts, options) | |
546 |
except fancyopts.getopt.GetoptError |
|
546 | except fancyopts.getopt.GetoptError as inst: | |
547 | raise error.CommandError(None, inst) |
|
547 | raise error.CommandError(None, inst) | |
548 |
|
548 | |||
549 | if args: |
|
549 | if args: | |
@@ -566,7 +566,7 b' def _parse(ui, args):' | |||||
566 |
|
566 | |||
567 | try: |
|
567 | try: | |
568 | args = fancyopts.fancyopts(args, c, cmdoptions, True) |
|
568 | args = fancyopts.fancyopts(args, c, cmdoptions, True) | |
569 |
except fancyopts.getopt.GetoptError |
|
569 | except fancyopts.getopt.GetoptError as inst: | |
570 | raise error.CommandError(cmd, inst) |
|
570 | raise error.CommandError(cmd, inst) | |
571 |
|
571 | |||
572 | # separate global options back out |
|
572 | # separate global options back out | |
@@ -665,7 +665,7 b' def _getlocal(ui, rpath):' | |||||
665 | """ |
|
665 | """ | |
666 | try: |
|
666 | try: | |
667 | wd = os.getcwd() |
|
667 | wd = os.getcwd() | |
668 |
except OSError |
|
668 | except OSError as e: | |
669 | raise util.Abort(_("error getting current working directory: %s") % |
|
669 | raise util.Abort(_("error getting current working directory: %s") % | |
670 | e.strerror) |
|
670 | e.strerror) | |
671 | path = cmdutil.findrepo(wd) or "" |
|
671 | path = cmdutil.findrepo(wd) or "" |
@@ -138,7 +138,7 b' def tolocal(s):' | |||||
138 | except UnicodeDecodeError: |
|
138 | except UnicodeDecodeError: | |
139 | u = s.decode("utf-8", "replace") # last ditch |
|
139 | u = s.decode("utf-8", "replace") # last ditch | |
140 | return u.encode(encoding, "replace") # can't round-trip |
|
140 | return u.encode(encoding, "replace") # can't round-trip | |
141 |
except LookupError |
|
141 | except LookupError as k: | |
142 | raise error.Abort(k, hint="please check your locale settings") |
|
142 | raise error.Abort(k, hint="please check your locale settings") | |
143 |
|
143 | |||
144 | def fromlocal(s): |
|
144 | def fromlocal(s): | |
@@ -158,10 +158,10 b' def fromlocal(s):' | |||||
158 |
|
158 | |||
159 | try: |
|
159 | try: | |
160 | return s.decode(encoding, encodingmode).encode("utf-8") |
|
160 | return s.decode(encoding, encodingmode).encode("utf-8") | |
161 |
except UnicodeDecodeError |
|
161 | except UnicodeDecodeError as inst: | |
162 | sub = s[max(0, inst.start - 10):inst.start + 10] |
|
162 | sub = s[max(0, inst.start - 10):inst.start + 10] | |
163 | raise error.Abort("decoding near '%s': %s!" % (sub, inst)) |
|
163 | raise error.Abort("decoding near '%s': %s!" % (sub, inst)) | |
164 |
except LookupError |
|
164 | except LookupError as k: | |
165 | raise error.Abort(k, hint="please check your locale settings") |
|
165 | raise error.Abort(k, hint="please check your locale settings") | |
166 |
|
166 | |||
167 | # How to treat ambiguous-width characters. Set to 'wide' to treat as wide. |
|
167 | # How to treat ambiguous-width characters. Set to 'wide' to treat as wide. | |
@@ -330,7 +330,7 b' def lower(s):' | |||||
330 | return lu.encode(encoding) |
|
330 | return lu.encode(encoding) | |
331 | except UnicodeError: |
|
331 | except UnicodeError: | |
332 | return s.lower() # we don't know how to fold this except in ASCII |
|
332 | return s.lower() # we don't know how to fold this except in ASCII | |
333 |
except LookupError |
|
333 | except LookupError as k: | |
334 | raise error.Abort(k, hint="please check your locale settings") |
|
334 | raise error.Abort(k, hint="please check your locale settings") | |
335 |
|
335 | |||
336 | def upper(s): |
|
336 | def upper(s): | |
@@ -353,7 +353,7 b' def upperfallback(s):' | |||||
353 | return uu.encode(encoding) |
|
353 | return uu.encode(encoding) | |
354 | except UnicodeError: |
|
354 | except UnicodeError: | |
355 | return s.upper() # we don't know how to fold this except in ASCII |
|
355 | return s.upper() # we don't know how to fold this except in ASCII | |
356 |
except LookupError |
|
356 | except LookupError as k: | |
357 | raise error.Abort(k, hint="please check your locale settings") |
|
357 | raise error.Abort(k, hint="please check your locale settings") | |
358 |
|
358 | |||
359 | class normcasespecs(object): |
|
359 | class normcasespecs(object): |
@@ -215,7 +215,7 b' def push(repo, remote, force=False, revs' | |||||
215 | localwlock = pushop.repo.wlock() |
|
215 | localwlock = pushop.repo.wlock() | |
216 | locallock = pushop.repo.lock() |
|
216 | locallock = pushop.repo.lock() | |
217 | pushop.locallocked = True |
|
217 | pushop.locallocked = True | |
218 |
except IOError |
|
218 | except IOError as err: | |
219 | pushop.locallocked = False |
|
219 | pushop.locallocked = False | |
220 | if err.errno != errno.EACCES: |
|
220 | if err.errno != errno.EACCES: | |
221 | raise |
|
221 | raise | |
@@ -646,16 +646,16 b' def _pushbundle2(pushop):' | |||||
646 | try: |
|
646 | try: | |
647 | try: |
|
647 | try: | |
648 | reply = pushop.remote.unbundle(stream, ['force'], 'push') |
|
648 | reply = pushop.remote.unbundle(stream, ['force'], 'push') | |
649 |
except error.BundleValueError |
|
649 | except error.BundleValueError as exc: | |
650 | raise util.Abort('missing support for %s' % exc) |
|
650 | raise util.Abort('missing support for %s' % exc) | |
651 | try: |
|
651 | try: | |
652 | trgetter = None |
|
652 | trgetter = None | |
653 | if pushback: |
|
653 | if pushback: | |
654 | trgetter = pushop.trmanager.transaction |
|
654 | trgetter = pushop.trmanager.transaction | |
655 | op = bundle2.processbundle(pushop.repo, reply, trgetter) |
|
655 | op = bundle2.processbundle(pushop.repo, reply, trgetter) | |
656 |
except error.BundleValueError |
|
656 | except error.BundleValueError as exc: | |
657 | raise util.Abort('missing support for %s' % exc) |
|
657 | raise util.Abort('missing support for %s' % exc) | |
658 |
except error.PushkeyFailed |
|
658 | except error.PushkeyFailed as exc: | |
659 | partid = int(exc.partid) |
|
659 | partid = int(exc.partid) | |
660 | if partid not in pushop.pkfailcb: |
|
660 | if partid not in pushop.pkfailcb: | |
661 | raise |
|
661 | raise | |
@@ -1061,7 +1061,7 b' def _pullbundle2(pullop):' | |||||
1061 | bundle = pullop.remote.getbundle('pull', **kwargs) |
|
1061 | bundle = pullop.remote.getbundle('pull', **kwargs) | |
1062 | try: |
|
1062 | try: | |
1063 | op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction) |
|
1063 | op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction) | |
1064 |
except error.BundleValueError |
|
1064 | except error.BundleValueError as exc: | |
1065 | raise util.Abort('missing support for %s' % exc) |
|
1065 | raise util.Abort('missing support for %s' % exc) | |
1066 |
|
1066 | |||
1067 | if pullop.fetch: |
|
1067 | if pullop.fetch: | |
@@ -1425,7 +1425,7 b' def unbundle(repo, cg, heads, source, ur' | |||||
1425 | def recordout(output): |
|
1425 | def recordout(output): | |
1426 | r.newpart('output', data=output, mandatory=False) |
|
1426 | r.newpart('output', data=output, mandatory=False) | |
1427 | tr.close() |
|
1427 | tr.close() | |
1428 |
except BaseException |
|
1428 | except BaseException as exc: | |
1429 | exc.duringunbundle2 = True |
|
1429 | exc.duringunbundle2 = True | |
1430 | if captureoutput and r is not None: |
|
1430 | if captureoutput and r is not None: | |
1431 | parts = exc._bundle2salvagedoutput = r.salvageoutput() |
|
1431 | parts = exc._bundle2salvagedoutput = r.salvageoutput() |
@@ -53,7 +53,7 b' def loadpath(path, module_name):' | |||||
53 | else: |
|
53 | else: | |
54 | try: |
|
54 | try: | |
55 | return imp.load_source(module_name, path) |
|
55 | return imp.load_source(module_name, path) | |
56 |
except IOError |
|
56 | except IOError as exc: | |
57 | if not exc.filename: |
|
57 | if not exc.filename: | |
58 | exc.filename = path # python does not fill this |
|
58 | exc.filename = path # python does not fill this | |
59 | raise |
|
59 | raise | |
@@ -82,7 +82,7 b' def load(ui, name, path):' | |||||
82 | return mod |
|
82 | return mod | |
83 | try: |
|
83 | try: | |
84 | mod = importh("hgext.%s" % name) |
|
84 | mod = importh("hgext.%s" % name) | |
85 |
except ImportError |
|
85 | except ImportError as err: | |
86 | ui.debug('could not import hgext.%s (%s): trying %s\n' |
|
86 | ui.debug('could not import hgext.%s (%s): trying %s\n' | |
87 | % (name, err, name)) |
|
87 | % (name, err, name)) | |
88 | if ui.debugflag: |
|
88 | if ui.debugflag: | |
@@ -105,7 +105,7 b' def loadall(ui):' | |||||
105 | load(ui, name, path) |
|
105 | load(ui, name, path) | |
106 | except KeyboardInterrupt: |
|
106 | except KeyboardInterrupt: | |
107 | raise |
|
107 | raise | |
108 |
except Exception |
|
108 | except Exception as inst: | |
109 | if path: |
|
109 | if path: | |
110 | ui.warn(_("*** failed to import extension %s from %s: %s\n") |
|
110 | ui.warn(_("*** failed to import extension %s from %s: %s\n") | |
111 | % (name, path, inst)) |
|
111 | % (name, path, inst)) |
@@ -280,7 +280,7 b' def grep(mctx, x):' | |||||
280 | try: |
|
280 | try: | |
281 | # i18n: "grep" is a keyword |
|
281 | # i18n: "grep" is a keyword | |
282 | r = re.compile(getstring(x, _("grep requires a pattern"))) |
|
282 | r = re.compile(getstring(x, _("grep requires a pattern"))) | |
283 |
except re.error |
|
283 | except re.error as e: | |
284 | raise error.ParseError(_('invalid match pattern: %s') % e) |
|
284 | raise error.ParseError(_('invalid match pattern: %s') % e) | |
285 | return [f for f in mctx.existing() if r.search(mctx.ctx[f].data())] |
|
285 | return [f for f in mctx.existing() if r.search(mctx.ctx[f].data())] | |
286 |
|
286 |
@@ -228,7 +228,7 b' def help_(ui, name, unknowncmd=False, fu' | |||||
228 | try: |
|
228 | try: | |
229 | aliases, entry = cmdutil.findcmd(name, commands.table, |
|
229 | aliases, entry = cmdutil.findcmd(name, commands.table, | |
230 | strict=unknowncmd) |
|
230 | strict=unknowncmd) | |
231 |
except error.AmbiguousCommand |
|
231 | except error.AmbiguousCommand as inst: | |
232 | # py3k fix: except vars can't be used outside the scope of the |
|
232 | # py3k fix: except vars can't be used outside the scope of the | |
233 | # except block, nor can be used inside a lambda. python issue4617 |
|
233 | # except block, nor can be used inside a lambda. python issue4617 | |
234 | prefix = inst.args[0] |
|
234 | prefix = inst.args[0] |
@@ -202,7 +202,7 b' def share(ui, source, dest=None, update=' | |||||
202 | requirements = '' |
|
202 | requirements = '' | |
203 | try: |
|
203 | try: | |
204 | requirements = srcrepo.vfs.read('requires') |
|
204 | requirements = srcrepo.vfs.read('requires') | |
205 |
except IOError |
|
205 | except IOError as inst: | |
206 | if inst.errno != errno.ENOENT: |
|
206 | if inst.errno != errno.ENOENT: | |
207 | raise |
|
207 | raise | |
208 |
|
208 | |||
@@ -388,7 +388,7 b' def clone(ui, peeropts, source, dest=Non' | |||||
388 | try: |
|
388 | try: | |
389 | destpath = hgdir |
|
389 | destpath = hgdir | |
390 | util.makedir(destpath, notindexed=True) |
|
390 | util.makedir(destpath, notindexed=True) | |
391 |
except OSError |
|
391 | except OSError as inst: | |
392 | if inst.errno == errno.EEXIST: |
|
392 | if inst.errno == errno.EEXIST: | |
393 | cleandir = None |
|
393 | cleandir = None | |
394 | raise util.Abort(_("destination '%s' already exists") |
|
394 | raise util.Abort(_("destination '%s' already exists") | |
@@ -428,7 +428,7 b' def clone(ui, peeropts, source, dest=Non' | |||||
428 | try: |
|
428 | try: | |
429 | destpeer = peer(srcrepo or ui, peeropts, dest, create=True) |
|
429 | destpeer = peer(srcrepo or ui, peeropts, dest, create=True) | |
430 | # only pass ui when no srcrepo |
|
430 | # only pass ui when no srcrepo | |
431 |
except OSError |
|
431 | except OSError as inst: | |
432 | if inst.errno == errno.EEXIST: |
|
432 | if inst.errno == errno.EEXIST: | |
433 | cleandir = None |
|
433 | cleandir = None | |
434 | raise util.Abort(_("destination '%s' already exists") |
|
434 | raise util.Abort(_("destination '%s' already exists") |
@@ -153,7 +153,7 b' def staticfile(directory, fname, req):' | |||||
153 | req.respond(HTTP_OK, ct, body=data) |
|
153 | req.respond(HTTP_OK, ct, body=data) | |
154 | except TypeError: |
|
154 | except TypeError: | |
155 | raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename') |
|
155 | raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename') | |
156 |
except OSError |
|
156 | except OSError as err: | |
157 | if err.errno == errno.ENOENT: |
|
157 | if err.errno == errno.ENOENT: | |
158 | raise ErrorResponse(HTTP_NOT_FOUND) |
|
158 | raise ErrorResponse(HTTP_NOT_FOUND) | |
159 | else: |
|
159 | else: |
@@ -190,7 +190,7 b' class hgweb(object):' | |||||
190 | if cmd in perms: |
|
190 | if cmd in perms: | |
191 | self.check_perm(req, perms[cmd]) |
|
191 | self.check_perm(req, perms[cmd]) | |
192 | return protocol.call(self.repo, req, cmd) |
|
192 | return protocol.call(self.repo, req, cmd) | |
193 |
except ErrorResponse |
|
193 | except ErrorResponse as inst: | |
194 | # A client that sends unbundle without 100-continue will |
|
194 | # A client that sends unbundle without 100-continue will | |
195 | # break if we respond early. |
|
195 | # break if we respond early. | |
196 | if (cmd == 'unbundle' and |
|
196 | if (cmd == 'unbundle' and | |
@@ -269,17 +269,17 b' class hgweb(object):' | |||||
269 |
|
269 | |||
270 | return content |
|
270 | return content | |
271 |
|
271 | |||
272 |
except (error.LookupError, error.RepoLookupError) |
|
272 | except (error.LookupError, error.RepoLookupError) as err: | |
273 | req.respond(HTTP_NOT_FOUND, ctype) |
|
273 | req.respond(HTTP_NOT_FOUND, ctype) | |
274 | msg = str(err) |
|
274 | msg = str(err) | |
275 | if (util.safehasattr(err, 'name') and |
|
275 | if (util.safehasattr(err, 'name') and | |
276 | not isinstance(err, error.ManifestLookupError)): |
|
276 | not isinstance(err, error.ManifestLookupError)): | |
277 | msg = 'revision not found: %s' % err.name |
|
277 | msg = 'revision not found: %s' % err.name | |
278 | return tmpl('error', error=msg) |
|
278 | return tmpl('error', error=msg) | |
279 |
except (error.RepoError, error.RevlogError) |
|
279 | except (error.RepoError, error.RevlogError) as inst: | |
280 | req.respond(HTTP_SERVER_ERROR, ctype) |
|
280 | req.respond(HTTP_SERVER_ERROR, ctype) | |
281 | return tmpl('error', error=str(inst)) |
|
281 | return tmpl('error', error=str(inst)) | |
282 |
except ErrorResponse |
|
282 | except ErrorResponse as inst: | |
283 | req.respond(inst, ctype) |
|
283 | req.respond(inst, ctype) | |
284 | if inst.code == HTTP_NOT_MODIFIED: |
|
284 | if inst.code == HTTP_NOT_MODIFIED: | |
285 | # Not allowed to return a body on a 304 |
|
285 | # Not allowed to return a body on a 304 |
@@ -219,10 +219,10 b' class hgwebdir(object):' | |||||
219 | # ensure caller gets private copy of ui |
|
219 | # ensure caller gets private copy of ui | |
220 | repo = hg.repository(self.ui.copy(), real) |
|
220 | repo = hg.repository(self.ui.copy(), real) | |
221 | return hgweb(repo).run_wsgi(req) |
|
221 | return hgweb(repo).run_wsgi(req) | |
222 |
except IOError |
|
222 | except IOError as inst: | |
223 | msg = inst.strerror |
|
223 | msg = inst.strerror | |
224 | raise ErrorResponse(HTTP_SERVER_ERROR, msg) |
|
224 | raise ErrorResponse(HTTP_SERVER_ERROR, msg) | |
225 |
except error.RepoError |
|
225 | except error.RepoError as inst: | |
226 | raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) |
|
226 | raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) | |
227 |
|
227 | |||
228 | up = virtualrepo.rfind('/') |
|
228 | up = virtualrepo.rfind('/') | |
@@ -240,7 +240,7 b' class hgwebdir(object):' | |||||
240 | req.respond(HTTP_NOT_FOUND, ctype) |
|
240 | req.respond(HTTP_NOT_FOUND, ctype) | |
241 | return tmpl("notfound", repo=virtual) |
|
241 | return tmpl("notfound", repo=virtual) | |
242 |
|
242 | |||
243 |
except ErrorResponse |
|
243 | except ErrorResponse as err: | |
244 | req.respond(err, ctype) |
|
244 | req.respond(err, ctype) | |
245 | return tmpl('error', error=err.message or '') |
|
245 | return tmpl('error', error=err.message or '') | |
246 | finally: |
|
246 | finally: | |
@@ -336,7 +336,7 b' class hgwebdir(object):' | |||||
336 | u = self.ui.copy() |
|
336 | u = self.ui.copy() | |
337 | try: |
|
337 | try: | |
338 | u.readconfig(os.path.join(path, '.hg', 'hgrc')) |
|
338 | u.readconfig(os.path.join(path, '.hg', 'hgrc')) | |
339 |
except Exception |
|
339 | except Exception as e: | |
340 | u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e)) |
|
340 | u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e)) | |
341 | continue |
|
341 | continue | |
342 | def get(section, name, default=None): |
|
342 | def get(section, name, default=None): |
@@ -111,7 +111,7 b' class wsgirequest(object):' | |||||
111 | if thing: |
|
111 | if thing: | |
112 | try: |
|
112 | try: | |
113 | self.server_write(thing) |
|
113 | self.server_write(thing) | |
114 |
except socket.error |
|
114 | except socket.error as inst: | |
115 | if inst[0] != errno.ECONNRESET: |
|
115 | if inst[0] != errno.ECONNRESET: | |
116 | raise |
|
116 | raise | |
117 |
|
117 |
@@ -71,7 +71,7 b' class _httprequesthandler(BaseHTTPServer' | |||||
71 | def do_write(self): |
|
71 | def do_write(self): | |
72 | try: |
|
72 | try: | |
73 | self.do_hgweb() |
|
73 | self.do_hgweb() | |
74 |
except socket.error |
|
74 | except socket.error as inst: | |
75 | if inst[0] != errno.EPIPE: |
|
75 | if inst[0] != errno.EPIPE: | |
76 | raise |
|
76 | raise | |
77 |
|
77 | |||
@@ -226,7 +226,7 b' class _httprequesthandleropenssl(_httpre' | |||||
226 | import OpenSSL |
|
226 | import OpenSSL | |
227 | try: |
|
227 | try: | |
228 | _httprequesthandler.do_write(self) |
|
228 | _httprequesthandler.do_write(self) | |
229 |
except OpenSSL.SSL.SysCallError |
|
229 | except OpenSSL.SSL.SysCallError as inst: | |
230 | if inst.args[0] != errno.EPIPE: |
|
230 | if inst.args[0] != errno.EPIPE: | |
231 | raise |
|
231 | raise | |
232 |
|
232 | |||
@@ -344,6 +344,6 b' def create_server(ui, app):' | |||||
344 | port = util.getport(ui.config('web', 'port', 8000)) |
|
344 | port = util.getport(ui.config('web', 'port', 8000)) | |
345 | try: |
|
345 | try: | |
346 | return cls(ui, app, (address, port), handler) |
|
346 | return cls(ui, app, (address, port), handler) | |
347 |
except socket.error |
|
347 | except socket.error as inst: | |
348 | raise util.Abort(_("cannot start server at '%s:%d': %s") |
|
348 | raise util.Abort(_("cannot start server at '%s:%d': %s") | |
349 | % (address, port, inst.args[1])) |
|
349 | % (address, port, inst.args[1])) |
@@ -76,7 +76,7 b' def rawfile(web, req, tmpl):' | |||||
76 |
|
76 | |||
77 | try: |
|
77 | try: | |
78 | fctx = webutil.filectx(web.repo, req) |
|
78 | fctx = webutil.filectx(web.repo, req) | |
79 |
except error.LookupError |
|
79 | except error.LookupError as inst: | |
80 | try: |
|
80 | try: | |
81 | content = manifest(web, req, tmpl) |
|
81 | content = manifest(web, req, tmpl) | |
82 | req.respond(HTTP_OK, web.ctype) |
|
82 | req.respond(HTTP_OK, web.ctype) | |
@@ -160,7 +160,7 b' def file(web, req, tmpl):' | |||||
160 | return manifest(web, req, tmpl) |
|
160 | return manifest(web, req, tmpl) | |
161 | try: |
|
161 | try: | |
162 | return _filerevision(web, req, tmpl, webutil.filectx(web.repo, req)) |
|
162 | return _filerevision(web, req, tmpl, webutil.filectx(web.repo, req)) | |
163 |
except error.LookupError |
|
163 | except error.LookupError as inst: | |
164 | try: |
|
164 | try: | |
165 | return manifest(web, req, tmpl) |
|
165 | return manifest(web, req, tmpl) | |
166 | except ErrorResponse: |
|
166 | except ErrorResponse: |
@@ -80,7 +80,7 b' def _pythonhook(ui, repo, name, hname, f' | |||||
80 | sys.stdout, sys.stderr, sys.stdin = ui.fout, ui.ferr, ui.fin |
|
80 | sys.stdout, sys.stderr, sys.stdin = ui.fout, ui.ferr, ui.fin | |
81 |
|
81 | |||
82 | r = obj(ui=ui, repo=repo, hooktype=name, **args) |
|
82 | r = obj(ui=ui, repo=repo, hooktype=name, **args) | |
83 |
except Exception |
|
83 | except Exception as exc: | |
84 | if isinstance(exc, util.Abort): |
|
84 | if isinstance(exc, util.Abort): | |
85 | ui.warn(_('error: %s hook failed: %s\n') % |
|
85 | ui.warn(_('error: %s hook failed: %s\n') % | |
86 | (hname, exc.args[0])) |
|
86 | (hname, exc.args[0])) |
@@ -166,7 +166,7 b' class HTTPResponse(object):' | |||||
166 | raise HTTPTimeoutException('timeout reading data') |
|
166 | raise HTTPTimeoutException('timeout reading data') | |
167 | try: |
|
167 | try: | |
168 | data = self.sock.recv(INCOMING_BUFFER_SIZE) |
|
168 | data = self.sock.recv(INCOMING_BUFFER_SIZE) | |
169 |
except socket.sslerror |
|
169 | except socket.sslerror as e: | |
170 | if e.args[0] != socket.SSL_ERROR_WANT_READ: |
|
170 | if e.args[0] != socket.SSL_ERROR_WANT_READ: | |
171 | raise |
|
171 | raise | |
172 | logger.debug('SSL_ERROR_WANT_READ in _select, should retry later') |
|
172 | logger.debug('SSL_ERROR_WANT_READ in _select, should retry later') | |
@@ -555,7 +555,7 b' class HTTPConnection(object):' | |||||
555 | try: |
|
555 | try: | |
556 | try: |
|
556 | try: | |
557 | data = r[0].recv(INCOMING_BUFFER_SIZE) |
|
557 | data = r[0].recv(INCOMING_BUFFER_SIZE) | |
558 |
except socket.sslerror |
|
558 | except socket.sslerror as e: | |
559 | if e.args[0] != socket.SSL_ERROR_WANT_READ: |
|
559 | if e.args[0] != socket.SSL_ERROR_WANT_READ: | |
560 | raise |
|
560 | raise | |
561 | logger.debug('SSL_ERROR_WANT_READ while sending ' |
|
561 | logger.debug('SSL_ERROR_WANT_READ while sending ' | |
@@ -610,7 +610,7 b' class HTTPConnection(object):' | |||||
610 | # Jump to the next select() call so we load more |
|
610 | # Jump to the next select() call so we load more | |
611 | # data if the server is still sending us content. |
|
611 | # data if the server is still sending us content. | |
612 | continue |
|
612 | continue | |
613 |
except socket.error |
|
613 | except socket.error as e: | |
614 | if e[0] != errno.EPIPE and not was_first: |
|
614 | if e[0] != errno.EPIPE and not was_first: | |
615 | raise |
|
615 | raise | |
616 |
|
616 | |||
@@ -633,7 +633,7 b' class HTTPConnection(object):' | |||||
633 | else: |
|
633 | else: | |
634 | out = data |
|
634 | out = data | |
635 | amt = w[0].send(out) |
|
635 | amt = w[0].send(out) | |
636 |
except socket.error |
|
636 | except socket.error as e: | |
637 | if e[0] == socket.SSL_ERROR_WANT_WRITE and self.ssl: |
|
637 | if e[0] == socket.SSL_ERROR_WANT_WRITE and self.ssl: | |
638 | # This means that SSL hasn't flushed its buffer into |
|
638 | # This means that SSL hasn't flushed its buffer into | |
639 | # the socket yet. |
|
639 | # the socket yet. |
@@ -64,7 +64,7 b' except AttributeError:' | |||||
64 | sock = socket.socket(af, socktype, proto) |
|
64 | sock = socket.socket(af, socktype, proto) | |
65 | logger.info("connect: (%s, %s)", host, port) |
|
65 | logger.info("connect: (%s, %s)", host, port) | |
66 | sock.connect(sa) |
|
66 | sock.connect(sa) | |
67 |
except socket.error |
|
67 | except socket.error as msg: | |
68 | logger.info('connect fail: %s %s', host, port) |
|
68 | logger.info('connect fail: %s %s', host, port) | |
69 | if sock: |
|
69 | if sock: | |
70 | sock.close() |
|
70 | sock.close() | |
@@ -100,7 +100,7 b' else:' | |||||
100 | while True: |
|
100 | while True: | |
101 | try: |
|
101 | try: | |
102 | return self._ssl.read(buflen) |
|
102 | return self._ssl.read(buflen) | |
103 |
except socket.sslerror |
|
103 | except socket.sslerror as x: | |
104 | if x.args[0] == socket.SSL_ERROR_WANT_READ: |
|
104 | if x.args[0] == socket.SSL_ERROR_WANT_READ: | |
105 | continue |
|
105 | continue | |
106 | else: |
|
106 | else: |
@@ -211,7 +211,7 b' class http2handler(urllib2.HTTPHandler, ' | |||||
211 | path = '/' + path |
|
211 | path = '/' + path | |
212 | h.request(req.get_method(), path, req.data, headers) |
|
212 | h.request(req.get_method(), path, req.data, headers) | |
213 | r = h.getresponse() |
|
213 | r = h.getresponse() | |
214 |
except socket.error |
|
214 | except socket.error as err: # XXX what error? | |
215 | raise urllib2.URLError(err) |
|
215 | raise urllib2.URLError(err) | |
216 |
|
216 | |||
217 | # Pick apart the HTTPResponse object to get the addinfourl |
|
217 | # Pick apart the HTTPResponse object to get the addinfourl |
@@ -119,11 +119,11 b' class httppeer(wireproto.wirepeer):' | |||||
119 | req.add_unredirected_header('Content-Length', '%d' % size) |
|
119 | req.add_unredirected_header('Content-Length', '%d' % size) | |
120 | try: |
|
120 | try: | |
121 | resp = self.urlopener.open(req) |
|
121 | resp = self.urlopener.open(req) | |
122 |
except urllib2.HTTPError |
|
122 | except urllib2.HTTPError as inst: | |
123 | if inst.code == 401: |
|
123 | if inst.code == 401: | |
124 | raise util.Abort(_('authorization failed')) |
|
124 | raise util.Abort(_('authorization failed')) | |
125 | raise |
|
125 | raise | |
126 |
except httplib.HTTPException |
|
126 | except httplib.HTTPException as inst: | |
127 | self.ui.debug('http error while sending %s command\n' % cmd) |
|
127 | self.ui.debug('http error while sending %s command\n' % cmd) | |
128 | self.ui.traceback() |
|
128 | self.ui.traceback() | |
129 | raise IOError(None, inst) |
|
129 | raise IOError(None, inst) | |
@@ -205,7 +205,7 b' class httppeer(wireproto.wirepeer):' | |||||
205 | if len(vals) < 2: |
|
205 | if len(vals) < 2: | |
206 | raise error.ResponseError(_("unexpected response:"), r) |
|
206 | raise error.ResponseError(_("unexpected response:"), r) | |
207 | return vals |
|
207 | return vals | |
208 |
except socket.error |
|
208 | except socket.error as err: | |
209 | if err.args[0] in (errno.ECONNRESET, errno.EPIPE): |
|
209 | if err.args[0] in (errno.ECONNRESET, errno.EPIPE): | |
210 | raise util.Abort(_('push failed: %s') % err.args[1]) |
|
210 | raise util.Abort(_('push failed: %s') % err.args[1]) | |
211 | raise util.Abort(err.args[1]) |
|
211 | raise util.Abort(err.args[1]) | |
@@ -267,7 +267,7 b' def instance(ui, path, create):' | |||||
267 | # No luck, try older compatibility check. |
|
267 | # No luck, try older compatibility check. | |
268 | inst.between([(nullid, nullid)]) |
|
268 | inst.between([(nullid, nullid)]) | |
269 | return inst |
|
269 | return inst | |
270 |
except error.RepoError |
|
270 | except error.RepoError as httpexception: | |
271 | try: |
|
271 | try: | |
272 | r = statichttprepo.instance(ui, "static-" + path, create) |
|
272 | r = statichttprepo.instance(ui, "static-" + path, create) | |
273 | ui.note('(falling back to static-http)\n') |
|
273 | ui.note('(falling back to static-http)\n') |
@@ -251,7 +251,7 b' class KeepAliveHandler(object):' | |||||
251 | self._cm.add(host, h, 0) |
|
251 | self._cm.add(host, h, 0) | |
252 | self._start_transaction(h, req) |
|
252 | self._start_transaction(h, req) | |
253 | r = h.getresponse() |
|
253 | r = h.getresponse() | |
254 |
except (socket.error, httplib.HTTPException) |
|
254 | except (socket.error, httplib.HTTPException) as err: | |
255 | raise urllib2.URLError(err) |
|
255 | raise urllib2.URLError(err) | |
256 |
|
256 | |||
257 | # if not a persistent connection, don't try to reuse it |
|
257 | # if not a persistent connection, don't try to reuse it | |
@@ -343,7 +343,7 b' class KeepAliveHandler(object):' | |||||
343 | h.putheader('Content-length', '%d' % len(data)) |
|
343 | h.putheader('Content-length', '%d' % len(data)) | |
344 | else: |
|
344 | else: | |
345 | h.putrequest('GET', req.get_selector(), **skipheaders) |
|
345 | h.putrequest('GET', req.get_selector(), **skipheaders) | |
346 |
except (socket.error) |
|
346 | except (socket.error) as err: | |
347 | raise urllib2.URLError(err) |
|
347 | raise urllib2.URLError(err) | |
348 | for k, v in headers.items(): |
|
348 | for k, v in headers.items(): | |
349 | h.putheader(k, v) |
|
349 | h.putheader(k, v) | |
@@ -550,7 +550,7 b' def safesend(self, str):' | |||||
550 | data = read(blocksize) |
|
550 | data = read(blocksize) | |
551 | else: |
|
551 | else: | |
552 | self.sock.sendall(str) |
|
552 | self.sock.sendall(str) | |
553 |
except socket.error |
|
553 | except socket.error as v: | |
554 | reraise = True |
|
554 | reraise = True | |
555 | if v[0] == errno.EPIPE: # Broken pipe |
|
555 | if v[0] == errno.EPIPE: # Broken pipe | |
556 | if self._HTTPConnection__state == httplib._CS_REQ_SENT: |
|
556 | if self._HTTPConnection__state == httplib._CS_REQ_SENT: | |
@@ -605,7 +605,7 b' def error_handler(url):' | |||||
605 | status, reason = fo.status, fo.reason |
|
605 | status, reason = fo.status, fo.reason | |
606 | except AttributeError: |
|
606 | except AttributeError: | |
607 | status, reason = None, None |
|
607 | status, reason = None, None | |
608 |
except IOError |
|
608 | except IOError as e: | |
609 | print " EXCEPTION: %s" % e |
|
609 | print " EXCEPTION: %s" % e | |
610 | raise |
|
610 | raise | |
611 | else: |
|
611 | else: |
@@ -135,7 +135,7 b' class localpeer(peer.peerrepository):' | |||||
135 | stream = util.chunkbuffer(ret.getchunks()) |
|
135 | stream = util.chunkbuffer(ret.getchunks()) | |
136 | ret = bundle2.getunbundler(self.ui, stream) |
|
136 | ret = bundle2.getunbundler(self.ui, stream) | |
137 | return ret |
|
137 | return ret | |
138 |
except Exception |
|
138 | except Exception as exc: | |
139 | # If the exception contains output salvaged from a bundle2 |
|
139 | # If the exception contains output salvaged from a bundle2 | |
140 | # reply, we need to make sure it is printed before continuing |
|
140 | # reply, we need to make sure it is printed before continuing | |
141 | # to fail. So we build a bundle2 with such output and consume |
|
141 | # to fail. So we build a bundle2 with such output and consume | |
@@ -152,7 +152,7 b' class localpeer(peer.peerrepository):' | |||||
152 | b = bundle2.getunbundler(self.ui, stream) |
|
152 | b = bundle2.getunbundler(self.ui, stream) | |
153 | bundle2.processbundle(self._repo, b) |
|
153 | bundle2.processbundle(self._repo, b) | |
154 | raise |
|
154 | raise | |
155 |
except error.PushRaced |
|
155 | except error.PushRaced as exc: | |
156 | raise error.ResponseError(_('push failed:'), str(exc)) |
|
156 | raise error.ResponseError(_('push failed:'), str(exc)) | |
157 |
|
157 | |||
158 | def lock(self): |
|
158 | def lock(self): | |
@@ -272,7 +272,7 b' class localrepository(object):' | |||||
272 | try: |
|
272 | try: | |
273 | self.requirements = scmutil.readrequires( |
|
273 | self.requirements = scmutil.readrequires( | |
274 | self.vfs, self.supported) |
|
274 | self.vfs, self.supported) | |
275 |
except IOError |
|
275 | except IOError as inst: | |
276 | if inst.errno != errno.ENOENT: |
|
276 | if inst.errno != errno.ENOENT: | |
277 | raise |
|
277 | raise | |
278 |
|
278 | |||
@@ -285,7 +285,7 b' class localrepository(object):' | |||||
285 | raise error.RepoError( |
|
285 | raise error.RepoError( | |
286 | _('.hg/sharedpath points to nonexistent directory %s') % s) |
|
286 | _('.hg/sharedpath points to nonexistent directory %s') % s) | |
287 | self.sharedpath = s |
|
287 | self.sharedpath = s | |
288 |
except IOError |
|
288 | except IOError as inst: | |
289 | if inst.errno != errno.ENOENT: |
|
289 | if inst.errno != errno.ENOENT: | |
290 | raise |
|
290 | raise | |
291 |
|
291 | |||
@@ -578,7 +578,7 b' class localrepository(object):' | |||||
578 |
|
578 | |||
579 | try: |
|
579 | try: | |
580 | fp = self.wfile('.hgtags', 'rb+') |
|
580 | fp = self.wfile('.hgtags', 'rb+') | |
581 |
except IOError |
|
581 | except IOError as e: | |
582 | if e.errno != errno.ENOENT: |
|
582 | if e.errno != errno.ENOENT: | |
583 | raise |
|
583 | raise | |
584 | fp = self.wfile('.hgtags', 'ab') |
|
584 | fp = self.wfile('.hgtags', 'ab') | |
@@ -1189,7 +1189,7 b' class localrepository(object):' | |||||
1189 | def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc): |
|
1189 | def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc): | |
1190 | try: |
|
1190 | try: | |
1191 | l = lockmod.lock(vfs, lockname, 0, releasefn, desc=desc) |
|
1191 | l = lockmod.lock(vfs, lockname, 0, releasefn, desc=desc) | |
1192 |
except error.LockHeld |
|
1192 | except error.LockHeld as inst: | |
1193 | if not wait: |
|
1193 | if not wait: | |
1194 | raise |
|
1194 | raise | |
1195 | self.ui.warn(_("waiting for lock on %s held by %r\n") % |
|
1195 | self.ui.warn(_("waiting for lock on %s held by %r\n") % | |
@@ -1570,10 +1570,10 b' class localrepository(object):' | |||||
1570 | m[f] = self._filecommit(fctx, m1, m2, linkrev, |
|
1570 | m[f] = self._filecommit(fctx, m1, m2, linkrev, | |
1571 | trp, changed) |
|
1571 | trp, changed) | |
1572 | m.setflag(f, fctx.flags()) |
|
1572 | m.setflag(f, fctx.flags()) | |
1573 |
except OSError |
|
1573 | except OSError as inst: | |
1574 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
1574 | self.ui.warn(_("trouble committing %s!\n") % f) | |
1575 | raise |
|
1575 | raise | |
1576 |
except IOError |
|
1576 | except IOError as inst: | |
1577 | errcode = getattr(inst, 'errno', errno.ENOENT) |
|
1577 | errcode = getattr(inst, 'errno', errno.ENOENT) | |
1578 | if error or errcode and errcode != errno.ENOENT: |
|
1578 | if error or errcode and errcode != errno.ENOENT: | |
1579 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
1579 | self.ui.warn(_("trouble committing %s!\n") % f) | |
@@ -1888,7 +1888,7 b' class localrepository(object):' | |||||
1888 | hookargs['old'] = old |
|
1888 | hookargs['old'] = old | |
1889 | hookargs['new'] = new |
|
1889 | hookargs['new'] = new | |
1890 | self.hook('prepushkey', throw=True, **hookargs) |
|
1890 | self.hook('prepushkey', throw=True, **hookargs) | |
1891 |
except error.HookAbort |
|
1891 | except error.HookAbort as exc: | |
1892 | self.ui.write_err(_("pushkey-abort: %s\n") % exc) |
|
1892 | self.ui.write_err(_("pushkey-abort: %s\n") % exc) | |
1893 | if exc.hint: |
|
1893 | if exc.hint: | |
1894 | self.ui.write_err(_("(%s)\n") % exc.hint) |
|
1894 | self.ui.write_err(_("(%s)\n") % exc.hint) |
@@ -58,7 +58,7 b' class lock(object):' | |||||
58 | try: |
|
58 | try: | |
59 | self.trylock() |
|
59 | self.trylock() | |
60 | return self.timeout - timeout |
|
60 | return self.timeout - timeout | |
61 |
except error.LockHeld |
|
61 | except error.LockHeld as inst: | |
62 | if timeout != 0: |
|
62 | if timeout != 0: | |
63 | time.sleep(1) |
|
63 | time.sleep(1) | |
64 | if timeout > 0: |
|
64 | if timeout > 0: | |
@@ -78,7 +78,7 b' class lock(object):' | |||||
78 | try: |
|
78 | try: | |
79 | self.vfs.makelock(lockname, self.f) |
|
79 | self.vfs.makelock(lockname, self.f) | |
80 | self.held = 1 |
|
80 | self.held = 1 | |
81 |
except (OSError, IOError) |
|
81 | except (OSError, IOError) as why: | |
82 | if why.errno == errno.EEXIST: |
|
82 | if why.errno == errno.EEXIST: | |
83 | locker = self.testlock() |
|
83 | locker = self.testlock() | |
84 | if locker is not None: |
|
84 | if locker is not None: | |
@@ -102,7 +102,7 b' class lock(object):' | |||||
102 | """ |
|
102 | """ | |
103 | try: |
|
103 | try: | |
104 | locker = self.vfs.readlock(self.f) |
|
104 | locker = self.vfs.readlock(self.f) | |
105 |
except (OSError, IOError) |
|
105 | except (OSError, IOError) as why: | |
106 | if why.errno == errno.ENOENT: |
|
106 | if why.errno == errno.ENOENT: | |
107 | return None |
|
107 | return None | |
108 | raise |
|
108 | raise |
@@ -138,16 +138,16 b' def _smtp(ui):' | |||||
138 | (username)) |
|
138 | (username)) | |
139 | try: |
|
139 | try: | |
140 | s.login(username, password) |
|
140 | s.login(username, password) | |
141 |
except smtplib.SMTPException |
|
141 | except smtplib.SMTPException as inst: | |
142 | raise util.Abort(inst) |
|
142 | raise util.Abort(inst) | |
143 |
|
143 | |||
144 | def send(sender, recipients, msg): |
|
144 | def send(sender, recipients, msg): | |
145 | try: |
|
145 | try: | |
146 | return s.sendmail(sender, recipients, msg) |
|
146 | return s.sendmail(sender, recipients, msg) | |
147 |
except smtplib.SMTPRecipientsRefused |
|
147 | except smtplib.SMTPRecipientsRefused as inst: | |
148 | recipients = [r[1] for r in inst.recipients.values()] |
|
148 | recipients = [r[1] for r in inst.recipients.values()] | |
149 | raise util.Abort('\n' + '\n'.join(recipients)) |
|
149 | raise util.Abort('\n' + '\n'.join(recipients)) | |
150 |
except smtplib.SMTPException |
|
150 | except smtplib.SMTPException as inst: | |
151 | raise util.Abort(inst) |
|
151 | raise util.Abort(inst) | |
152 |
|
152 | |||
153 | return send |
|
153 | return send |
@@ -293,9 +293,9 b' class match(object):' | |||||
293 | for k, p, source in self._normalize(includepats, default, |
|
293 | for k, p, source in self._normalize(includepats, default, | |
294 | root, cwd, auditor): |
|
294 | root, cwd, auditor): | |
295 | kindpats.append((k, p, source or pat)) |
|
295 | kindpats.append((k, p, source or pat)) | |
296 |
except util.Abort |
|
296 | except util.Abort as inst: | |
297 | raise util.Abort('%s: %s' % (pat, inst[0])) |
|
297 | raise util.Abort('%s: %s' % (pat, inst[0])) | |
298 |
except IOError |
|
298 | except IOError as inst: | |
299 | if self._warn: |
|
299 | if self._warn: | |
300 | self._warn(_("skipping unreadable pattern file " |
|
300 | self._warn(_("skipping unreadable pattern file " | |
301 | "'%s': %s\n") % (pat, inst.strerror)) |
|
301 | "'%s': %s\n") % (pat, inst.strerror)) |
@@ -145,7 +145,7 b' class mergestate(object):' | |||||
145 | else: |
|
145 | else: | |
146 | records.append(('F', l[:-1])) |
|
146 | records.append(('F', l[:-1])) | |
147 | f.close() |
|
147 | f.close() | |
148 |
except IOError |
|
148 | except IOError as err: | |
149 | if err.errno != errno.ENOENT: |
|
149 | if err.errno != errno.ENOENT: | |
150 | raise |
|
150 | raise | |
151 | return records |
|
151 | return records | |
@@ -170,7 +170,7 b' class mergestate(object):' | |||||
170 | off += length |
|
170 | off += length | |
171 | records.append((rtype, record)) |
|
171 | records.append((rtype, record)) | |
172 | f.close() |
|
172 | f.close() | |
173 |
except IOError |
|
173 | except IOError as err: | |
174 | if err.errno != errno.ENOENT: |
|
174 | if err.errno != errno.ENOENT: | |
175 | raise |
|
175 | raise | |
176 | return records |
|
176 | return records | |
@@ -660,7 +660,7 b' def batchremove(repo, actions):' | |||||
660 | audit(f) |
|
660 | audit(f) | |
661 | try: |
|
661 | try: | |
662 | unlink(wjoin(f), ignoremissing=True) |
|
662 | unlink(wjoin(f), ignoremissing=True) | |
663 |
except OSError |
|
663 | except OSError as inst: | |
664 | repo.ui.warn(_("update failed to remove %s: %s!\n") % |
|
664 | repo.ui.warn(_("update failed to remove %s: %s!\n") % | |
665 | (f, inst.strerror)) |
|
665 | (f, inst.strerror)) | |
666 | if i == 100: |
|
666 | if i == 100: |
@@ -431,12 +431,12 b' class fsbackend(abstractbackend):' | |||||
431 | isexec = False |
|
431 | isexec = False | |
432 | try: |
|
432 | try: | |
433 | isexec = self.opener.lstat(fname).st_mode & 0o100 != 0 |
|
433 | isexec = self.opener.lstat(fname).st_mode & 0o100 != 0 | |
434 |
except OSError |
|
434 | except OSError as e: | |
435 | if e.errno != errno.ENOENT: |
|
435 | if e.errno != errno.ENOENT: | |
436 | raise |
|
436 | raise | |
437 | try: |
|
437 | try: | |
438 | return (self.opener.read(fname), (False, isexec)) |
|
438 | return (self.opener.read(fname), (False, isexec)) | |
439 |
except IOError |
|
439 | except IOError as e: | |
440 | if e.errno != errno.ENOENT: |
|
440 | if e.errno != errno.ENOENT: | |
441 | raise |
|
441 | raise | |
442 | return None, None |
|
442 | return None, None | |
@@ -1363,7 +1363,7 b' class binhunk(object):' | |||||
1363 | l = ord(l) - ord('a') + 27 |
|
1363 | l = ord(l) - ord('a') + 27 | |
1364 | try: |
|
1364 | try: | |
1365 | dec.append(base85.b85decode(line[1:])[:l]) |
|
1365 | dec.append(base85.b85decode(line[1:])[:l]) | |
1366 |
except ValueError |
|
1366 | except ValueError as e: | |
1367 | raise PatchError(_('could not decode "%s" binary patch: %s') |
|
1367 | raise PatchError(_('could not decode "%s" binary patch: %s') | |
1368 | % (self._fname, str(e))) |
|
1368 | % (self._fname, str(e))) | |
1369 | line = getline(lr, self.hunk) |
|
1369 | line = getline(lr, self.hunk) | |
@@ -1938,7 +1938,7 b' def _applydiff(ui, fp, patcher, backend,' | |||||
1938 | try: |
|
1938 | try: | |
1939 | current_file = patcher(ui, gp, backend, store, |
|
1939 | current_file = patcher(ui, gp, backend, store, | |
1940 | eolmode=eolmode) |
|
1940 | eolmode=eolmode) | |
1941 |
except PatchError |
|
1941 | except PatchError as inst: | |
1942 | ui.warn(str(inst) + '\n') |
|
1942 | ui.warn(str(inst) + '\n') | |
1943 | current_file = None |
|
1943 | current_file = None | |
1944 | rejects += 1 |
|
1944 | rejects += 1 |
@@ -76,7 +76,7 b' class pathauditor(object):' | |||||
76 | curpath = os.path.join(self.root, prefix) |
|
76 | curpath = os.path.join(self.root, prefix) | |
77 | try: |
|
77 | try: | |
78 | st = os.lstat(curpath) |
|
78 | st = os.lstat(curpath) | |
79 |
except OSError |
|
79 | except OSError as err: | |
80 | # EINVAL can be raised as invalid path syntax under win32. |
|
80 | # EINVAL can be raised as invalid path syntax under win32. | |
81 | # They must be ignored for patterns can be checked too. |
|
81 | # They must be ignored for patterns can be checked too. | |
82 | if err.errno not in (errno.ENOENT, errno.ENOTDIR, errno.EINVAL): |
|
82 | if err.errno not in (errno.ENOENT, errno.ENOTDIR, errno.EINVAL): |
@@ -129,7 +129,7 b' def _readroots(repo, phasedefaults=None)' | |||||
129 | if 'HG_PENDING' in os.environ: |
|
129 | if 'HG_PENDING' in os.environ: | |
130 | try: |
|
130 | try: | |
131 | f = repo.svfs('phaseroots.pending') |
|
131 | f = repo.svfs('phaseroots.pending') | |
132 |
except IOError |
|
132 | except IOError as inst: | |
133 | if inst.errno != errno.ENOENT: |
|
133 | if inst.errno != errno.ENOENT: | |
134 | raise |
|
134 | raise | |
135 | if f is None: |
|
135 | if f is None: | |
@@ -140,7 +140,7 b' def _readroots(repo, phasedefaults=None)' | |||||
140 | roots[int(phase)].add(bin(nh)) |
|
140 | roots[int(phase)].add(bin(nh)) | |
141 | finally: |
|
141 | finally: | |
142 | f.close() |
|
142 | f.close() | |
143 |
except IOError |
|
143 | except IOError as inst: | |
144 | if inst.errno != errno.ENOENT: |
|
144 | if inst.errno != errno.ENOENT: | |
145 | raise |
|
145 | raise | |
146 | if phasedefaults: |
|
146 | if phasedefaults: |
@@ -115,7 +115,7 b' def copymode(src, dst, mode=None):' | |||||
115 | using umask.''' |
|
115 | using umask.''' | |
116 | try: |
|
116 | try: | |
117 | st_mode = os.lstat(src).st_mode & 0o777 |
|
117 | st_mode = os.lstat(src).st_mode & 0o777 | |
118 |
except OSError |
|
118 | except OSError as inst: | |
119 | if inst.errno != errno.ENOENT: |
|
119 | if inst.errno != errno.ENOENT: | |
120 | raise |
|
120 | raise | |
121 | st_mode = mode |
|
121 | st_mode = mode | |
@@ -166,7 +166,7 b' def checklink(path):' | |||||
166 | fd.close() |
|
166 | fd.close() | |
167 | except AttributeError: |
|
167 | except AttributeError: | |
168 | return False |
|
168 | return False | |
169 |
except OSError |
|
169 | except OSError as inst: | |
170 | # sshfs might report failure while successfully creating the link |
|
170 | # sshfs might report failure while successfully creating the link | |
171 | if inst[0] == errno.EIO and os.path.exists(name): |
|
171 | if inst[0] == errno.EIO and os.path.exists(name): | |
172 | os.unlink(name) |
|
172 | os.unlink(name) | |
@@ -355,7 +355,7 b' def testpid(pid):' | |||||
355 | try: |
|
355 | try: | |
356 | os.kill(pid, 0) |
|
356 | os.kill(pid, 0) | |
357 | return True |
|
357 | return True | |
358 |
except OSError |
|
358 | except OSError as inst: | |
359 | return inst.errno != errno.ESRCH |
|
359 | return inst.errno != errno.ESRCH | |
360 |
|
360 | |||
361 | def explainexit(code): |
|
361 | def explainexit(code): | |
@@ -410,7 +410,7 b' def statfiles(files):' | |||||
410 | st = lstat(nf) |
|
410 | st = lstat(nf) | |
411 | if getkind(st.st_mode) not in _wantedkinds: |
|
411 | if getkind(st.st_mode) not in _wantedkinds: | |
412 | st = None |
|
412 | st = None | |
413 |
except OSError |
|
413 | except OSError as err: | |
414 | if err.errno not in (errno.ENOENT, errno.ENOTDIR): |
|
414 | if err.errno not in (errno.ENOENT, errno.ENOTDIR): | |
415 | raise |
|
415 | raise | |
416 | st = None |
|
416 | st = None | |
@@ -477,7 +477,7 b' def termwidth():' | |||||
477 | pass |
|
477 | pass | |
478 | except ValueError: |
|
478 | except ValueError: | |
479 | pass |
|
479 | pass | |
480 |
except IOError |
|
480 | except IOError as e: | |
481 | if e[0] == errno.EINVAL: |
|
481 | if e[0] == errno.EINVAL: | |
482 | pass |
|
482 | pass | |
483 | else: |
|
483 | else: | |
@@ -493,7 +493,7 b' def unlinkpath(f, ignoremissing=False):' | |||||
493 | """unlink and remove the directory if it is empty""" |
|
493 | """unlink and remove the directory if it is empty""" | |
494 | try: |
|
494 | try: | |
495 | os.unlink(f) |
|
495 | os.unlink(f) | |
496 |
except OSError |
|
496 | except OSError as e: | |
497 | if not (ignoremissing and e.errno == errno.ENOENT): |
|
497 | if not (ignoremissing and e.errno == errno.ENOENT): | |
498 | raise |
|
498 | raise | |
499 | # try removing directories that might now be empty |
|
499 | # try removing directories that might now be empty | |
@@ -560,7 +560,7 b' class unixdomainserver(socket.socket):' | |||||
560 | os.unlink(self.path) |
|
560 | os.unlink(self.path) | |
561 | try: |
|
561 | try: | |
562 | self.bind(self.realpath) |
|
562 | self.bind(self.realpath) | |
563 |
except socket.error |
|
563 | except socket.error as err: | |
564 | if err.args[0] == 'AF_UNIX path too long': |
|
564 | if err.args[0] == 'AF_UNIX path too long': | |
565 | tmpdir = tempfile.mkdtemp(prefix='hg-%s-' % subsystem) |
|
565 | tmpdir = tempfile.mkdtemp(prefix='hg-%s-' % subsystem) | |
566 | self.realpath = os.path.join(tmpdir, sockname) |
|
566 | self.realpath = os.path.join(tmpdir, sockname) | |
@@ -578,7 +578,7 b' class unixdomainserver(socket.socket):' | |||||
578 | def okayifmissing(f, path): |
|
578 | def okayifmissing(f, path): | |
579 | try: |
|
579 | try: | |
580 | f(path) |
|
580 | f(path) | |
581 |
except OSError |
|
581 | except OSError as err: | |
582 | if err.errno != errno.ENOENT: |
|
582 | if err.errno != errno.ENOENT: | |
583 | raise |
|
583 | raise | |
584 |
|
584 |
@@ -205,7 +205,7 b' def strip(ui, repo, nodelist, backup=Tru' | |||||
205 | for undovfs, undofile in repo.undofiles(): |
|
205 | for undovfs, undofile in repo.undofiles(): | |
206 | try: |
|
206 | try: | |
207 | undovfs.unlink(undofile) |
|
207 | undovfs.unlink(undofile) | |
208 |
except OSError |
|
208 | except OSError as e: | |
209 | if e.errno != errno.ENOENT: |
|
209 | if e.errno != errno.ENOENT: | |
210 | ui.warn(_('error removing %s: %s\n') % |
|
210 | ui.warn(_('error removing %s: %s\n') % | |
211 | (undovfs.join(undofile), str(e))) |
|
211 | (undovfs.join(undofile), str(e))) |
@@ -89,7 +89,7 b' def decompress(bin):' | |||||
89 | if t == 'x': |
|
89 | if t == 'x': | |
90 | try: |
|
90 | try: | |
91 | return _decompress(bin) |
|
91 | return _decompress(bin) | |
92 |
except zlib.error |
|
92 | except zlib.error as e: | |
93 | raise RevlogError(_("revlog decompress error: %s") % str(e)) |
|
93 | raise RevlogError(_("revlog decompress error: %s") % str(e)) | |
94 | if t == 'u': |
|
94 | if t == 'u': | |
95 | return bin[1:] |
|
95 | return bin[1:] | |
@@ -246,7 +246,7 b' class revlog(object):' | |||||
246 | if len(i) > 0: |
|
246 | if len(i) > 0: | |
247 | v = struct.unpack(versionformat, i[:4])[0] |
|
247 | v = struct.unpack(versionformat, i[:4])[0] | |
248 | self._initempty = False |
|
248 | self._initempty = False | |
249 |
except IOError |
|
249 | except IOError as inst: | |
250 | if inst.errno != errno.ENOENT: |
|
250 | if inst.errno != errno.ENOENT: | |
251 | raise |
|
251 | raise | |
252 |
|
252 | |||
@@ -1571,7 +1571,7 b' class revlog(object):' | |||||
1571 | actual = f.tell() |
|
1571 | actual = f.tell() | |
1572 | f.close() |
|
1572 | f.close() | |
1573 | dd = actual - expected |
|
1573 | dd = actual - expected | |
1574 |
except IOError |
|
1574 | except IOError as inst: | |
1575 | if inst.errno != errno.ENOENT: |
|
1575 | if inst.errno != errno.ENOENT: | |
1576 | raise |
|
1576 | raise | |
1577 | dd = 0 |
|
1577 | dd = 0 | |
@@ -1590,7 +1590,7 b' class revlog(object):' | |||||
1590 | databytes += max(0, self.length(r)) |
|
1590 | databytes += max(0, self.length(r)) | |
1591 | dd = 0 |
|
1591 | dd = 0 | |
1592 | di = actual - len(self) * s - databytes |
|
1592 | di = actual - len(self) * s - databytes | |
1593 |
except IOError |
|
1593 | except IOError as inst: | |
1594 | if inst.errno != errno.ENOENT: |
|
1594 | if inst.errno != errno.ENOENT: | |
1595 | raise |
|
1595 | raise | |
1596 | di = 0 |
|
1596 | di = 0 |
@@ -1019,7 +1019,7 b' def grep(repo, subset, x):' | |||||
1019 | try: |
|
1019 | try: | |
1020 | # i18n: "grep" is a keyword |
|
1020 | # i18n: "grep" is a keyword | |
1021 | gr = re.compile(getstring(x, _("grep requires a string"))) |
|
1021 | gr = re.compile(getstring(x, _("grep requires a string"))) | |
1022 |
except re.error |
|
1022 | except re.error as e: | |
1023 | raise error.ParseError(_('invalid match pattern: %s') % e) |
|
1023 | raise error.ParseError(_('invalid match pattern: %s') % e) | |
1024 |
|
1024 | |||
1025 | def matches(x): |
|
1025 | def matches(x): | |
@@ -1900,7 +1900,7 b' def _stringmatcher(pattern):' | |||||
1900 | pattern = pattern[3:] |
|
1900 | pattern = pattern[3:] | |
1901 | try: |
|
1901 | try: | |
1902 | regex = re.compile(pattern) |
|
1902 | regex = re.compile(pattern) | |
1903 |
except re.error |
|
1903 | except re.error as e: | |
1904 | raise error.ParseError(_('invalid regular expression: %s') |
|
1904 | raise error.ParseError(_('invalid regular expression: %s') | |
1905 | % e) |
|
1905 | % e) | |
1906 | return 're', pattern, regex.search |
|
1906 | return 're', pattern, regex.search | |
@@ -2416,7 +2416,7 b' def _parsealiasdecl(decl):' | |||||
2416 | return (name, ('func', ('symbol', name)), args, None) |
|
2416 | return (name, ('func', ('symbol', name)), args, None) | |
2417 |
|
2417 | |||
2418 | return (decl, None, None, _("invalid format")) |
|
2418 | return (decl, None, None, _("invalid format")) | |
2419 |
except error.ParseError |
|
2419 | except error.ParseError as inst: | |
2420 | return (decl, None, None, parseerrordetail(inst)) |
|
2420 | return (decl, None, None, parseerrordetail(inst)) | |
2421 |
|
2421 | |||
2422 | def _parsealiasdefn(defn, args): |
|
2422 | def _parsealiasdefn(defn, args): | |
@@ -2505,7 +2505,7 b' class revsetalias(object):' | |||||
2505 | self.replacement = _parsealiasdefn(value, self.args) |
|
2505 | self.replacement = _parsealiasdefn(value, self.args) | |
2506 | # Check for placeholder injection |
|
2506 | # Check for placeholder injection | |
2507 | _checkaliasarg(self.replacement, self.args) |
|
2507 | _checkaliasarg(self.replacement, self.args) | |
2508 |
except error.ParseError |
|
2508 | except error.ParseError as inst: | |
2509 | self.error = _('failed to parse the definition of revset alias' |
|
2509 | self.error = _('failed to parse the definition of revset alias' | |
2510 | ' "%s": %s') % (self.name, parseerrordetail(inst)) |
|
2510 | ' "%s": %s') % (self.name, parseerrordetail(inst)) | |
2511 |
|
2511 |
@@ -222,7 +222,7 b' class abstractvfs(object):' | |||||
222 | '''gracefully return an empty string for missing files''' |
|
222 | '''gracefully return an empty string for missing files''' | |
223 | try: |
|
223 | try: | |
224 | return self.read(path) |
|
224 | return self.read(path) | |
225 |
except IOError |
|
225 | except IOError as inst: | |
226 | if inst.errno != errno.ENOENT: |
|
226 | if inst.errno != errno.ENOENT: | |
227 | raise |
|
227 | raise | |
228 | return "" |
|
228 | return "" | |
@@ -231,7 +231,7 b' class abstractvfs(object):' | |||||
231 | '''gracefully return an empty array for missing files''' |
|
231 | '''gracefully return an empty array for missing files''' | |
232 | try: |
|
232 | try: | |
233 | return self.readlines(path, mode=mode) |
|
233 | return self.readlines(path, mode=mode) | |
234 |
except IOError |
|
234 | except IOError as inst: | |
235 | if inst.errno != errno.ENOENT: |
|
235 | if inst.errno != errno.ENOENT: | |
236 | raise |
|
236 | raise | |
237 | return [] |
|
237 | return [] | |
@@ -491,7 +491,7 b' class vfs(abstractvfs):' | |||||
491 | if nlink < 1: |
|
491 | if nlink < 1: | |
492 | nlink = 2 # force mktempcopy (issue1922) |
|
492 | nlink = 2 # force mktempcopy (issue1922) | |
493 | fd.close() |
|
493 | fd.close() | |
494 |
except (OSError, IOError) |
|
494 | except (OSError, IOError) as e: | |
495 | if e.errno != errno.ENOENT: |
|
495 | if e.errno != errno.ENOENT: | |
496 | raise |
|
496 | raise | |
497 | nlink = 0 |
|
497 | nlink = 0 | |
@@ -519,7 +519,7 b' class vfs(abstractvfs):' | |||||
519 | if self._cansymlink: |
|
519 | if self._cansymlink: | |
520 | try: |
|
520 | try: | |
521 | os.symlink(src, linkname) |
|
521 | os.symlink(src, linkname) | |
522 |
except OSError |
|
522 | except OSError as err: | |
523 | raise OSError(err.errno, _('could not symlink to %r: %s') % |
|
523 | raise OSError(err.errno, _('could not symlink to %r: %s') % | |
524 | (src, err.strerror), linkname) |
|
524 | (src, err.strerror), linkname) | |
525 | else: |
|
525 | else: | |
@@ -1058,7 +1058,7 b' class filecachesubentry(object):' | |||||
1058 | def stat(path): |
|
1058 | def stat(path): | |
1059 | try: |
|
1059 | try: | |
1060 | return util.cachestat(path) |
|
1060 | return util.cachestat(path) | |
1061 |
except OSError |
|
1061 | except OSError as e: | |
1062 | if e.errno != errno.ENOENT: |
|
1062 | if e.errno != errno.ENOENT: | |
1063 | raise |
|
1063 | raise | |
1064 |
|
1064 |
@@ -33,10 +33,10 b' class httprangereader(object):' | |||||
33 | f = self.opener.open(req) |
|
33 | f = self.opener.open(req) | |
34 | data = f.read() |
|
34 | data = f.read() | |
35 | code = f.code |
|
35 | code = f.code | |
36 |
except urllib2.HTTPError |
|
36 | except urllib2.HTTPError as inst: | |
37 | num = inst.code == 404 and errno.ENOENT or None |
|
37 | num = inst.code == 404 and errno.ENOENT or None | |
38 | raise IOError(num, inst) |
|
38 | raise IOError(num, inst) | |
39 |
except urllib2.URLError |
|
39 | except urllib2.URLError as inst: | |
40 | raise IOError(None, inst.reason[1]) |
|
40 | raise IOError(None, inst.reason[1]) | |
41 |
|
41 | |||
42 | if code == 200: |
|
42 | if code == 200: | |
@@ -106,7 +106,7 b' class statichttprepository(localrepo.loc' | |||||
106 |
|
106 | |||
107 | try: |
|
107 | try: | |
108 | requirements = scmutil.readrequires(self.vfs, self.supported) |
|
108 | requirements = scmutil.readrequires(self.vfs, self.supported) | |
109 |
except IOError |
|
109 | except IOError as inst: | |
110 | if inst.errno != errno.ENOENT: |
|
110 | if inst.errno != errno.ENOENT: | |
111 | raise |
|
111 | raise | |
112 | requirements = set() |
|
112 | requirements = set() | |
@@ -116,7 +116,7 b' class statichttprepository(localrepo.loc' | |||||
116 | fp = self.vfs("00changelog.i") |
|
116 | fp = self.vfs("00changelog.i") | |
117 | fp.read(1) |
|
117 | fp.read(1) | |
118 | fp.close() |
|
118 | fp.close() | |
119 |
except IOError |
|
119 | except IOError as inst: | |
120 | if inst.errno != errno.ENOENT: |
|
120 | if inst.errno != errno.ENOENT: | |
121 | raise |
|
121 | raise | |
122 | # we do not care about empty old-style repositories here |
|
122 | # we do not care about empty old-style repositories here |
@@ -489,7 +489,7 b' class fncachestore(basicstore):' | |||||
489 | ef = self.encode(f) |
|
489 | ef = self.encode(f) | |
490 | try: |
|
490 | try: | |
491 | yield f, ef, self.getsize(ef) |
|
491 | yield f, ef, self.getsize(ef) | |
492 |
except OSError |
|
492 | except OSError as err: | |
493 | if err.errno != errno.ENOENT: |
|
493 | if err.errno != errno.ENOENT: | |
494 | raise |
|
494 | raise | |
495 |
|
495 | |||
@@ -513,7 +513,7 b' class fncachestore(basicstore):' | |||||
513 | try: |
|
513 | try: | |
514 | self.getsize(ef) |
|
514 | self.getsize(ef) | |
515 | return True |
|
515 | return True | |
516 |
except OSError |
|
516 | except OSError as err: | |
517 | if err.errno != errno.ENOENT: |
|
517 | if err.errno != errno.ENOENT: | |
518 | raise |
|
518 | raise | |
519 | # nonexistent entry |
|
519 | # nonexistent entry |
@@ -44,10 +44,10 b' def annotatesubrepoerror(func):' | |||||
44 | def decoratedmethod(self, *args, **kargs): |
|
44 | def decoratedmethod(self, *args, **kargs): | |
45 | try: |
|
45 | try: | |
46 | res = func(self, *args, **kargs) |
|
46 | res = func(self, *args, **kargs) | |
47 |
except SubrepoAbort |
|
47 | except SubrepoAbort as ex: | |
48 | # This exception has already been handled |
|
48 | # This exception has already been handled | |
49 | raise ex |
|
49 | raise ex | |
50 |
except error.Abort |
|
50 | except error.Abort as ex: | |
51 | subrepo = subrelpath(self) |
|
51 | subrepo = subrelpath(self) | |
52 | errormsg = str(ex) + ' ' + _('(in subrepo %s)') % subrepo |
|
52 | errormsg = str(ex) + ' ' + _('(in subrepo %s)') % subrepo | |
53 | # avoid handling this exception by raising a SubrepoAbort exception |
|
53 | # avoid handling this exception by raising a SubrepoAbort exception | |
@@ -66,7 +66,7 b' def state(ctx, ui):' | |||||
66 | if f in ctx: |
|
66 | if f in ctx: | |
67 | try: |
|
67 | try: | |
68 | data = ctx[f].data() |
|
68 | data = ctx[f].data() | |
69 |
except IOError |
|
69 | except IOError as err: | |
70 | if err.errno != errno.ENOENT: |
|
70 | if err.errno != errno.ENOENT: | |
71 | raise |
|
71 | raise | |
72 | # handle missing subrepo spec files as removed |
|
72 | # handle missing subrepo spec files as removed | |
@@ -101,7 +101,7 b' def state(ctx, ui):' | |||||
101 | % (util.pathto(repo.root, repo.getcwd(), |
|
101 | % (util.pathto(repo.root, repo.getcwd(), | |
102 | '.hgsubstate'), (i + 1))) |
|
102 | '.hgsubstate'), (i + 1))) | |
103 | rev[path] = revision |
|
103 | rev[path] = revision | |
104 |
except IOError |
|
104 | except IOError as err: | |
105 | if err.errno != errno.ENOENT: |
|
105 | if err.errno != errno.ENOENT: | |
106 | raise |
|
106 | raise | |
107 |
|
107 | |||
@@ -116,7 +116,7 b' def state(ctx, ui):' | |||||
116 | repl = re.sub(r'\\\\([0-9]+)', r'\\\1', repl) |
|
116 | repl = re.sub(r'\\\\([0-9]+)', r'\\\1', repl) | |
117 | try: |
|
117 | try: | |
118 | src = re.sub(pattern, repl, src, 1) |
|
118 | src = re.sub(pattern, repl, src, 1) | |
119 |
except re.error |
|
119 | except re.error as e: | |
120 | raise util.Abort(_("bad subrepository pattern in %s: %s") |
|
120 | raise util.Abort(_("bad subrepository pattern in %s: %s") | |
121 | % (p.source('subpaths', pattern), e)) |
|
121 | % (p.source('subpaths', pattern), e)) | |
122 | return src |
|
122 | return src | |
@@ -734,7 +734,7 b' class hgsubrepo(abstractsubrepo):' | |||||
734 | ctx1 = self._repo[rev1] |
|
734 | ctx1 = self._repo[rev1] | |
735 | ctx2 = self._repo[rev2] |
|
735 | ctx2 = self._repo[rev2] | |
736 | return self._repo.status(ctx1, ctx2, **opts) |
|
736 | return self._repo.status(ctx1, ctx2, **opts) | |
737 |
except error.RepoLookupError |
|
737 | except error.RepoLookupError as inst: | |
738 | self.ui.warn(_('warning: error "%s" in subrepository "%s"\n') |
|
738 | self.ui.warn(_('warning: error "%s" in subrepository "%s"\n') | |
739 | % (inst, subrelpath(self))) |
|
739 | % (inst, subrelpath(self))) | |
740 | return scmutil.status([], [], [], [], [], [], []) |
|
740 | return scmutil.status([], [], [], [], [], [], []) | |
@@ -751,7 +751,7 b' class hgsubrepo(abstractsubrepo):' | |||||
751 | node1, node2, match, |
|
751 | node1, node2, match, | |
752 | prefix=posixpath.join(prefix, self._path), |
|
752 | prefix=posixpath.join(prefix, self._path), | |
753 | listsubrepos=True, **opts) |
|
753 | listsubrepos=True, **opts) | |
754 |
except error.RepoLookupError |
|
754 | except error.RepoLookupError as inst: | |
755 | self.ui.warn(_('warning: error "%s" in subrepository "%s"\n') |
|
755 | self.ui.warn(_('warning: error "%s" in subrepository "%s"\n') | |
756 | % (inst, subrelpath(self))) |
|
756 | % (inst, subrelpath(self))) | |
757 |
|
757 | |||
@@ -1280,7 +1280,7 b' class gitsubrepo(abstractsubrepo):' | |||||
1280 | try: |
|
1280 | try: | |
1281 | self._gitexecutable = 'git' |
|
1281 | self._gitexecutable = 'git' | |
1282 | out, err = self._gitnodir(['--version']) |
|
1282 | out, err = self._gitnodir(['--version']) | |
1283 |
except OSError |
|
1283 | except OSError as e: | |
1284 | if e.errno != 2 or os.name != 'nt': |
|
1284 | if e.errno != 2 or os.name != 'nt': | |
1285 | raise |
|
1285 | raise | |
1286 | self._gitexecutable = 'git.cmd' |
|
1286 | self._gitexecutable = 'git.cmd' |
@@ -120,7 +120,7 b' def readlocaltags(ui, repo, alltags, tag' | |||||
120 | '''Read local tags in repo. Update alltags and tagtypes.''' |
|
120 | '''Read local tags in repo. Update alltags and tagtypes.''' | |
121 | try: |
|
121 | try: | |
122 | data = repo.vfs.read("localtags") |
|
122 | data = repo.vfs.read("localtags") | |
123 |
except IOError |
|
123 | except IOError as inst: | |
124 | if inst.errno != errno.ENOENT: |
|
124 | if inst.errno != errno.ENOENT: | |
125 | raise |
|
125 | raise | |
126 | return |
|
126 | return | |
@@ -545,7 +545,7 b' class hgtagsfnodescache(object):' | |||||
545 | self._dirtyoffset = None |
|
545 | self._dirtyoffset = None | |
546 | finally: |
|
546 | finally: | |
547 | f.close() |
|
547 | f.close() | |
548 |
except (IOError, OSError) |
|
548 | except (IOError, OSError) as inst: | |
549 | repo.ui.log('tagscache', |
|
549 | repo.ui.log('tagscache', | |
550 | "couldn't write %s: %s\n" % ( |
|
550 | "couldn't write %s: %s\n" % ( | |
551 | _fnodescachefile, inst)) |
|
551 | _fnodescachefile, inst)) |
@@ -770,7 +770,7 b' class templater(object):' | |||||
770 | if val[0] in "'\"": |
|
770 | if val[0] in "'\"": | |
771 | try: |
|
771 | try: | |
772 | self.cache[key] = unquotestring(val) |
|
772 | self.cache[key] = unquotestring(val) | |
773 |
except SyntaxError |
|
773 | except SyntaxError as inst: | |
774 | raise SyntaxError('%s: %s' % |
|
774 | raise SyntaxError('%s: %s' % | |
775 | (conf.source('', key), inst.args[0])) |
|
775 | (conf.source('', key), inst.args[0])) | |
776 | else: |
|
776 | else: | |
@@ -787,10 +787,10 b' class templater(object):' | |||||
787 | if t not in self.cache: |
|
787 | if t not in self.cache: | |
788 | try: |
|
788 | try: | |
789 | self.cache[t] = util.readfile(self.map[t][1]) |
|
789 | self.cache[t] = util.readfile(self.map[t][1]) | |
790 |
except KeyError |
|
790 | except KeyError as inst: | |
791 | raise TemplateNotFound(_('"%s" not in template map') % |
|
791 | raise TemplateNotFound(_('"%s" not in template map') % | |
792 | inst.args[0]) |
|
792 | inst.args[0]) | |
793 |
except IOError |
|
793 | except IOError as inst: | |
794 | raise IOError(inst.args[0], _('template file %s: %s') % |
|
794 | raise IOError(inst.args[0], _('template file %s: %s') % | |
795 | (self.map[t][1], inst.args[1])) |
|
795 | (self.map[t][1], inst.args[1])) | |
796 | return self.cache[t] |
|
796 | return self.cache[t] |
@@ -39,7 +39,7 b' def _playback(journal, report, opener, v' | |||||
39 | else: |
|
39 | else: | |
40 | try: |
|
40 | try: | |
41 | opener.unlink(f) |
|
41 | opener.unlink(f) | |
42 |
except (IOError, OSError) |
|
42 | except (IOError, OSError) as inst: | |
43 | if inst.errno != errno.ENOENT: |
|
43 | if inst.errno != errno.ENOENT: | |
44 | raise |
|
44 | raise | |
45 |
|
45 | |||
@@ -62,10 +62,10 b' def _playback(journal, report, opener, v' | |||||
62 | target = f or b |
|
62 | target = f or b | |
63 | try: |
|
63 | try: | |
64 | vfs.unlink(target) |
|
64 | vfs.unlink(target) | |
65 |
except (IOError, OSError) |
|
65 | except (IOError, OSError) as inst: | |
66 | if inst.errno != errno.ENOENT: |
|
66 | if inst.errno != errno.ENOENT: | |
67 | raise |
|
67 | raise | |
68 |
except (IOError, OSError, util.Abort) |
|
68 | except (IOError, OSError, util.Abort) as inst: | |
69 | if not c: |
|
69 | if not c: | |
70 | raise |
|
70 | raise | |
71 |
|
71 | |||
@@ -77,7 +77,7 b' def _playback(journal, report, opener, v' | |||||
77 | for f in backupfiles: |
|
77 | for f in backupfiles: | |
78 | if opener.exists(f): |
|
78 | if opener.exists(f): | |
79 | opener.unlink(f) |
|
79 | opener.unlink(f) | |
80 |
except (IOError, OSError, util.Abort) |
|
80 | except (IOError, OSError, util.Abort) as inst: | |
81 | # only pure backup file remains, it is sage to ignore any error |
|
81 | # only pure backup file remains, it is sage to ignore any error | |
82 | pass |
|
82 | pass | |
83 |
|
83 | |||
@@ -405,7 +405,7 b' class transaction(object):' | |||||
405 | if not f and b and vfs.exists(b): |
|
405 | if not f and b and vfs.exists(b): | |
406 | try: |
|
406 | try: | |
407 | vfs.unlink(b) |
|
407 | vfs.unlink(b) | |
408 |
except (IOError, OSError, util.Abort) |
|
408 | except (IOError, OSError, util.Abort) as inst: | |
409 | if not c: |
|
409 | if not c: | |
410 | raise |
|
410 | raise | |
411 | # Abort may be raise by read only opener |
|
411 | # Abort may be raise by read only opener | |
@@ -428,7 +428,7 b' class transaction(object):' | |||||
428 | if b and vfs.exists(b): |
|
428 | if b and vfs.exists(b): | |
429 | try: |
|
429 | try: | |
430 | vfs.unlink(b) |
|
430 | vfs.unlink(b) | |
431 |
except (IOError, OSError, util.Abort) |
|
431 | except (IOError, OSError, util.Abort) as inst: | |
432 | if not c: |
|
432 | if not c: | |
433 | raise |
|
433 | raise | |
434 | # Abort may be raise by read only opener |
|
434 | # Abort may be raise by read only opener |
@@ -153,7 +153,7 b' class ui(object):' | |||||
153 | try: |
|
153 | try: | |
154 | cfg.read(filename, fp, sections=sections, remap=remap) |
|
154 | cfg.read(filename, fp, sections=sections, remap=remap) | |
155 | fp.close() |
|
155 | fp.close() | |
156 |
except error.ConfigError |
|
156 | except error.ConfigError as inst: | |
157 | if trusted: |
|
157 | if trusted: | |
158 | raise |
|
158 | raise | |
159 | self.warn(_("ignored: %s\n") % str(inst)) |
|
159 | self.warn(_("ignored: %s\n") % str(inst)) | |
@@ -605,7 +605,7 b' class ui(object):' | |||||
605 | # including stdout. |
|
605 | # including stdout. | |
606 | if not getattr(self.ferr, 'closed', False): |
|
606 | if not getattr(self.ferr, 'closed', False): | |
607 | self.ferr.flush() |
|
607 | self.ferr.flush() | |
608 |
except IOError |
|
608 | except IOError as inst: | |
609 | if inst.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): |
|
609 | if inst.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): | |
610 | raise |
|
610 | raise | |
611 |
|
611 |
@@ -159,7 +159,7 b' if has_https:' | |||||
159 | sock.connect(sa) |
|
159 | sock.connect(sa) | |
160 | return sock |
|
160 | return sock | |
161 |
|
161 | |||
162 |
except socket.error |
|
162 | except socket.error as msg: | |
163 | if sock is not None: |
|
163 | if sock is not None: | |
164 | sock.close() |
|
164 | sock.close() | |
165 |
|
165 | |||
@@ -411,7 +411,7 b' class httpdigestauthhandler(urllib2.HTTP' | |||||
411 | try: |
|
411 | try: | |
412 | return urllib2.HTTPDigestAuthHandler.http_error_auth_reqed( |
|
412 | return urllib2.HTTPDigestAuthHandler.http_error_auth_reqed( | |
413 | self, auth_header, host, req, headers) |
|
413 | self, auth_header, host, req, headers) | |
414 |
except ValueError |
|
414 | except ValueError as inst: | |
415 | arg = inst.args[0] |
|
415 | arg = inst.args[0] | |
416 | if arg.startswith("AbstractDigestAuthHandler doesn't know "): |
|
416 | if arg.startswith("AbstractDigestAuthHandler doesn't know "): | |
417 | return |
|
417 | return |
@@ -816,7 +816,7 b' def copyfile(src, dest, hardlink=False):' | |||||
816 | try: |
|
816 | try: | |
817 | shutil.copyfile(src, dest) |
|
817 | shutil.copyfile(src, dest) | |
818 | shutil.copymode(src, dest) |
|
818 | shutil.copymode(src, dest) | |
819 |
except shutil.Error |
|
819 | except shutil.Error as inst: | |
820 | raise Abort(str(inst)) |
|
820 | raise Abort(str(inst)) | |
821 |
|
821 | |||
822 | def copyfiles(src, dst, hardlink=None, progress=lambda t, pos: None): |
|
822 | def copyfiles(src, dst, hardlink=None, progress=lambda t, pos: None): | |
@@ -915,7 +915,7 b' else:' | |||||
915 | def makelock(info, pathname): |
|
915 | def makelock(info, pathname): | |
916 | try: |
|
916 | try: | |
917 | return os.symlink(info, pathname) |
|
917 | return os.symlink(info, pathname) | |
918 |
except OSError |
|
918 | except OSError as why: | |
919 | if why.errno == errno.EEXIST: |
|
919 | if why.errno == errno.EEXIST: | |
920 | raise |
|
920 | raise | |
921 | except AttributeError: # no symlink in os |
|
921 | except AttributeError: # no symlink in os | |
@@ -928,7 +928,7 b' def makelock(info, pathname):' | |||||
928 | def readlock(pathname): |
|
928 | def readlock(pathname): | |
929 | try: |
|
929 | try: | |
930 | return os.readlink(pathname) |
|
930 | return os.readlink(pathname) | |
931 |
except OSError |
|
931 | except OSError as why: | |
932 | if why.errno not in (errno.EINVAL, errno.ENOSYS): |
|
932 | if why.errno not in (errno.EINVAL, errno.ENOSYS): | |
933 | raise |
|
933 | raise | |
934 | except AttributeError: # no symlink in os |
|
934 | except AttributeError: # no symlink in os | |
@@ -1145,7 +1145,7 b' def mktempcopy(name, emptyok=False, crea' | |||||
1145 | try: |
|
1145 | try: | |
1146 | try: |
|
1146 | try: | |
1147 | ifp = posixfile(name, "rb") |
|
1147 | ifp = posixfile(name, "rb") | |
1148 |
except IOError |
|
1148 | except IOError as inst: | |
1149 | if inst.errno == errno.ENOENT: |
|
1149 | if inst.errno == errno.ENOENT: | |
1150 | return temp |
|
1150 | return temp | |
1151 | if not getattr(inst, 'filename', None): |
|
1151 | if not getattr(inst, 'filename', None): | |
@@ -1204,7 +1204,7 b' def makedirs(name, mode=None, notindexed' | |||||
1204 | """recursive directory creation with parent mode inheritance""" |
|
1204 | """recursive directory creation with parent mode inheritance""" | |
1205 | try: |
|
1205 | try: | |
1206 | makedir(name, notindexed) |
|
1206 | makedir(name, notindexed) | |
1207 |
except OSError |
|
1207 | except OSError as err: | |
1208 | if err.errno == errno.EEXIST: |
|
1208 | if err.errno == errno.EEXIST: | |
1209 | return |
|
1209 | return | |
1210 | if err.errno != errno.ENOENT or not name: |
|
1210 | if err.errno != errno.ENOENT or not name: | |
@@ -1231,7 +1231,7 b' def ensuredirs(name, mode=None, notindex' | |||||
1231 | ensuredirs(parent, mode, notindexed) |
|
1231 | ensuredirs(parent, mode, notindexed) | |
1232 | try: |
|
1232 | try: | |
1233 | makedir(name, notindexed) |
|
1233 | makedir(name, notindexed) | |
1234 |
except OSError |
|
1234 | except OSError as err: | |
1235 | if err.errno == errno.EEXIST and os.path.isdir(name): |
|
1235 | if err.errno == errno.EEXIST and os.path.isdir(name): | |
1236 | # someone else seems to have won a directory creation race |
|
1236 | # someone else seems to have won a directory creation race | |
1237 | return |
|
1237 | return |
@@ -108,7 +108,7 b' def _verify(repo):' | |||||
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 |
|
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: | |
@@ -144,7 +144,7 b' def _verify(repo):' | |||||
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 |
|
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) | |
@@ -171,7 +171,7 b' def _verify(repo):' | |||||
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 |
|
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 | |||
@@ -237,7 +237,7 b' def _verify(repo):' | |||||
237 |
|
237 | |||
238 | try: |
|
238 | try: | |
239 | fl = repo.file(f) |
|
239 | fl = repo.file(f) | |
240 |
except error.RevlogError |
|
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 | |||
@@ -272,7 +272,7 b' def _verify(repo):' | |||||
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 |
|
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 | |
@@ -298,7 +298,7 b' def _verify(repo):' | |||||
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 |
|
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 |
@@ -467,7 +467,7 b' def unlink(f):' | |||||
467 | try: |
|
467 | try: | |
468 | os.rename(f, temp) # raises OSError EEXIST if temp exists |
|
468 | os.rename(f, temp) # raises OSError EEXIST if temp exists | |
469 | break |
|
469 | break | |
470 |
except OSError |
|
470 | except OSError as e: | |
471 | if e.errno != errno.EEXIST: |
|
471 | if e.errno != errno.EEXIST: | |
472 | raise |
|
472 | raise | |
473 | else: |
|
473 | else: |
@@ -38,7 +38,7 b" def posixfile(name, mode='r', buffering=" | |||||
38 | fp.seek(0, os.SEEK_END) |
|
38 | fp.seek(0, os.SEEK_END) | |
39 |
|
39 | |||
40 | return fp |
|
40 | return fp | |
41 |
except WindowsError |
|
41 | except WindowsError as err: | |
42 | # convert to a friendlier exception |
|
42 | # convert to a friendlier exception | |
43 | raise IOError(err.errno, '%s: %s' % (name, err.strerror)) |
|
43 | raise IOError(err.errno, '%s: %s' % (name, err.strerror)) | |
44 |
|
44 | |||
@@ -69,7 +69,7 b' class winstdout(object):' | |||||
69 | end = start + limit |
|
69 | end = start + limit | |
70 | self.fp.write(s[start:end]) |
|
70 | self.fp.write(s[start:end]) | |
71 | start = end |
|
71 | start = end | |
72 |
except IOError |
|
72 | except IOError as inst: | |
73 | if inst.errno != 0: |
|
73 | if inst.errno != 0: | |
74 | raise |
|
74 | raise | |
75 | self.close() |
|
75 | self.close() | |
@@ -78,7 +78,7 b' class winstdout(object):' | |||||
78 | def flush(self): |
|
78 | def flush(self): | |
79 | try: |
|
79 | try: | |
80 | return self.fp.flush() |
|
80 | return self.fp.flush() | |
81 |
except IOError |
|
81 | except IOError as inst: | |
82 | if inst.errno != errno.EINVAL: |
|
82 | if inst.errno != errno.EINVAL: | |
83 | raise |
|
83 | raise | |
84 | self.close() |
|
84 | self.close() | |
@@ -259,7 +259,7 b' def statfiles(files):' | |||||
259 | dmap = dict([(normcase(n), s) |
|
259 | dmap = dict([(normcase(n), s) | |
260 | for n, k, s in osutil.listdir(dir, True) |
|
260 | for n, k, s in osutil.listdir(dir, True) | |
261 | if getkind(s.st_mode) in _wantedkinds]) |
|
261 | if getkind(s.st_mode) in _wantedkinds]) | |
262 |
except OSError |
|
262 | except OSError as err: | |
263 | # Python >= 2.5 returns ENOENT and adds winerror field |
|
263 | # Python >= 2.5 returns ENOENT and adds winerror field | |
264 | # EINVAL is raised if dir is not a directory. |
|
264 | # EINVAL is raised if dir is not a directory. | |
265 | if err.errno not in (errno.ENOENT, errno.EINVAL, |
|
265 | if err.errno not in (errno.ENOENT, errno.EINVAL, | |
@@ -303,7 +303,7 b' def unlinkpath(f, ignoremissing=False):' | |||||
303 | """unlink and remove the directory if it is empty""" |
|
303 | """unlink and remove the directory if it is empty""" | |
304 | try: |
|
304 | try: | |
305 | unlink(f) |
|
305 | unlink(f) | |
306 |
except OSError |
|
306 | except OSError as e: | |
307 | if not (ignoremissing and e.errno == errno.ENOENT): |
|
307 | if not (ignoremissing and e.errno == errno.ENOENT): | |
308 | raise |
|
308 | raise | |
309 | # try removing directories that might now be empty |
|
309 | # try removing directories that might now be empty | |
@@ -316,7 +316,7 b' def rename(src, dst):' | |||||
316 | '''atomically rename file src to dst, replacing dst if it exists''' |
|
316 | '''atomically rename file src to dst, replacing dst if it exists''' | |
317 | try: |
|
317 | try: | |
318 | os.rename(src, dst) |
|
318 | os.rename(src, dst) | |
319 |
except OSError |
|
319 | except OSError as e: | |
320 | if e.errno != errno.EEXIST: |
|
320 | if e.errno != errno.EEXIST: | |
321 | raise |
|
321 | raise | |
322 | unlink(dst) |
|
322 | unlink(dst) |
@@ -705,7 +705,7 b' def lookup(repo, proto, key):' | |||||
705 | c = repo[k] |
|
705 | c = repo[k] | |
706 | r = c.hex() |
|
706 | r = c.hex() | |
707 | success = 1 |
|
707 | success = 1 | |
708 |
except Exception |
|
708 | except Exception as inst: | |
709 | r = str(inst) |
|
709 | r = str(inst) | |
710 | success = 0 |
|
710 | success = 0 | |
711 | return "%s %s\n" % (success, r) |
|
711 | return "%s %s\n" % (success, r) | |
@@ -800,7 +800,7 b' def unbundle(repo, proto, heads):' | |||||
800 | fp.close() |
|
800 | fp.close() | |
801 | os.unlink(tempname) |
|
801 | os.unlink(tempname) | |
802 |
|
802 | |||
803 |
except (error.BundleValueError, util.Abort, error.PushRaced) |
|
803 | except (error.BundleValueError, util.Abort, error.PushRaced) as exc: | |
804 | # handle non-bundle2 case first |
|
804 | # handle non-bundle2 case first | |
805 | if not getattr(exc, 'duringunbundle2', False): |
|
805 | if not getattr(exc, 'duringunbundle2', False): | |
806 | try: |
|
806 | try: | |
@@ -821,7 +821,7 b' def unbundle(repo, proto, heads):' | |||||
821 | try: |
|
821 | try: | |
822 | try: |
|
822 | try: | |
823 | raise |
|
823 | raise | |
824 |
except error.PushkeyFailed |
|
824 | except error.PushkeyFailed as exc: | |
825 | # check client caps |
|
825 | # check client caps | |
826 | remotecaps = getattr(exc, '_replycaps', None) |
|
826 | remotecaps = getattr(exc, '_replycaps', None) | |
827 | if (remotecaps is not None |
|
827 | if (remotecaps is not None | |
@@ -840,19 +840,19 b' def unbundle(repo, proto, heads):' | |||||
840 | part.addparam('old', exc.old, mandatory=False) |
|
840 | part.addparam('old', exc.old, mandatory=False) | |
841 | if exc.ret is not None: |
|
841 | if exc.ret is not None: | |
842 | part.addparam('ret', exc.ret, mandatory=False) |
|
842 | part.addparam('ret', exc.ret, mandatory=False) | |
843 |
except error.BundleValueError |
|
843 | except error.BundleValueError as exc: | |
844 | errpart = bundler.newpart('error:unsupportedcontent') |
|
844 | errpart = bundler.newpart('error:unsupportedcontent') | |
845 | if exc.parttype is not None: |
|
845 | if exc.parttype is not None: | |
846 | errpart.addparam('parttype', exc.parttype) |
|
846 | errpart.addparam('parttype', exc.parttype) | |
847 | if exc.params: |
|
847 | if exc.params: | |
848 | errpart.addparam('params', '\0'.join(exc.params)) |
|
848 | errpart.addparam('params', '\0'.join(exc.params)) | |
849 |
except util.Abort |
|
849 | except util.Abort as exc: | |
850 | manargs = [('message', str(exc))] |
|
850 | manargs = [('message', str(exc))] | |
851 | advargs = [] |
|
851 | advargs = [] | |
852 | if exc.hint is not None: |
|
852 | if exc.hint is not None: | |
853 | advargs.append(('hint', exc.hint)) |
|
853 | advargs.append(('hint', exc.hint)) | |
854 | bundler.addpart(bundle2.bundlepart('error:abort', |
|
854 | bundler.addpart(bundle2.bundlepart('error:abort', | |
855 | manargs, advargs)) |
|
855 | manargs, advargs)) | |
856 |
except error.PushRaced |
|
856 | except error.PushRaced as exc: | |
857 | bundler.newpart('error:pushraced', [('message', str(exc))]) |
|
857 | bundler.newpart('error:pushraced', [('message', str(exc))]) | |
858 | return streamres(bundler.getchunks()) |
|
858 | return streamres(bundler.getchunks()) |
@@ -101,7 +101,7 b' def _posixworker(ui, func, staticargs, a' | |||||
101 | for p in pids: |
|
101 | for p in pids: | |
102 | try: |
|
102 | try: | |
103 | os.kill(p, signal.SIGTERM) |
|
103 | os.kill(p, signal.SIGTERM) | |
104 |
except OSError |
|
104 | except OSError as err: | |
105 | if err.errno != errno.ESRCH: |
|
105 | if err.errno != errno.ESRCH: | |
106 | raise |
|
106 | raise | |
107 | def waitforworkers(): |
|
107 | def waitforworkers(): |
@@ -23,7 +23,7 b' except ImportError:' | |||||
23 | for filename in sys.argv[1:]: |
|
23 | for filename in sys.argv[1:]: | |
24 | try: |
|
24 | try: | |
25 | fp = open(filename, 'rb') |
|
25 | fp = open(filename, 'rb') | |
26 |
except IOError |
|
26 | except IOError as msg: | |
27 | sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) |
|
27 | sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) | |
28 | sys.exit(1) |
|
28 | sys.exit(1) | |
29 |
|
29 | |||
@@ -34,7 +34,7 b' for filename in sys.argv[1:]:' | |||||
34 | if not data: |
|
34 | if not data: | |
35 | break |
|
35 | break | |
36 | m.update(data) |
|
36 | m.update(data) | |
37 |
except IOError |
|
37 | except IOError as msg: | |
38 | sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) |
|
38 | sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) | |
39 | sys.exit(1) |
|
39 | sys.exit(1) | |
40 | sys.stdout.write('%s %s\n' % (m.hexdigest(), filename)) |
|
40 | sys.stdout.write('%s %s\n' % (m.hexdigest(), filename)) |
@@ -5,7 +5,7 b' import errno, os, sys' | |||||
5 | for f in sys.argv[1:]: |
|
5 | for f in sys.argv[1:]: | |
6 | try: |
|
6 | try: | |
7 | print f, '->', os.readlink(f) |
|
7 | print f, '->', os.readlink(f) | |
8 |
except OSError |
|
8 | except OSError as err: | |
9 | if err.errno != errno.EINVAL: |
|
9 | if err.errno != errno.EINVAL: | |
10 | raise |
|
10 | raise | |
11 | print f, 'not a symlink' |
|
11 | print f, 'not a symlink' |
@@ -325,21 +325,21 b' class basemanifesttests(object):' | |||||
325 | try: |
|
325 | try: | |
326 | self.parsemanifest(backwards) |
|
326 | self.parsemanifest(backwards) | |
327 | self.fail('Should have raised ValueError') |
|
327 | self.fail('Should have raised ValueError') | |
328 |
except ValueError |
|
328 | except ValueError as v: | |
329 | self.assertIn('Manifest lines not in sorted order.', str(v)) |
|
329 | self.assertIn('Manifest lines not in sorted order.', str(v)) | |
330 |
|
330 | |||
331 | def testNoTerminalNewline(self): |
|
331 | def testNoTerminalNewline(self): | |
332 | try: |
|
332 | try: | |
333 | self.parsemanifest(A_SHORT_MANIFEST + 'wat') |
|
333 | self.parsemanifest(A_SHORT_MANIFEST + 'wat') | |
334 | self.fail('Should have raised ValueError') |
|
334 | self.fail('Should have raised ValueError') | |
335 |
except ValueError |
|
335 | except ValueError as v: | |
336 | self.assertIn('Manifest did not end in a newline.', str(v)) |
|
336 | self.assertIn('Manifest did not end in a newline.', str(v)) | |
337 |
|
337 | |||
338 | def testNoNewLineAtAll(self): |
|
338 | def testNoNewLineAtAll(self): | |
339 | try: |
|
339 | try: | |
340 | self.parsemanifest('wat') |
|
340 | self.parsemanifest('wat') | |
341 | self.fail('Should have raised ValueError') |
|
341 | self.fail('Should have raised ValueError') | |
342 |
except ValueError |
|
342 | except ValueError as v: | |
343 | self.assertIn('Manifest did not end in a newline.', str(v)) |
|
343 | self.assertIn('Manifest did not end in a newline.', str(v)) | |
344 |
|
344 | |||
345 | def testHugeManifest(self): |
|
345 | def testHugeManifest(self): |
@@ -169,7 +169,7 b' print "# error handling"' | |||||
169 | def assertraises(f, exc=util.Abort): |
|
169 | def assertraises(f, exc=util.Abort): | |
170 | try: |
|
170 | try: | |
171 | f() |
|
171 | f() | |
172 |
except exc |
|
172 | except exc as inst: | |
173 | print 'raised', inst.__class__.__name__ |
|
173 | print 'raised', inst.__class__.__name__ | |
174 | else: |
|
174 | else: | |
175 | print 'no exception?!' |
|
175 | print 'no exception?!' | |
@@ -188,10 +188,10 b' f.close()' | |||||
188 |
|
188 | |||
189 | try: |
|
189 | try: | |
190 | testui(user='abc', group='def', silent=True) |
|
190 | testui(user='abc', group='def', silent=True) | |
191 |
except error.ParseError |
|
191 | except error.ParseError as inst: | |
192 | print inst |
|
192 | print inst | |
193 |
|
193 | |||
194 | try: |
|
194 | try: | |
195 | testui(debug=True, silent=True) |
|
195 | testui(debug=True, silent=True) | |
196 |
except error.ParseError |
|
196 | except error.ParseError as inst: | |
197 | print inst |
|
197 | print inst |
@@ -39,7 +39,7 b" print repr(testui.config('values', 'unkn" | |||||
39 | print "---" |
|
39 | print "---" | |
40 | try: |
|
40 | try: | |
41 | print repr(testui.configbool('values', 'string')) |
|
41 | print repr(testui.configbool('values', 'string')) | |
42 |
except error.ConfigError |
|
42 | except error.ConfigError as inst: | |
43 | print inst |
|
43 | print inst | |
44 | print repr(testui.configbool('values', 'bool1')) |
|
44 | print repr(testui.configbool('values', 'bool1')) | |
45 | print repr(testui.configbool('values', 'bool2')) |
|
45 | print repr(testui.configbool('values', 'bool2')) |
@@ -45,7 +45,7 b' class ProxyHandler (BaseHTTPServer.BaseH' | |||||
45 | host_port = netloc, 80 |
|
45 | host_port = netloc, 80 | |
46 | print "\t" "connect to %s:%d" % host_port |
|
46 | print "\t" "connect to %s:%d" % host_port | |
47 | try: soc.connect(host_port) |
|
47 | try: soc.connect(host_port) | |
48 |
except socket.error |
|
48 | except socket.error as arg: | |
49 | try: msg = arg[1] |
|
49 | try: msg = arg[1] | |
50 | except (IndexError, TypeError): msg = arg |
|
50 | except (IndexError, TypeError): msg = arg | |
51 | self.send_error(404, msg) |
|
51 | self.send_error(404, msg) |
General Comments 0
You need to be logged in to leave comments.
Login now