]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei convert: explicitly allow --sort for inputs
authorEric Wong <e@80x24.org>
Wed, 31 Jan 2024 10:20:16 +0000 (10:20 +0000)
committerEric Wong <e@80x24.org>
Thu, 1 Feb 2024 21:00:14 +0000 (21:00 +0000)
LeiToMail can't sort v2 output, but sorting MH input (and
NNTP spool + mlmmj archives) numerically makes sense.

lib/PublicInbox/LeiConvert.pm
lib/PublicInbox/LeiToMail.pm
t/mh_reader.t

index 17a952f207e01609a59adee0e2ec143296757f8f..4d4fceb240d1309df50e716a2b93608ec30e9f4b 100644 (file)
@@ -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
index 9197bb441a73ced58446ba912cd1ead00bf9aa0a..a816df6c54e183db332eb8ce20966af024b885ec 100644 (file)
@@ -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;
index e8f69fa8cd65b1af43bc301af0c2c38c8a898916..711fc8aacbe6dfb9a008b29288ca04167b943a9f 100644 (file)
@@ -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;