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;

Reply via email to