about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-02-22 05:17:40 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-02-22 18:30:20 +0000
commit6a5d79ca1d848f1672022e2c5494a182612be375 (patch)
treef5e2280e976f71c67443e1e6cdbe19463d056a54
parentfeabfb1809b911fc97538282234c8b1f087ddb6a (diff)
downloadpublic-inbox-6a5d79ca1d848f1672022e2c5494a182612be375.tar.gz
This will let us quickly test between v2 and v1 inboxes.
-rw-r--r--scripts/import_vger_from_mbox24
1 files changed, 19 insertions, 5 deletions
diff --git a/scripts/import_vger_from_mbox b/scripts/import_vger_from_mbox
index d30e8a30..abc2d37c 100644
--- a/scripts/import_vger_from_mbox
+++ b/scripts/import_vger_from_mbox
@@ -9,21 +9,35 @@ use Email::MIME;
 $Email::MIME::ContentType::STRICT_PARAMS = 0; # user input is imperfect
 use PublicInbox::Inbox;
 use PublicInbox::V2Writable;
+use PublicInbox::Import;
 my $usage = "usage: $0 NAME EMAIL DIR <MBOX\n";
 my $dry_run;
-my %opts = ( 'n|dry-run' => \$dry_run );
+my $version = 2;
+my %opts = (
+        'n|dry-run' => \$dry_run,
+        'V|version=i' => \$version,
+);
 GetOptions(%opts) or die $usage;
 my $name = shift or die $usage; # git
 my $email = shift or die $usage; # git@vger.kernel.org
 my $mainrepo = shift or die $usage; # /path/to/v2/repo
-my $v2ibx = {
+my $ibx = {
         mainrepo => $mainrepo,
         name => $name,
-        version => 2,
+        version => $version,
         -primary_address => $email,
 };
-$v2ibx = PublicInbox::Inbox->new($v2ibx);
-my $im = $dry_run ? undef : PublicInbox::V2Writable->new($v2ibx, 1);
+$ibx = PublicInbox::Inbox->new($ibx);
+my $im;
+unless ($dry_run) {
+        if ($version >= 2) {
+                $im = PublicInbox::V2Writable->new($ibx, 1);
+        } else {
+                system(qw(git init --bare -q), $mainrepo);
+                my $git = PublicInbox::Git->new($mainrepo);
+                $im = PublicInbox::Import->new($git, $name, $email, $ibx);
+        }
+}
 binmode STDIN;
 my $msg = '';
 use PublicInbox::Filter::Vger;