[PATCH 2 of 6] largefiles: test lfconvert error handling; remove redundant code

Greg Ward greg-hg at gerg.ca
Sat Oct 22 14:43:17 CDT 2011


# HG changeset patch
# User Greg Ward <greg at gerg.ca>
# Date 1319307439 14400
# Branch stable
# Node ID 49f3bb81d7ba631c8ea157c47ccdc4b0fe0656a2
# Parent  086c40edac07bd37659ad563e9e9cccf71479618
largefiles: test lfconvert error handling; remove redundant code

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -43,26 +43,14 @@
     else:
         tolfile = True
         size = lfutil.getminsize(ui, True, opts.get('size'), default=None)
-    try:
-        rsrc = hg.repository(ui, src)
-        if not rsrc.local():
-            raise util.Abort(_('%s is not a local Mercurial repo') % src)
-    except error.RepoError, err:
-        ui.traceback()
-        raise util.Abort(err.args[0])
-    if os.path.exists(dest):
-        if not os.path.isdir(dest):
-            raise util.Abort(_('destination %s already exists') % dest)
-        elif os.listdir(dest):
-            raise util.Abort(_('destination %s is not empty') % dest)
-    try:
-        ui.status(_('initializing destination %s\n') % dest)
-        rdst = hg.repository(ui, dest, create=True)
-        if not rdst.local():
-            raise util.Abort(_('%s is not a local Mercurial repo') % dest)
-    except error.RepoError:
-        ui.traceback()
-        raise util.Abort(_('%s is not a repo') % dest)
+    rsrc = hg.repository(ui, src)
+    if not rsrc.local():
+        raise util.Abort(_('%s is not a local Mercurial repo') % src)
+
+    ui.status(_('initializing destination %s\n') % dest)
+    rdst = hg.repository(ui, dest, create=True)
+    if not rdst.local():
+        raise util.Abort(_('%s is not a local Mercurial repo') % dest)
 
     success = False
     try:
diff --git a/tests/test-lfconvert.t b/tests/test-lfconvert.t
--- a/tests/test-lfconvert.t
+++ b/tests/test-lfconvert.t
@@ -1,6 +1,7 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > largefiles =
+  > share =
   > [largefiles]
   > minsize = 0.5
   > patterns = **.dat
@@ -41,8 +42,24 @@
   $ cat .hglf/a-large-file .hglf/another-large-file
   2e000fa7e85759c7f4c254d4d9c33ef481e459a7
   3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3
+  $ cd ..
+
+"lfconvert" error cases
+  $ hg lfconvert nosuchrepo foo
+  abort: repository nosuchrepo not found!
+  [255]
+  $ hg share -q -U bigfile-repo shared
+  $ echo -n bogus > shared/.hg/sharedpath
+  $ hg lfconvert shared foo
+  abort: .hg/sharedpath points to nonexistent directory $TESTTMP/bogus!
+  [255]
+  $ hg lfconvert bigfile-repo largefiles-repo
+  initializing destination largefiles-repo
+  abort: repository largefiles-repo already exists!
+  [255]
 
 Convert back to a normal (non-largefiles) repo
+  $ cd largefiles-repo
   $ hg lfconvert --to-normal . ../normal-repo
   initializing destination ../normal-repo
   $ cd ../normal-repo


More information about the Mercurial-devel mailing list