From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 2AA7C1FAEA for ; Thu, 22 Feb 2018 21:42:25 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 08/12] import_vger_from_inbox: allow "-V" option Date: Thu, 22 Feb 2018 21:42:18 +0000 Message-Id: <20180222214222.1086-9-e@80x24.org> In-Reply-To: <20180222214222.1086-1-e@80x24.org> References: <20180222214222.1086-1-e@80x24.org> List-Id: This will let us quickly test between v2 and v1 inboxes. --- scripts/import_vger_from_mbox | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/import_vger_from_mbox b/scripts/import_vger_from_mbox index d30e8a3..abc2d37 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 \$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; -- EW