+if (-f "$mainrepo/inbox.lock") {
+ if (!defined $version) {
+ $version = 2;
+ } elsif ($version != 2) {
+ die "$mainrepo is a -V2 repo, -V$version specified\n"
+ }
+} elsif (-d "$mainrepo/objects") {
+ if (!defined $version) {
+ $version = 1;
+ } elsif ($version != 1) {
+ die "$mainrepo is a -V1 repo, -V$version specified\n"
+ }
+}
+
+$version = 1 unless defined $version;
+
+if ($version == 1 && defined $skip) {
+ die "--skip is only supported for -V2 repos\n";
+}
+
+my $ibx = PublicInbox::Inbox->new({
+ mainrepo => $mainrepo,
+ name => $name,
+ version => $version,
+ -primary_address => $address[0],
+ indexlevel => $indexlevel,
+});