# HG changeset patch # User Idan Kamara # Date 1303509085 -10800 # Node ID 97ed99d1f419246c630139b501d4a9bc8d660d53 # Parent ba734ff5cadd3cf188bb5b184b9f86c4a95d09de eliminate various naked except clauses diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/bookmarks.py --- a/mercurial/bookmarks.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/bookmarks.py Sat Apr 23 00:51:25 2011 +0300 @@ -29,7 +29,7 @@ sha, refspec = line.strip().split(' ', 1) refspec = encoding.tolocal(refspec) bookmarks[refspec] = repo.changelog.lookup(sha) - except: + except IOError: pass return bookmarks diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/bundlerepo.py Sat Apr 23 00:51:25 2011 +0300 @@ -294,7 +294,7 @@ if not incoming: try: os.unlink(bundlename) - except: + except OSError: pass return other, None, None, None diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/changelog.py --- a/mercurial/changelog.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/changelog.py Sat Apr 23 00:51:25 2011 +0300 @@ -185,7 +185,7 @@ try: # various tools did silly things with the time zone field. timezone = int(extra_data[0]) - except: + except ValueError: timezone = 0 extra = {} else: diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/cmdutil.py Sat Apr 23 00:51:25 2011 +0300 @@ -293,7 +293,7 @@ good = True try: audit_path(abs) - except: + except (OSError, util.Abort): good = False rel = m.rel(abs) exact = m.exact(abs) diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/context.py --- a/mercurial/context.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/context.py Sat Apr 23 00:51:25 2011 +0300 @@ -805,7 +805,7 @@ p = self._repo.wjoin(f) try: st = os.lstat(p) - except: + except OSError: ui.warn(_("%s does not exist!\n") % join(f)) rejected.append(f) continue diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/dispatch.py --- a/mercurial/dispatch.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/dispatch.py Sat Apr 23 00:51:25 2011 +0300 @@ -133,7 +133,7 @@ elif hasattr(inst, "reason"): try: # usually it is in the form (errno, strerror) reason = inst.reason.args[1] - except: # it might be anything, for example a string + except AttributeError: # it might be anything, for example a string reason = inst.reason ui.warn(_("abort: error: %s\n") % reason) elif hasattr(inst, "args") and inst.args[0] == errno.EPIPE: diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/hg.py --- a/mercurial/hg.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/hg.py Sat Apr 23 00:51:25 2011 +0300 @@ -363,7 +363,7 @@ try: m = dest_repo.lookup(n) dest_repo._bookmarks[k] = m - except: + except error.RepoLookupError: pass if rb: bookmarks.write(dest_repo) diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/localrepo.py --- a/mercurial/localrepo.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/localrepo.py Sat Apr 23 00:51:25 2011 +0300 @@ -549,7 +549,7 @@ try: if len(key) == 20: key = hex(key) - except: + except TypeError: pass raise error.RepoLookupError(_("unknown revision '%s'") % key) diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/posix.py --- a/mercurial/posix.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/posix.py Sat Apr 23 00:51:25 2011 +0300 @@ -59,7 +59,7 @@ os.unlink(f) try: os.symlink(data, f) - except: + except OSError: # failed to make a link, rewrite file fp = open(f, "w") fp.write(data) diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/sshrepo.py --- a/mercurial/sshrepo.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/sshrepo.py Sat Apr 23 00:51:25 2011 +0300 @@ -167,7 +167,7 @@ self.readerr() try: l = int(l) - except: + except ValueError: self._abort(error.ResponseError(_("unexpected response:"), l)) return self.pipei.read(l) @@ -208,7 +208,7 @@ return 1 try: return int(r) - except: + except ValueError: self._abort(error.ResponseError(_("unexpected response:"), r)) instance = sshrepository diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/util.py --- a/mercurial/util.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/util.py Sat Apr 23 00:51:25 2011 +0300 @@ -206,12 +206,12 @@ try: if inname: os.unlink(inname) - except: + except OSError: pass try: if outname: os.unlink(outname) - except: + except OSError: pass filtertable = { @@ -407,7 +407,7 @@ if os.path.islink(src): try: os.unlink(dest) - except: + except OSError: pass os.symlink(os.readlink(src), dest) else: @@ -556,7 +556,7 @@ if s2 == s1: return False return True - except: + except OSError: return True _fspathcache = {} diff -r ba734ff5cadd -r 97ed99d1f419 mercurial/windows.py --- a/mercurial/windows.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/windows.py Sat Apr 23 00:51:25 2011 +0300 @@ -32,7 +32,8 @@ def close(self): try: self.fp.close() - except: pass + except IOError: + pass def write(self, s): try: @@ -243,7 +244,7 @@ if osutil.listdir(head): return os.rmdir(head) - except: + except (ValueError, OSError): break head, tail = os.path.split(head)