[PATCH 6 of 6] imported patch check-code-ignore-naked-excepts

Brodie Rao brodie at sf.io
Sat May 12 08:39:35 CDT 2012


# HG changeset patch
# User Brodie Rao <brodie at sf.io>
# Date 1336828934 -7200
# Branch stable
# Node ID 5485da9f094a5a14ead56e6b499492d1451465c7
# Parent  aeb9a6868d1a6e99a031369c92a6a3613f599df7
imported patch check-code-ignore-naked-excepts

diff --git a/contrib/shrink-revlog.py b/contrib/shrink-revlog.py
--- a/contrib/shrink-revlog.py
+++ b/contrib/shrink-revlog.py
@@ -240,7 +240,7 @@ def shrink(ui, repo, **opts):
             writerevs(ui, r1, r2, order, tr)
             report(ui, r1, r2)
             tr.close()
-        except:
+        except: # check-code-ignore
             # Abort transaction first, so we truncate the files before
             # deleting them.
             tr.abort()
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -694,7 +694,7 @@ class queue(object):
                 tr.close()
                 self.savedirty()
                 return ret
-            except:
+            except: # check-code-ignore
                 try:
                     tr.abort()
                 finally:
@@ -1052,7 +1052,7 @@ class queue(object):
                     r = self.qrepo()
                     if r:
                         r[None].add([patchfn])
-                except:
+                except: # check-code-ignore
                     repo.rollback()
                     raise
             except Exception:
@@ -1271,7 +1271,7 @@ class queue(object):
                 else:
                     ret = self.apply(repo, s, list, all_files=all_files,
                                      tobackup=tobackup)
-            except:
+            except: # check-code-ignore
                 self.ui.warn(_('cleaning up working directory...'))
                 node = repo.dirstate.p1()
                 hg.revert(repo, node, None)
@@ -1591,7 +1591,7 @@ class queue(object):
                 self.applieddirty = True
                 self.strip(repo, [top], update=False,
                            backup='strip')
-            except:
+            except: # check-code-ignore
                 repo.dirstate.invalidate()
                 raise
 
@@ -1605,7 +1605,7 @@ class queue(object):
                 # only write patch after a successful commit
                 patchf.close()
                 self.applied.append(statusentry(n, patchfn))
-            except:
+            except: # check-code-ignore
                 ctx = repo[cparents[0]]
                 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
                 self.savedirty()
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3738,7 +3738,7 @@ def import_(ui, repo, patch1=None, *patc
                 tr.close()
             if msgs:
                 repo.savecommitmessage('\n* * *\n'.join(msgs))
-        except:
+        except: # check-code-ignore
             # wlock.release() indirectly calls dirstate.write(): since
             # we're crashing, we do not want to change the working dir
             # parent after all, so make sure it writes nothing
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -88,7 +88,7 @@ def _runcatch(req):
                 return _dispatch(req)
             finally:
                 ui.flush()
-        except:
+        except: # check-code-ignore
             # enter the debugger when we hit an exception
             if '--debugger' in req.args:
                 traceback.print_exc()
@@ -204,7 +204,7 @@ def _runcatch(req):
         return inst.code
     except socket.error, inst:
         ui.warn(_("abort: %s\n") % inst.args[-1])
-    except:
+    except: # check-code-ignore
         ui.warn(_("** unknown exception encountered,"
                   " please report by visiting\n"))
         ui.warn(_("**  http://mercurial.selenic.com/wiki/BugTracker\n"))
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -203,7 +203,7 @@ def copystore(ui, srcrepo, destpath):
         else:
             ui.debug("copied %d files\n" % num)
         return destlock
-    except:
+    except: # check-code-ignore
         release(destlock)
         raise
 
diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -290,7 +290,7 @@ class KeepAliveHandler(object):
             # worked.  We'll check the version below, too.
         except (socket.error, httplib.HTTPException):
             r = None
-        except:
+        except: # check-code-ignore
             # adding this block just in case we've missed
             # something we will still raise the exception, but
             # lets try and close the connection and remove it
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1195,7 +1195,7 @@ class localrepository(repo.repository):
                 self.hook("precommit", throw=True, parent1=hookp1,
                           parent2=hookp2)
                 ret = self.commitctx(cctx, True)
-            except:
+            except: # check-code-ignore
                 if edited:
                     self.ui.write(
                         _('note: commit message saved in %s\n') % msgfn)
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -245,7 +245,7 @@ def extract(ui, fileobj):
                         tmpfp.write('\n')
             elif not diffs_seen and message and content_type == 'text/plain':
                 message += '\n' + payload
-    except:
+    except: # check-code-ignore
         tmpfp.close()
         os.unlink(tmpname)
         raise
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -131,7 +131,7 @@ def strip(ui, repo, nodelist, backup="al
                 file, troffset, ignore = tr.entries[i]
                 repo.sopener(file, 'a').truncate(troffset)
             tr.close()
-        except:
+        except: # check-code-ignore
             tr.abort()
             raise
 
@@ -160,7 +160,7 @@ def strip(ui, repo, nodelist, backup="al
         for m in updatebm:
             bm[m] = repo['.'].node()
         bookmarks.write(repo)
-    except:
+    except: # check-code-ignore
         if backupfile:
             ui.warn(_("strip failed, full bundle stored in '%s'\n")
                     % backupfile)
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -760,7 +760,7 @@ def mktempcopy(name, emptyok=False, crea
             ofp.write(chunk)
         ifp.close()
         ofp.close()
-    except:
+    except: # check-code-ignore
         try: os.unlink(temp)
         except: pass
         raise
diff --git a/tests/test-check-code-hg.t b/tests/test-check-code-hg.t
--- a/tests/test-check-code-hg.t
+++ b/tests/test-check-code-hg.t
@@ -8,9 +8,6 @@
   $ hg manifest | xargs "$check_code" || echo 'FAILURE IS NOT AN OPTION!!!'
 
   $ hg manifest | xargs "$check_code" --warnings --nolineno --per-file=0 || true
-  contrib/shrink-revlog.py:0:
-   >         except:
-   warning: naked except clause
   hgext/convert/cvsps.py:0:
    >                     ui.write('Ancestors: %s\n' % (','.join(r)))
    warning: unwrapped ui message
@@ -69,15 +66,6 @@
    >     ui.note("hg ci -m '%s'\n" % msg)
    warning: unwrapped ui message
   hgext/mq.py:0:
-   >                 except:
-   warning: naked except clause
-  hgext/mq.py:0:
-   >             except:
-   warning: naked except clause
-   warning: naked except clause
-   warning: naked except clause
-   warning: naked except clause
-  hgext/mq.py:0:
    >         ui.write("mq:     %s\n" % ', '.join(m))
    warning: unwrapped ui message
   hgext/patchbomb.py:0:
@@ -117,9 +105,6 @@
    >             ui.write('deltas against p2    : ' + fmt % pcfmt(nump2, numdeltas))
    warning: unwrapped ui message
   mercurial/commands.py:0:
-   >         except:
-   warning: naked except clause
-  mercurial/commands.py:0:
    >         ui.write("common heads: %s\n" % " ".join([short(n) for n in common]))
    warning: unwrapped ui message
   mercurial/commands.py:0:
@@ -177,33 +162,6 @@
   mercurial/commands.py:0:
    >     ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
    warning: unwrapped ui message
-  mercurial/dispatch.py:0:
-   >         except:
-   warning: naked except clause
-  mercurial/dispatch.py:0:
-   >     except:
-   warning: naked except clause
-  mercurial/hg.py:0:
-   >     except:
-   warning: naked except clause
-  mercurial/keepalive.py:0:
-   >         except:
-   warning: naked except clause
-  mercurial/localrepo.py:0:
-   >             except:
-   warning: naked except clause
-  mercurial/patch.py:0:
-   >     except:
-   warning: naked except clause
-  mercurial/repair.py:0:
-   >         except:
-   warning: naked except clause
-  mercurial/repair.py:0:
-   >     except:
-   warning: naked except clause
-  mercurial/util.py:0:
-   >     except:
-   warning: naked except clause
   tests/autodiff.py:0:
    >         ui.write('data lost for: %s\n' % fn)
    warning: unwrapped ui message


More information about the Mercurial-devel mailing list