Index: trunk/bind-import
===================================================================
--- trunk/bind-import	(revision 820)
+++ trunk/bind-import	(revision 821)
@@ -31,5 +31,5 @@
 
 my $dnsdb = new DNSDB;
-my $doimport = 1;
+my $dryrun = 0;
 
 #print Dumper(\%reverse_typemap);
@@ -59,5 +59,5 @@
 	"skip=s" => \@skipdefs,
 	"skipfile=s" => \$skipfile,
-	"test|dry-run" => sub { $doimport = 0; },
+	"test|dry-run" => \$dryrun,
 );
 
@@ -72,4 +72,6 @@
 		A file containing patterns to skip.  Patterns from the file and
 		any --skip arguments are merged.
+	--dry-run
+		Do everything except finalize the import
 	zonename
 		The name of the zone to import.  Required.
@@ -131,4 +133,5 @@
 ##fixme:  this is wrong, BIND zone files are generally complete and we're adding.  merging records is an entire fridge full of worms.
 ##fixme:  for import, should arguably check for zone *non*existence
+
   if ($zname =~ /\.arpa\.?$/ || $zname =~ m,^[\d./]+$,) {
     $rev = 'y';
@@ -137,6 +140,7 @@
     if ($zid) {
       die "zone $origzone already present, not merging records\n";
-      $zname = new NetAddr::IP $zname;
-      $zname = DNSDB::_ZONE($zname, 'ZONE', 'r', '.').($zname->{isv6} ? '.ip6.arpa' : '.in-addr.arpa');
+#print "dbg: skip add domain\n";
+#      $zname = new NetAddr::IP $zname;
+#      $zname = DNSDB::_ZONE($zname, 'ZONE', 'r', '.').($zname->{isv6} ? '.ip6.arpa' : '.in-addr.arpa');
     }
     ($zid) = $dnsdb->{dbh}->selectrow_array("INSERT INTO revzones (revnet,group_id,status,default_location,zserial) VALUES (?,?,?,?,?) RETURNING rnds_id",
@@ -144,13 +148,11 @@
 
   } else {
-print "dbg: forward zone\n";
     $zid = $dnsdb->domainID($zname,':ANY:');
     if ($zid) {
-#      die "zone $origzone already present, not merging records\n";
-print "dbg: skip add domain\n";
-    } else {
-      ($zid) = $dnsdb->{dbh}->selectrow_array("INSERT INTO domains (domain,group_id,status,default_location,zserial) VALUES (?,?,?,?,?) RETURNING domain_id",
+      die "zone $origzone already present, not merging records\n";
+#print "dbg: skip add domain\n";
+    }
+    ($zid) = $dnsdb->{dbh}->selectrow_array("INSERT INTO domains (domain,group_id,status,default_location,zserial) VALUES (?,?,?,?,?) RETURNING domain_id",
 	undef, ($zname, $group, $status, $location, $serial));
-    }
 
   }
@@ -557,10 +559,6 @@
     }
 
-no warnings qw(uninitialized);
-#print "parsed: '$curlabel' '$class' '$ttl' '$type'->'$itype' '$rdata'\n";
-#print;
-#;imap   IN      900     CNAME   deepnet.cx.
-##fixme:  not sure how to handle the case where someone leaves off the class.
-    if ($doimport) {
+##fixme:  need to dig out a subtransaction widget or extract a core of addRec() that doesn't dbh->commit(), so --dry-run works
+#    unless ($dryrun) {
       my ($code, $msg);
       if ($rev eq 'n') {
@@ -572,8 +570,13 @@
       }
       print "$code: $msg\n" if $code ne 'OK';
-    }
+#    }
 #  $i++;
   }
 
+  if ($dryrun) {
+    $dnsdb->{dbh}->rollback;
+  } else {
+    $dnsdb->{dbh}->commit;
+  }
 };
 if ($@) {
