changeset 15171:547da6115d1d

largefiles: eliminate naked exceptions
author Matt Mackall <mpm@selenic.com>
date Thu, 29 Sep 2011 17:14:47 -0500
parents c1a4a3220711
children fb1dcd2aae2a
files hgext/largefiles/lfcommands.py hgext/largefiles/lfutil.py hgext/largefiles/reposetup.py
diffstat 3 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/lfcommands.py	Thu Sep 29 17:04:57 2011 -0500
+++ b/hgext/largefiles/lfcommands.py	Thu Sep 29 17:14:47 2011 -0500
@@ -65,6 +65,7 @@
         ui.traceback()
         raise util.Abort(_('%s is not a repo') % dest)
 
+    success = False
     try:
         # Lock destination to prevent modification while it is converted to.
         # Don't need to lock src because we are just reading from its history
@@ -106,7 +107,7 @@
                     os.unlink(rdst.wjoin(f))
                 try:
                     os.removedirs(os.path.dirname(rdst.wjoin(f)))
-                except:
+                except OSError:
                     pass
 
         else:
@@ -116,11 +117,11 @@
                 _addchangeset(ui, rsrc, rdst, ctx, revmap)
 
             ui.progress(_('converting revisions'), None)
-    except:
-        # we failed, remove the new directory
-        shutil.rmtree(rdst.root)
-        raise
+        success = True
     finally:
+        if not success:
+            # we failed, remove the new directory
+            shutil.rmtree(rdst.root)
         dst_lock.release()
 
 def _addchangeset(ui, rsrc, rdst, ctx, revmap):
--- a/hgext/largefiles/lfutil.py	Thu Sep 29 17:04:57 2011 -0500
+++ b/hgext/largefiles/lfutil.py	Thu Sep 29 17:14:47 2011 -0500
@@ -103,12 +103,7 @@
 
 if os.name == 'nt':
     from mercurial import win32
-    try:
-        linkfn = win32.oslink
-    except:
-        linkfn = win32.os_link
-else:
-    linkfn = os.link
+    linkfn = win32.oslink
 
 def link(src, dest):
     try:
--- a/hgext/largefiles/reposetup.py	Thu Sep 29 17:04:57 2011 -0500
+++ b/hgext/largefiles/reposetup.py	Thu Sep 29 17:14:47 2011 -0500
@@ -114,7 +114,7 @@
                             return file in ctx.manifest()
                         ctx[file]
                         return True
-                    except:
+                    except KeyError:
                         return False
 
                 # create a copy of match that matches standins instead of