use PublicInbox::InboxWritable;
use PublicInbox::Config;
use PublicInbox::V2Writable;
+use PublicInbox::Git;
use PublicInbox::Spawn qw(spawn);
use Cwd 'abs_path';
use File::Copy 'cp'; # preserves permissions:
close $rd or die "close fast-export: $!\n";
waitpid($pid, 0) or die "waitpid failed: $!\n";
$? == 0 or die "fast-export failed: $?\n";
-my $mm = $old->mm;
-$mm->{dbh}->sqlite_backup_to_file("$new_dir/msgmap.sqlite3") if $mm;
$v2w->done;
+if (my $mm = $old->mm) {
+ $old->cleanup;
+ $mm->{dbh}->sqlite_backup_to_file("$new_dir/msgmap.sqlite3");
+
+ # we want to trigger a reindex, not a from scratch index if
+ # we're reusing the msgmap from an existing v1 installation.
+ $v2w->idx_init;
+ my $epoch0 = PublicInbox::Git->new($v2w->git_init(0));
+ chop(my $cmt = $epoch0->qx(qw(rev-parse --verify), $head));
+ $v2w->last_epoch_commit(0, $cmt);
+}
if ($index) {
- $v2w->index_sync;
+ $v2w->index_sync({reindex => 1});
$v2w->done;
}
is(((stat($xdir[0]))[2]) & 07777, 0755,
'sharedRepository respected on v1 compact');
+my $hwm = do {
+ my $mm = $ibx->mm;
+ $ibx->cleanup;
+ $mm->num_highwater;
+};
+ok(defined($hwm) && $hwm > 0, "highwater mark set #$hwm");
+
$cmd = [ '-convert', $ibx->{inboxdir}, "$tmpdir/v2" ];
ok(run_script($cmd, undef, $rdr), 'convert works');
@xdir = glob("$tmpdir/v2/xap*/*");
ok(run_script($cmd, $env, $rdr), 'v2 compact works');
$ibx->{inboxdir} = "$tmpdir/v2";
$ibx->{version} = 2;
+is($ibx->mm->num_highwater, $hwm, 'highwater mark unchanged in v2 inbox');
@xdir = glob("$tmpdir/v2/xap*/*");
foreach (@xdir) {