From: rkinyon <rkinyon@50811bd7-b8ce-0310-adc1-d9db26280581>
Date: Thu, 15 Feb 2007 19:52:29 +0000 (+0000)
Subject: Cleanup for new file versions
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8071afd3e68803ec8c33b611e424ca81d64692f7;p=dbsrgits%2FDBM-Deep.git

Cleanup for new file versions
---

diff --git a/t/06_error.t b/t/06_error.t
index f60e4a5..47b5c92 100644
--- a/t/06_error.t
+++ b/t/06_error.t
@@ -128,12 +128,12 @@ use_ok( 'DBM::Deep' );
 
 {
     throws_ok {
-        DBM::Deep->new( 't/old_versions/db.0.983' );
+        DBM::Deep->new( 't/old_versions/db-0-983' );
     } qr/DBM::Deep: Pre-1.00 file version found/, "Fail if opening a pre-1.00 file";
 }
 
 {
     throws_ok {
-        DBM::Deep->new( 't/old_versions/db.0.99_04' );
+        DBM::Deep->new( 't/old_versions/db-0-99_04' );
     } qr/DBM::Deep: Wrong file version found - 1 - expected 2/, "Fail if opening a file version 1";
 }
diff --git a/utils/upgrade_db.pl b/utils/upgrade_db.pl
index 0385a59..5133bda 100755
--- a/utils/upgrade_db.pl
+++ b/utils/upgrade_db.pl
@@ -60,8 +60,8 @@ my %db;
   my $mod = $headerver_to_module{ $ver };
   require $mod;
   $db{input} = $mod->new({
-    file    => $opts{input},
-    locking => 1,
+    file      => $opts{input},
+    locking   => 1,
     autobless => $opts{autobless},
   });
   $db{input}->lock;
@@ -69,19 +69,31 @@ my %db;
 
 {
   my $ver = $opts{version};
-  #if ( $ver =~ /^0\.98/ ) {
+  if ( $ver =~ /^0\.98/ ) {
+    $ver = 0;
+  }
+  elsif ( $ver =~ /^0\.99/) { 
+    $ver = 1;
+  }
+  elsif ( $ver =~ /^1\.00/) {
+    $ver = 2;
+  }
+  else {
+    _exit( "'$ver' is an unrecognized version." );
+  }
+
   if ( $is_dev{ $ver } ) {
     _exit( "'$opts{version}' is a dev release and not supported." );
   }
 
   my $mod = $headerver_to_module{ $ver };
   require $mod;
-  $db{input} = $mod->new({
-    file    => $opts{input},
-    locking => 1,
+  $db{output} = $mod->new({
+    file      => $opts{output},
+    locking   => 1,
     autobless => $opts{autobless},
   });
-  $db{input}->lock;
+  $db{output}->lock;
 }
 
 # Do the actual conversion