]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-convert
convert: support converting with altid defined
[public-inbox.git] / script / public-inbox-convert
index 9aa27814d4538a28c75c513d3b90a7e825714767..2742be79fe1d47b4d0ef79c76ab95660a7e18d11 100755 (executable)
@@ -45,7 +45,6 @@ if (($old->{version} || 1) >= 2) {
        die "Only conversion from v1 inboxes is supported\n";
 }
 my $new = { %$old };
-delete $new->{altid}; # TODO: support altid for v2
 $new->{mainrepo} = abs_path($new_dir);
 $new->{version} = 2;
 $new = PublicInbox::InboxWritable->new($new);
@@ -61,6 +60,16 @@ $old->with_umask(sub {
                        "--file=$new->{mainrepo}/all.git/config",
                        'core.sharedRepository', $sr]);
        }
+       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 $state = '';
 my ($prev, $from);