From 58fea974d2857c69e15d974cb62f8cabeeb32792 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 31 Jan 2024 10:20:20 +0000 Subject: lei: sort MH inputs sequentially by default MH sequence numbers can be analogous to IMAP UIDs and NNTP article numbers (or more like IMAP MSNs with clients which pack). In any case, sort then numerically by default to avoid surprising users who treat NNTP spools and mlmmj archives as MH folders. This gives more coherent git history and resulting NNTP/IMAP numbering when round-tripping MH -> v2 -> (NNTP|IMAP) -> MH --- lib/PublicInbox/LeiInput.pm | 2 +- lib/PublicInbox/MHreader.pm | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm index 947a7a79..d003d983 100644 --- a/lib/PublicInbox/LeiInput.pm +++ b/lib/PublicInbox/LeiInput.pm @@ -242,7 +242,7 @@ sub input_path_url { } } elsif (-d _ && $ifmt eq 'mh') { my $mhr = PublicInbox::MHreader->new($input.'/', $lei->{3}); - $mhr->{sort} = $lei->{opt}->{sort}; + $mhr->{sort} = $lei->{opt}->{sort} // [ 'sequence']; $mhr->mh_each_eml($self->can('input_mh_cb'), $self, @args); } elsif (-d _ && $ifmt =~ /\A(?:v1|v2)\z/) { my $ibx = PublicInbox::Inbox->new({inboxdir => $input}); diff --git a/lib/PublicInbox/MHreader.pm b/lib/PublicInbox/MHreader.pm index 033aa740..3e7bbd5c 100644 --- a/lib/PublicInbox/MHreader.pm +++ b/lib/PublicInbox/MHreader.pm @@ -54,7 +54,8 @@ sub mh_each_file { opendir(my $dh, my $dir = $self->{dir}); my $restore = PublicInbox::OnDestroy->new($$, \&chdir, $self->{cwdfh}); chdir($dh); - if (defined(my $sort = $self->{sort})) { + my $sort = $self->{sort}; + if (defined $sort && "@$sort" ne 'none') { my @sort = map { my @tmp = $_ eq '' ? ('sequence') : split(/[, ]/); # sorting by name alphabetically makes no sense for MH: -- cgit v1.2.3-24-ge0c7