+$new = PublicInbox::InboxWritable->new($new);
+my $v2w;
+$old->umask_prepare;
+
+sub link_or_copy ($$) {
+ my ($src, $dst) = @_;
+ link($src, $dst) and return;
+ $!{EXDEV} or warn "link $src, $dst failed: $!, trying cp\n";
+ cp($src, $dst) or die "cp $src, $dst failed: $!\n";
+}
+
+$old->with_umask(sub {
+ my $old_cfg = "$old->{inboxdir}/config";
+ local $ENV{GIT_CONFIG} = $old_cfg;
+ my $new_cfg = "$new->{inboxdir}/all.git/config";
+ $v2w = PublicInbox::V2Writable->new($new, 1);
+ $v2w->init_inbox($jobs);
+ unlink $new_cfg;
+ link_or_copy($old_cfg, $new_cfg);
+ if (my $alt = $new->{altid}) {
+ require PublicInbox::AltId;
+ foreach my $i (0..$#$alt) {
+ my $src = PublicInbox::AltId->new($old, $alt->[$i], 0);
+ $src->mm_alt or next;
+ my $dst = PublicInbox::AltId->new($new, $alt->[$i], 1);
+ $dst = $dst->{filename};
+ $src->mm_alt->{dbh}->sqlite_backup_to_file($dst);
+ }
+ }
+ my $desc = "$old->{inboxdir}/description";
+ link_or_copy($desc, "$new->{inboxdir}/description") if -e $desc;
+ my $clone = "$old->{inboxdir}/cloneurl";
+ if (-e $clone) {
+ warn <<"";
+$clone may not be valid after migrating to v2, not copying
+
+ }
+});