largefiles: eliminate naked exceptions
authorMatt Mackall <mpm@selenic.com>
Thu, 29 Sep 2011 17:14:47 -0500
changeset 15171 547da6115d1d
parent 15170 c1a4a3220711
child 15172 fb1dcd2aae2a
largefiles: eliminate naked exceptions
hgext/largefiles/lfcommands.py
hgext/largefiles/lfutil.py
hgext/largefiles/reposetup.py
--- 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