Index: trunk/ippScripts/scripts/minidvodb_merge.pl
===================================================================
--- branches/haf_branches/ipp.20100512/ippScripts/scripts/minidvodb_merge.pl	(revision 28177)
+++ trunk/ippScripts/scripts/minidvodb_merge.pl	(revision 28181)
@@ -87,5 +87,5 @@
 unless ($no_op) {
     if (defined $mergedvodbReal) {
-	{
+        {
             my $command  = "$addstar -resort";
             $command .= " -D CAMERA $camera";
@@ -101,5 +101,5 @@
             }
             $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);  $dtime_resort = $dtime_addstar;
-	    # MJD of starting script
+            # MJD of starting script
             print "addstar -resort time $dtime_addstar\n";
         }
@@ -123,84 +123,74 @@
             print "relphot time $dtime_relphot\n";
         }
-	
-	{
-
-	    my $mdcParser = PS::IPP::Metadata::Config->new;
-	    
-
-	    my $command = "$addtool -listminidvodbrun -state mergedsdfsad -minidvodb_group " . $minidvodb_group;
-	    $command .= " -dbname $dbname" if defined $dbname;
-
-	    
-
-	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+
+        my $this_is_the_first;
+        {
+
+            my $mdcParser = PS::IPP::Metadata::Config->new;
+
+            my $command = "$addtool -listminidvodbrun -state mergedsdfsad -minidvodb_group " . $minidvodb_group;
+            $command .= " -dbname $dbname" if defined $dbname;
+
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
                     run(command => $command, verbose => $verbose);
-	    &my_die( "Unable to get list of minidvodbruns", $minidvodb_id, $PS_EXIT_SYS_ERROR) unless $success;
-	    my $this_is_the_first;
-	    if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first
-		$this_is_the_first =1;
-	    } else {
-                 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+            &my_die( "Unable to get list of minidvodbruns", $minidvodb_id, $PS_EXIT_SYS_ERROR) unless $success;
+            if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first
+                $this_is_the_first =1;
+            } else {
+                my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
                     &my_die("Unable to parse metadata config", $minidvodb_id, $PS_EXIT_PROG_ERROR);
-		 #this fails if there is nothing listed. I checked.
+                #this fails if there is nothing listed. I checked.
                 my $components = parse_md_list($metadata) or
                     &my_die("Unable to parse metadata list", $minidvodb_id, $PS_EXIT_PROG_ERROR);
                 my $comp = $$components[0];
-	   my  $minidvodb_name = $comp->{minidvodb_name};
-        
+                my  $minidvodb_name = $comp->{minidvodb_name};
+
                 if (!defined($minidvodb_name)) {
                     &my_die("Unable to parse minidvodb_name", $minidvodb_id, $PS_EXIT_PROG_ERROR);
                 } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk.
-		 $this_is_the_first = 0;
-	    }
-
-	    my $merge_command;
-	    if ($this_is_the_first) {
-		
-		$merge_command = "cp -rp $minidvodb $mergedvodb"
-
-	    } else {
-
-		$merge_command = "$dvomerge $minidvodb into $mergedvodb"
-	    }
-
-
-
-	    system ($merge_command);
-
-	    my ( $success2, $error_code2, $full_buf2, $stdout_buf2, $stderr_buf2 ) =
-		run(command => $merge_command, verbose => $verbose);
-	unless ($success2) {
-	    $error_code2 = (($error_code2 >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("Unable to merge: $error_code", $mergedvodb, $error_code2);
-	}
-
-	    	   
-            $dtime_merge = 86400.0*(DateTime->now->mjd - $mjd_relphot_start);   # MJD of starting script
+                $this_is_the_first = 0;
+            }
+        }
+
+        {
+            my $merge_command;
+            if ($this_is_the_first) {
+                $merge_command = "cp -rp $minidvodb $mergedvodb"
+            } else {
+                $merge_command = "$dvomerge $minidvodb into $mergedvodb"
+            }
+
+            my $mjd_merge_start = DateTime->now->mjd;   # MJD of starting script
+
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                run(command => $merge_command, verbose => $verbose);
+            unless ($success) {
+                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+                &my_die("Unable to merge: $error_code", $mergedvodb, $error_code);
+            }
+
+            $dtime_merge = 86400.0*(DateTime->now->mjd - $mjd_merge_start);   # MJD of starting script
             print "merge time $dtime_merge\n";
-	    
-	}
-	
-
-	{
-	my $command = "addtool -minidvodb_id $minidvodb_id";
-        $command .= " -addminidvodbprocessed";
-	$command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
-	$command .= " -minidvodb_group $minidvodb_group";
-        $command .= " -dtime_relphot $dtime_relphot"  if defined $dtime_relphot;
-        $command .= " -dtime_relphot $dtime_resort" if defined $dtime_resort;
-        $command .= " -dtime_relphot $dtime_merge" if defined $dtime_merge;
-        $command .= " -dbname $dbname" if defined $dbname;
-    #print $command;
-	system ($command);
-
-	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	    run(command => $command, verbose => $verbose);
-	unless ($success) {
-	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("Unable to add to minidvodbprocessed: $error_code", $mergedvodb, $error_code);
-	}
-
-	}
+        }
+
+
+        {
+            my $command = "addtool -minidvodb_id $minidvodb_id";
+            $command .= " -addminidvodbprocessed";
+            $command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
+            $command .= " -minidvodb_group $minidvodb_group";
+            $command .= " -dtime_relphot $dtime_relphot"  if defined $dtime_relphot;
+            $command .= " -dtime_relphot $dtime_resort" if defined $dtime_resort;
+            $command .= " -dtime_relphot $dtime_merge" if defined $dtime_merge;
+            $command .= " -dbname $dbname" if defined $dbname;
+            #print $command;
+
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                run(command => $command, verbose => $verbose);
+            unless ($success) {
+                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+                &my_die("Unable to add to minidvodbprocessed: $error_code", $mergedvodb, $error_code);
+            }
+        }
 
     } else {
@@ -217,5 +207,5 @@
 {
     my $msg = shift; # Warning message on die
-    my $minidbvodb_id = shift; 
+    my $minidbvodb_id = shift;
     my $exit_code = shift; # Exit code to add
 
@@ -223,16 +213,16 @@
 
 if (defined $minidvodb_id ) {
-    
+
     my $command = "addtool -minidvodb_id $minidvodb_id";
     $command .= " -addminidvodbprocessed";
         $command .= " -fault $exit_code";
-	$command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
-    	$command .= " -minidvodb_group $minidvodb_group";
+        $command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
+        $command .= " -minidvodb_group $minidvodb_group";
         $command .= " -dtime_relphot $dtime_relphot" if defined $dtime_relphot;
         $command .= " -dtime_relphot $dtime_resort" if defined $dtime_resort;
         $command .= " -dtime_relphot $dtime_merge" if defined $dtime_merge;
         $command .= " -dbname $dbname" if defined $dbname;
-    
-    
+
+
 
     #print $command;
