#!/usr/bin/perl -w
-# Copyright (C) 2018-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <http://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use v5.10.1;
quiet => -1, compact => 0, maxsize => undef, fsync => 1,
reindex => 1, # we always reindex
};
-GetOptions($opt, qw(jobs|j=i index! help|h),
+GetOptions($opt, qw(jobs|j=i index! help|h C=s@),
# index options
qw(verbose|v+ rethread compact|c+ fsync|sync!
indexlevel|index-level|L=s max_size|max-size=s
batch_size|batch-size=s
- sequential_shard|sequential-shard|seq-shard
+ sequential-shard|seq-shard
)) or die $help;
if ($opt->{help}) { print $help; exit 0 };
+require PublicInbox::Admin;
+PublicInbox::Admin::do_chdir(delete $opt->{C});
my $old_dir = shift(@ARGV) // '';
my $new_dir = shift(@ARGV) // '';
die $help if (scalar(@ARGV) || $new_dir eq '' || $old_dir eq '');
die "$new_dir exists\n" if -d $new_dir;
die "$old_dir not a directory\n" unless -d $old_dir;
-require PublicInbox::Admin;
require PublicInbox::Config;
require PublicInbox::InboxWritable;
}
die "Only conversion from v1 inboxes is supported\n" if $old->version >= 2;
-require PublicInbox::Admin;
my $detected = PublicInbox::Admin::detect_indexlevel($old);
$old->{indexlevel} //= $detected;
my $env;
$new = PublicInbox::InboxWritable->new($new, { nproc => $opt->{jobs} });
$new->{-no_fsync} = 1 if !$opt->{fsync};
my $v2w;
-$old->umask_prepare;
sub link_or_copy ($$) {
my ($src, $dst) = @_;
$v2w->idx_init($opt);
$v2w->{mm}->{dbh}->sqlite_backup_from_file($old_mm);
- my $epoch0 = PublicInbox::Git->new($v2w->git_init(0));
+ my $epoch0 = PublicInbox::Git->new($v2w->{mg}->add_epoch(0));
chop(my $cmt = $epoch0->qx(qw(rev-parse --verify), $head));
$v2w->last_epoch_commit(0, $cmt);
}