From: Eric Wong <e@80x24.org>
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 [thread overview]
Message-ID: <20240131102021.1257902-2-e@80x24.org> (raw)
In-Reply-To: <20240131102021.1257902-1-e@80x24.org>
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;
next prev parent reply other threads:[~2024-01-31 10:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 10:20 [PATCH 0/5] more MH-related updates Eric Wong
2024-01-31 10:20 ` Eric Wong [this message]
2024-01-31 10:20 ` [PATCH 2/5] import: drop redundant `use' statement Eric Wong
2024-01-31 10:20 ` [PATCH 3/5] scripts/slrnspool2maildir: use MHreader and LeiToMail Eric Wong
2024-01-31 10:20 ` [PATCH 4/5] scripts/import_*: update usage to include lei tips Eric Wong
2024-01-31 10:20 ` [PATCH 5/5] lei: sort MH inputs sequentially by default Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240131102021.1257902-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).