From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 543531F4B8 for ; Wed, 31 Jan 2024 10:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1706696421; bh=cldoMqItM7xzAIBjZYJcAnT4qemel1j9TZHU/OhGxTM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UX/HVysRpnFqBZ1dQkEoC8c3hakKPNX9LxE1xsQi5vodgnnHsxtRvyLev09imQh4D gvs24DOXG7NQv0x+qUjZB5YKTFxAj5GsDzRjfYDztLaxjn9xDZjI3H9WARicV4c0m8 Zj/mqkr9Mq5lhKBoboNVJU+9DQR2lA7sTC4aCvl4= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/5] lei convert: explicitly allow --sort for inputs Date: Wed, 31 Jan 2024 10:20:16 +0000 Message-ID: <20240131102021.1257902-2-e@80x24.org> In-Reply-To: <20240131102021.1257902-1-e@80x24.org> References: <20240131102021.1257902-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: LeiToMail can't sort v2 output, but sorting MH input (and NNTP spool + mlmmj archives) numerically makes sense. --- lib/PublicInbox/LeiConvert.pm | 1 + lib/PublicInbox/LeiToMail.pm | 2 ++ t/mh_reader.t | 9 ++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/LeiConvert.pm b/lib/PublicInbox/LeiConvert.pm index 17a952f2..4d4fceb2 100644 --- a/lib/PublicInbox/LeiConvert.pm +++ b/lib/PublicInbox/LeiConvert.pm @@ -52,6 +52,7 @@ sub lei_convert { # the main "lei convert" method my ($lei, @inputs) = @_; $lei->{opt}->{kw} //= 1; $lei->{opt}->{dedupe} //= 'none'; + $lei->{input_opt}->{sort} = 1; # for LeiToMail conflict check my $self = bless {}, __PACKAGE__; my $ovv = PublicInbox::LeiOverview->new($lei, 'out-format'); $lei->{l2m} or return diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index 9197bb44..a816df6c 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -451,6 +451,8 @@ EOM (-d $dst || (-e _ && !-w _)) and die "$dst exists and is not a writable file\n"; } + $lei->{input_opt} and # lei_convert sets this + @conflict = grep { !$lei->{input_opt}->{$_} } @conflict; my @err = map { defined($lei->{opt}->{$_}) ? "--$_" : () } @conflict; die "@err incompatible with $fmt\n" if @err; $self->{dst} = $dst; diff --git a/t/mh_reader.t b/t/mh_reader.t index e8f69fa8..711fc8aa 100644 --- a/t/mh_reader.t +++ b/t/mh_reader.t @@ -101,7 +101,14 @@ test_lei(sub { lei_ok qw(index), 'mh:'.$stale; lei qw(q -f mboxrd), 's:msg 4'; like $lei_out, qr/^Subject: msg 4\nStatus: RO\n\n\n/ms, - "message retrieved after `lei index'" + "message retrieved after `lei index'"; + + # ensure sort works for _input_ when output disallows sort + my $v2out = "$ENV{HOME}/v2-out"; + lei_ok qw(convert -s sequence), "mh:$for_sort", '-o', "v2:$v2out"; + my $git = PublicInbox::Git->new("$v2out/git/0.git"); + chomp(my @l = $git->qx(qw(log --pretty=oneline --format=%s))); + is_xdeeply \@l, [1, 22, 333], 'sequence order preserved for v2'; }); done_testing;