First checkin of the reversion back from the failed optimization effort. I will be...
[dbsrgits/DBM-Deep.git] / utils / upgrade_db.pl
index 8fbf30c..91003c3 100755 (executable)
@@ -13,11 +13,12 @@ use lib File::Spec->catdir( $FindBin::Bin, 'lib' );
 use lib File::Spec->catdir( $FindBin::Bin, '..', 'lib' );
 
 use Getopt::Long qw( GetOptions );
-use Pod::Usage;
+use Pod::Usage 1.3;
 
 my %headerver_to_module = (
   '0' => 'DBM::Deep::09830',
-  '2' => 'DBM::Deep', 
+  '2' => 'DBM::Deep::10002', 
+  '3' => 'DBM::Deep',
 );
 
 my %is_dev = (
@@ -27,8 +28,8 @@ my %is_dev = (
 my %opts = (
   man => 0,
   help => 0,
-  version => '1.0000',
-  autobless => 0,
+  version => '1.0013',
+  autobless => 1,
 );
 GetOptions( \%opts,
   'input=s', 'output=s', 'version:s', 'autobless:i',
@@ -57,6 +58,9 @@ my %db;
 
   my $mod = $headerver_to_module{ $ver };
   eval "use $mod;";
+  if ( $@ ) {
+      _exit( "Cannot load '$mod' to read header version '$ver':\n\t$@" );
+  }
   $db{input} = $mod->new({
     file      => $opts{input},
     locking   => 1,
@@ -67,14 +71,20 @@ my %db;
 
 {
   my $ver = $opts{version};
-  if ( $ver =~ /^0\.9[1-8]/ ) {
-    $ver = 0;
+  if ( $ver =~ /^1\.001[0-3]/) {
+    $ver = 3;
+  }
+  elsif ( $ver =~ /^1\.000[3-9]/) {
+    $ver = 3;
+  }
+  elsif ( $ver =~ /^1\.000?[0-2]?/) {
+    $ver = 2;
   }
   elsif ( $ver =~ /^0\.99/) { 
     $ver = 1;
   }
-  elsif ( $ver =~ /^1\.000?0?/) {
-    $ver = 2;
+  elsif ( $ver =~ /^0\.9[1-8]/ ) {
+    $ver = 0;
   }
   else {
     _exit( "'$ver' is an unrecognized version." );
@@ -89,6 +99,9 @@ my %db;
 
   my $mod = $headerver_to_module{ $ver };
   eval "use $mod;";
+  if ( $@ ) {
+      _exit( "Cannot load '$mod' to read header version '$ver':\n\t$@" );
+  }
   $db{output} = $mod->new({
     file      => $opts{output},
     locking   => 1,
@@ -177,8 +190,8 @@ of the database.
 
 =item B<-autobless>
 
-In pre-1.0000 versions, autoblessing was an optional setting. This defaults to
-false.
+In pre-1.0000 versions, autoblessing was an optional setting defaulting to
+false. Autobless in upgrade_db.pl defaults to true.
 
 =item B<-help>
 
@@ -203,7 +216,7 @@ This will require about twice the diskspace of the input file.
 =item * Feature support
 
 Not all versions support the same features. In particular, internal references
-were supported in 0.983 and support was removed in 1.000. There is no
+were supported in 0.983, removed in 1.000, and re-added in 1.0003. There is no
 detection of this by upgrade_db.pl.
 
 =back