]> Sergey Matveev's repositories - public-inbox.git/log
public-inbox.git
3 years agodoc lei: add manpages for new commands
Kyle Meyer [Mon, 29 Mar 2021 03:11:15 +0000 (23:11 -0400)]
doc lei: add manpages for new commands

3 years agodoc lei: update manpages with new options
Kyle Meyer [Mon, 29 Mar 2021 03:11:14 +0000 (23:11 -0400)]
doc lei: update manpages with new options

3 years agodoc lei: don't render most to-do comments
Kyle Meyer [Mon, 29 Mar 2021 03:11:13 +0000 (23:11 -0400)]
doc lei: don't render most to-do comments

The lei manpages have a number of to-dos, but with the exception of
the lei-q's -tt warning, none of them seem worth displaying to the
reader (and some might not be worth addressing at all).

3 years agodoc lei: drop an unnecessary to-do comment
Kyle Meyer [Mon, 29 Mar 2021 03:11:12 +0000 (23:11 -0400)]
doc lei: drop an unnecessary to-do comment

When a new command is implemented, it is probably clear that it should
be added to lei.pod, but either way, having a to-do comment in lei.pod
isn't likely to help.

3 years agodoc lei: note --stdin shortcut in synopses
Kyle Meyer [Mon, 29 Mar 2021 03:11:11 +0000 (23:11 -0400)]
doc lei: note --stdin shortcut in synopses

3 years agodoc lei-q: fix typo in -tt description
Kyle Meyer [Mon, 29 Mar 2021 03:11:10 +0000 (23:11 -0400)]
doc lei-q: fix typo in -tt description

3 years agotreewide: shorten temporary filename
Eric Wong [Sun, 28 Mar 2021 09:01:24 +0000 (09:01 +0000)]
treewide: shorten temporary filename

File::Temp only requires four 'X' characters (unlike mkstemp(3),
which requires six).  So only so only give it 4 to avoid an
80-column violation and maybe save metadata space on FSes.

3 years agolei: drop coderepo placeholders, submodule TODO
Eric Wong [Sun, 28 Mar 2021 09:01:23 +0000 (09:01 +0000)]
lei: drop coderepo placeholders, submodule TODO

"lei blob" supports --git-dir and -C, and checks if the
current directory has a git directory associated with it.
It will likely support submodules in the future.

I'm inclined to believe declaring coderepos in a command-line
tool is needless clutter and users will rarely want to search
for blobs across different projects when on the command-line.

3 years agolei blob: add remote external support
Eric Wong [Sun, 28 Mar 2021 09:01:22 +0000 (09:01 +0000)]
lei blob: add remote external support

Introduce a new LeiRemote wrapper to provide an internal API
which SolverGit expects.  This lets us use HTTP/HTTPS endpoints
to reconstruct blobs off patches as we would with local
endpoints, just more slowly...

3 years agot/lei_store: ensure LeiSearch responds to ->isrch
Eric Wong [Sun, 28 Mar 2021 09:01:21 +0000 (09:01 +0000)]
t/lei_store: ensure LeiSearch responds to ->isrch

This is needed for SolverGit, at least, and maybe other
bits we share with PSGI in lei.

3 years agolei blob: flesh out help text
Eric Wong [Sun, 28 Mar 2021 09:01:20 +0000 (09:01 +0000)]
lei blob: flesh out help text

This means "lei blob" gets shell completion, too.

3 years agolei help: show "NAME=VALUE" properly for -c
Eric Wong [Sun, 28 Mar 2021 09:01:19 +0000 (09:01 +0000)]
lei help: show "NAME=VALUE" properly for -c

3 years agolei blob: some extra tests
Eric Wong [Sun, 28 Mar 2021 09:01:18 +0000 (09:01 +0000)]
lei blob: some extra tests

Most of it already gets tested since most of the logic is in
SolverGit, but make sure it's all wired up properly to lei.

3 years agolei blob: fail early if no git dirs
Eric Wong [Sun, 28 Mar 2021 09:01:17 +0000 (09:01 +0000)]
lei blob: fail early if no git dirs

This avoids triggering a "BUG:" message in the solver code.

3 years agolei blob: support --no-mail switch
Eric Wong [Sun, 28 Mar 2021 09:01:16 +0000 (09:01 +0000)]
lei blob: support --no-mail switch

It's possible for a abbreviated OID to be resolved unambiguously
to an email before we attempt to look at externals via xsearch;
so provide a way for a user to force searching coderepos.

If hints (--oid-a, --path-a, --path-b) are present, we'll
assume --no-mail by default, otherwise we'll assume the
user wants to look through mail for a matching blob.

3 years agolei blob: dclose if already failed
Eric Wong [Sun, 28 Mar 2021 09:01:15 +0000 (09:01 +0000)]
lei blob: dclose if already failed

We must close the socket to trigger pager exit if blob
reconstruction fails.  Not sure how to test this in the
test suite...

3 years agolei init: split out into separate file
Eric Wong [Sun, 28 Mar 2021 09:01:14 +0000 (09:01 +0000)]
lei init: split out into separate file

This is a rarely-needed command, so keep it separate file
so it's easier-to-find and maybe saves a bit of RAM.

3 years agolei: simplify PktOp callers
Eric Wong [Sun, 28 Mar 2021 09:01:13 +0000 (09:01 +0000)]
lei: simplify PktOp callers

Provide a consistent ->op_wait_event method instead of
forcing callers to loop (or not) at each callsite.
This also avoid a leak possibility by avoiding circular
references.

3 years agotest_common: require_mods bundles
Eric Wong [Sun, 28 Mar 2021 00:17:25 +0000 (00:17 +0000)]
test_common: require_mods bundles

This makes it easier to manage test dependencies on systems
where optional stuff isn't installed.  This fixes some lei tests
which didn't check for Plack before starting -httpd, and ensures
Parse::RecDescent is available for -imapd in case
Mail::IMAPClient stops using it.

3 years agolei mark: relax label requirements
Eric Wong [Sat, 27 Mar 2021 23:22:38 +0000 (23:22 +0000)]
lei mark: relax label requirements

It seems safe to use ALLCAPS labels like "INBOX" with Xapian.
We'll also allow single-character labels.

3 years agolei blob: aka "git-show-harder" for blobs
Eric Wong [Sat, 27 Mar 2021 11:45:51 +0000 (11:45 +0000)]
lei blob: aka "git-show-harder" for blobs

This implements blob reconstruction via SolverGit,
emulating the functionality of /$INBOX/$OID/s/ endpoint
in PublicInbox::WWW.

It uses the current working tree as a coderepo, and
accepts any number of --git-dir=$PATH args.

Remote externals are not yet supported.

v2: use absolute path for git repos

3 years agolei_query: hoist out lxs_prepare
Eric Wong [Sat, 27 Mar 2021 11:45:50 +0000 (11:45 +0000)]
lei_query: hoist out lxs_prepare

We'll be reusing it for "lei blob", as it makes sense
to keep handling of --only, --include, etc. switches
consistent.

3 years agolei help: move "lei help" into LeiHelp.pm
Eric Wong [Sat, 27 Mar 2021 11:45:49 +0000 (11:45 +0000)]
lei help: move "lei help" into LeiHelp.pm

We need to load LeiHelp.pm anyways if somebody calls "lei help",
so save a few kB RAM for users who don't need help.

3 years agolei_ale: do not create store unnecessarily
Eric Wong [Sat, 27 Mar 2021 11:45:48 +0000 (11:45 +0000)]
lei_ale: do not create store unnecessarily

We want to be able to read blobs without writing anything to
disk.

3 years agolei mark: disallow '!' in labels
Eric Wong [Fri, 26 Mar 2021 09:51:26 +0000 (09:51 +0000)]
lei mark: disallow '!' in labels

'!' could wreak havoc if exposed to a shell like bash.  It seems
like a rare character for use in file/directory/mailbox names.

3 years agolei: support /dev/fd/[0-2] inputs and outputs in daemon
Eric Wong [Fri, 26 Mar 2021 09:51:25 +0000 (09:51 +0000)]
lei: support /dev/fd/[0-2] inputs and outputs in daemon

Since lei-daemon won't have the same FDs as the client, we
need to special-case thse mappings and won't be able to open
arbitrary, non-standard FDs.

We also won't attempt to support /proc/self/fd/[0-2] since
that's a Linux-ism.  /dev/fd/[0-2] and /dev/std{in,out,err}
are portable to FreeBSD, at least.  mawk(1) also supports
/dev/std{out,err}, as does gawk(1) (which supports everything
we can support, and arbitrary /dev/fd/$FD).

3 years agolei: do not blindly commit to lei/store on close
Eric Wong [Fri, 26 Mar 2021 09:51:24 +0000 (09:51 +0000)]
lei: do not blindly commit to lei/store on close

It may hide errors/bugs, instead do it explicitly for each
worker that writes to it.  For lei_xsearch, it will be better
to close before spawning the MUA for future use since we may
need it again once the user starts changing keywords.

3 years agolei q: skip lei/store->write_prepare for JSON outputs
Eric Wong [Fri, 26 Mar 2021 09:51:23 +0000 (09:51 +0000)]
lei q: skip lei/store->write_prepare for JSON outputs

JSON outputs won't write to lei/store at all, so there's
no point in forking the store worker if it's not already
running.

LeiSearch object ($lse) is also fork-safe until it opens a
persistent FD for Xapian/SQLite so we can unconditionally
carry it across fork.

3 years agogit-send-email-reply: Append subject
Stavros Ntentos [Fri, 26 Mar 2021 16:31:46 +0000 (18:31 +0200)]
git-send-email-reply: Append subject

I keep copy-pasting the addresses provided,
I keep writing my plaintext reply in a file,
and I keep forgetting to add a subject
(because I am "just" writing a plaintext file)

Teach `git-send-email-reply` to append a `--subject` line.

[ew: avoid URI-encoded subject on command-line, adjust t/reply.t]

Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
3 years agolei: add some labels support
Eric Wong [Fri, 26 Mar 2021 04:29:37 +0000 (06:29 +0200)]
lei: add some labels support

"lei q" now displays labels in JSON output, "lei mark"
can add or remove labels for any messages.

"lei ls-label" is supported, too.

Unfortunately, "lei q" won't hande "kw:" or "L:" for
external messages, they must be imported, first.

3 years agolei: _lei_store: use default even if unconfigured
Eric Wong [Fri, 26 Mar 2021 04:29:36 +0000 (06:29 +0200)]
lei: _lei_store: use default even if unconfigured

Perhaps leistore.dir doesn't need to have a config file
entry if we're using the default location.

v2: "account for unconfigured leistore.dir" (on reuse)

3 years agolei_xsearch: wait for kw updates for non-threaded case, too
Eric Wong [Fri, 26 Mar 2021 04:29:35 +0000 (06:29 +0200)]
lei_xsearch: wait for kw updates for non-threaded case, too

We'll also hoist wait_startq out of the per-message loops
since it's not worth having to check every single message
when filling in smsg info is reasonably fast, anyways.

3 years agot/lei: add more diagnostics for failures
Eric Wong [Thu, 25 Mar 2021 04:20:26 +0000 (06:20 +0200)]
t/lei: add more diagnostics for failures

This seems to error out while looping the test suite and
I'm not 100% sure why.

3 years agot/cmd_ipc: workaround signal handling raciness
Eric Wong [Thu, 25 Mar 2021 04:20:25 +0000 (06:20 +0200)]
t/cmd_ipc: workaround signal handling raciness

Perl can't check for interrupts when inside a blocking syscall,
as there's no self-pipe mechanism inside Perl itself.  So fork
a child and have it repeated kill(2) instead of relying on alarm(3).

3 years agolei import: force store, improve test diagnostics
Eric Wong [Thu, 25 Mar 2021 04:20:24 +0000 (06:20 +0200)]
lei import: force store, improve test diagnostics

"lei import" should never be without a {sto}, and *_done should
not be called multiple times, so ensure we can fail if it's
missing.

Update some existing tests to complain loudly by introducing a
handy "xbail" function which wraps "explain" and BAIL_OUT.
BAIL_OUT was painful to type and concatenating the result of
"explain" doesn't work as I thought it would since "explain"
always returns an array, and BAIL_OUT only accepts a single
scalar arg (unlike "die").

3 years agotests: "check-run" uses persistent lei daemon
Eric Wong [Thu, 25 Mar 2021 04:20:23 +0000 (06:20 +0200)]
tests: "check-run" uses persistent lei daemon

We'll use a lei-daemon if it's already running and
TEST_LEI_DAEMON_PERSIST_DIR is set, but we can also start
one and manage it from t/run.perl

This drops "make check-run TEST_LEI_DAEMON_ONLY=1"
time by ~10% for me.

3 years agot/*: drop unnecessary v1-specific index calls
Eric Wong [Thu, 25 Mar 2021 04:20:22 +0000 (06:20 +0200)]
t/*: drop unnecessary v1-specific index calls

Outside of mirrors, we can -init with indexlevel to avoid
calling -index explicitly.

3 years agolei_mirror: don't show success on failure
Eric Wong [Thu, 25 Mar 2021 04:20:21 +0000 (06:20 +0200)]
lei_mirror: don't show success on failure

While we were exiting with a error code, showing a successful
"# mirrored $URL" message is misleading and wrong.  Don't show
success until everything is complete and the config is written.

3 years agolei add-external: do not initialize writable store
Eric Wong [Thu, 25 Mar 2021 04:20:20 +0000 (06:20 +0200)]
lei add-external: do not initialize writable store

There's no need to create or write lei/store when adding
an external, we just need to write to the config file.

3 years agotest_common: TEST_LEI_ERR_LOUD does not hide path names
Eric Wong [Thu, 25 Mar 2021 04:20:19 +0000 (06:20 +0200)]
test_common: TEST_LEI_ERR_LOUD does not hide path names

We hide paths by default to reduce noise, but we want
noise with loud errors.

3 years agolei: janky $PATH2CFG garbage collection
Eric Wong [Thu, 25 Mar 2021 04:20:18 +0000 (06:20 +0200)]
lei: janky $PATH2CFG garbage collection

We need to rely on this to keep our config cache (and lei_store
pipes) under control with tests each creating a new config and
directory.

3 years agotest_common: cleanup inbox objects after use
Eric Wong [Thu, 25 Mar 2021 04:20:17 +0000 (06:20 +0200)]
test_common: cleanup inbox objects after use

This stops us from leaking some more file handles across
test cases.

3 years agolei-daemon: do not leak FDs on bogus requests
Eric Wong [Wed, 24 Mar 2021 09:23:35 +0000 (14:23 +0500)]
lei-daemon: do not leak FDs on bogus requests

If a client passes us the incorrect number of FDs, we'll vivify
them into PerlIO objects so they can be auto-closed.  Using
POSIX::close was considered, but it would've been more code to
handle an uncommon case.

3 years agolei_mirror: fix circular reference
Eric Wong [Wed, 24 Mar 2021 09:23:34 +0000 (14:23 +0500)]
lei_mirror: fix circular reference

All of our $lei->workers_start callers can simply rely on
that wrapper to do the right thing and pass fields to
->wq_worker_start children, only.

This could manifest as a unbound memory growth if somebody is
constantly mirroring, and was causing tests to get stuck when
experimenting with a persistent lei-daemon for the entire
test suite.

3 years agov2writable: cleanup SQLite handles on --xapian-only
Eric Wong [Wed, 24 Mar 2021 09:23:33 +0000 (14:23 +0500)]
v2writable: cleanup SQLite handles on --xapian-only

I'm not sure exactly why this is needed with run_script
localizing %SIG and everything else, but explictly cleaning up
seems to fix the occasional test failures I see.

Followup-to: 4c6c853494b49368 ("tests: show lsof output on deleted-file-check failures")
3 years agolei_store: give process a better name
Eric Wong [Wed, 24 Mar 2021 09:23:32 +0000 (14:23 +0500)]
lei_store: give process a better name

We'll prioritize the last two components of the path name
("lei/store") since that's how I often refer to the on-disk
location.  Then, show the XDG_DATA_HOME it belongs to in case
a user changes HOME or XDG_* for testing purposes.

3 years agolei: clean up pkt_op consumer on exception, too
Eric Wong [Wed, 24 Mar 2021 09:23:31 +0000 (14:23 +0500)]
lei: clean up pkt_op consumer on exception, too

We need to consistently ensure pkt_op_c doesn't lead to a
long-lived circular reference if an exception is thrown in
pre_augment.  Maybe the API could be better, but this fixes an
FD leak when attempting to --augment a FIFO.

Followup-to: b9524082ba39e665 ("lei_xsearch: cleanup {pkt_op_p} on exceptions")
3 years agolei: update {3} after -C chdirs
Eric Wong [Wed, 24 Mar 2021 09:23:30 +0000 (14:23 +0500)]
lei: update {3} after -C chdirs

This is necessary for lei->rel2abs correctness, and may
eventually be useful if we can use *at syscalls.

3 years agolei: drop circular reference in lei_store process
Eric Wong [Wed, 24 Mar 2021 09:23:29 +0000 (14:23 +0500)]
lei: drop circular reference in lei_store process

I'm not sure if this was causing real problems, but it's sure ugly.

3 years agombox_lock: dotlock: chdir for relative lock paths
Eric Wong [Wed, 24 Mar 2021 09:23:28 +0000 (14:23 +0500)]
mbox_lock: dotlock: chdir for relative lock paths

Since lei-daemon will fchdir on every request, we must ensure
we're in the correct directory before unlink(2) is called,
since we can't use unlinkat(2) from pure Perl.

3 years agods: improve DS->Reset fork-safety
Eric Wong [Wed, 24 Mar 2021 09:23:27 +0000 (14:23 +0500)]
ds: improve DS->Reset fork-safety

None of these fixes affect current public-inbox-* code, or even
normal uses of lei.  However, lei users wanting to switch
between $HOME directories or use alternate store paths may
notice strange behavior and this fixes some of it.

We'll also loop to account for DESTROY callbacks inserting into
container objects and retry appropriately.

3 years agolei: improve management around short-lived workers
Eric Wong [Tue, 23 Mar 2021 11:48:08 +0000 (11:48 +0000)]
lei: improve management around short-lived workers

Instead of creating a short-lived circular reference,
ensure they don't exist in the first place.

Note the following changes to hold an extra ref to $sto:

- $self->_lei_store(1)->write_prepare($self);
+ my $sto = $self->_lei_store(1);
+ $sto->write_prepare($self);

I'm not a perlguts expert, but I actually wanted to switch
to the one-line version for LeiImport, but xt/lei-auth-fail.t
was getting stuck for some reason.  It seems the extra ref
to the LeiStore ($sto) object is necessary.

3 years agolei_input: more common code between <mark|convert|import>
Eric Wong [Tue, 23 Mar 2021 11:48:07 +0000 (11:48 +0000)]
lei_input: more common code between <mark|convert|import>

"lei convert" is actually a bit of the odd one, since
it uses lei2mail for auth, unlike the others.

3 years agolei: persistent workers (lei_store) run in /
Eric Wong [Tue, 23 Mar 2021 11:48:06 +0000 (11:48 +0000)]
lei: persistent workers (lei_store) run in /

Since each lei->event_step can change the directory of
lei-daemon, we need to ensure the lei_store runs in a
directory that is stable.

3 years agotest_common: check lei/errors.log
Eric Wong [Tue, 23 Mar 2021 11:48:05 +0000 (11:48 +0000)]
test_common: check lei/errors.log

This will make it easier to diagnose some large internal
rewrites.

3 years agonet_reader: nntp_each: pass keywords as `undef'
Eric Wong [Tue, 23 Mar 2021 11:48:04 +0000 (11:48 +0000)]
net_reader: nntp_each: pass keywords as `undef'

We'll use `undef' to denote keywords are unknown/unsupported,
instead of an empty arrayref.

This will let callers use the same callback and args for
imap_each.  Passing an empty arrayref to set_eml in LeiStore
causes keywords to be cleared completely, which is not desired
behavior when "lei import" is importing already-seen messages
from NNTP.

3 years agolei: hide *_atfork_child from command-line
Eric Wong [Tue, 23 Mar 2021 06:51:41 +0000 (04:51 -0200)]
lei: hide *_atfork_child from command-line

Otherwise we could get non-sensical results if somebody tries
running "lei atfork_child" from the command-line.

3 years agolei mark: add support for (bash) completion
Eric Wong [Tue, 23 Mar 2021 05:02:18 +0000 (11:02 +0600)]
lei mark: add support for (bash) completion

Only lightly tested, this seems to suffer from the same
problem as external completions for network URLs with
colons in them.  In any case, its usable enough for me.

The core LEI module now supports completions for lazy-loaded
commands, too, so we'll be able to do completions for other
commands more easily.

3 years agolei mark: command for (un)setting keywords and labels
Eric Wong [Tue, 23 Mar 2021 05:02:17 +0000 (11:02 +0600)]
lei mark: command for (un)setting keywords and labels

Only tested for keywords and labels with file inputs, so far;
but it seems to do what it needs to do.  There's a bit more
redundant code than I'd like, and more opportunities for code
sharing in the future

"lei import" will be expanded to support +kw:$KEYWORD and
+L:$LABEL in the future.

3 years agolei import: ignore Status headers in "eml" messages
Eric Wong [Mon, 22 Mar 2021 07:54:02 +0000 (07:54 +0000)]
lei import: ignore Status headers in "eml" messages

Those headers only have meaning with for mboxes.  Don't surprise
users by trying to make sense of a header that is defined for mboxes.

It's possible to send email with (Status|X-Status) headers and
have those headers show up in a recipient's IMAP mailbox.

This was bad because an IMAP user may want to import a single
message through their MUA and pipe its contents to "lei import"
without noticing a mischievious sender stuck "X-Status: F"
(flagged/important) in there.

3 years agolei_input: drop "From " line on single "eml" (message/rfc822)
Eric Wong [Mon, 22 Mar 2021 07:54:01 +0000 (07:54 +0000)]
lei_input: drop "From " line on single "eml" (message/rfc822)

This matches the long-standing behavior of public-inbox-mda,
public-inbox-learn and our other tools.  It is useful because
mutt, "git format-patch", and likely other tools will
pipe a single message with a "From " header line, but with
no further "From " escaping or Content-Length: header.

3 years agolei_input: common filehandle reader for eml + mbox
Eric Wong [Mon, 22 Mar 2021 07:54:00 +0000 (07:54 +0000)]
lei_input: common filehandle reader for eml + mbox

This improve code regularity, and will let us deal with
the "RFC822" messages with "From " line that mutt pipes
to.

3 years agombox_reader: add ->reads method to avoid nonsensical formats
Eric Wong [Mon, 22 Mar 2021 07:53:59 +0000 (07:53 +0000)]
mbox_reader: add ->reads method to avoid nonsensical formats

Relying on UNIVERSAL::can may cause internal helper methods
to be used, which can lead to failures or nonsensical results.

3 years agolei: simplify workers_start and callers
Eric Wong [Mon, 22 Mar 2021 07:53:58 +0000 (07:53 +0000)]
lei: simplify workers_start and callers

Since workers_start is in the common PublicInbox::LEI
package, we can just use \&METHOD_NAME instead of relying
on UNIVERSAL->can to avoid a method dispatch.

Most of our worker code can just use lei->dclose, so default
to doing that unless it's been overridden.

3 years agolei: share input code between convert and import
Eric Wong [Mon, 22 Mar 2021 07:53:57 +0000 (07:53 +0000)]
lei: share input code between convert and import

These commands accept mail the same way, and this forces
us to maintain consistent input format support between
commands.

We'll be using this for "lei mark", too.

3 years agonet_reader: escape nasty chars from Net::NNTP->message
Eric Wong [Mon, 22 Mar 2021 07:53:56 +0000 (07:53 +0000)]
net_reader: escape nasty chars from Net::NNTP->message

Net::Cmd::message (used by Net::NNTP) does no escaping at all,
so "\r" was causing confusing/nonsensical error messages when
I tried to import from the wrong group.

3 years agolei: support -c <name>=<value> to overrides
Eric Wong [Mon, 22 Mar 2021 07:53:55 +0000 (07:53 +0000)]
lei: support -c <name>=<value> to overrides

It's a bit nasty, but seems to mostly work for debugging
IMAP and NNTP commands.

3 years agolei: simplify lazy-loading
Eric Wong [Sun, 21 Mar 2021 11:24:05 +0000 (13:24 +0200)]
lei: simplify lazy-loading

This makes it slightly easier to implement future commands,
since there'll be a couple more relatively self-contained
ones.

3 years agolei: fix some warnings in tests
Eric Wong [Sun, 21 Mar 2021 09:50:47 +0000 (15:50 +0600)]
lei: fix some warnings in tests

And then test the contents of $lei_err to ensure it doesn't
happen again.

We'll also make MboxLock emit nicer warnings without the line
number, since the line number is irrelevant to the user fixing
an mbox lock contention problem.

Finally, we'll also allow showing loud warnings via
TEST_LEI_ERR_LOUD=1

3 years agolei q: fix warning on remote imports
Eric Wong [Sun, 21 Mar 2021 09:50:46 +0000 (15:50 +0600)]
lei q: fix warning on remote imports

This will let us tie keywords from remote externals
to those which only exist in local externals.

3 years agolei import: vivify external-only messages
Eric Wong [Sun, 21 Mar 2021 09:50:45 +0000 (15:50 +0600)]
lei import: vivify external-only messages

Keyword storage for external-only messages was preventing
messages from being explicitly imported.  Teach lei_store
to vivify keyword-only entries into fully-indexed messages
on import.

3 years agosearchview: collapse Message-ID links in summary
Eric Wong [Wed, 17 Mar 2021 18:14:08 +0000 (20:14 +0200)]
searchview: collapse Message-ID links in summary

There's no point in showing duplicate links to the same
Message-ID in summary view.  The per-message page will
note the duplication (if any) separately.

Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20210317132723.xx4klonordhsb6ve@chatter.i7.local/
3 years agolei q: trim JSON output
Eric Wong [Sat, 20 Mar 2021 12:40:31 +0000 (18:40 +0600)]
lei q: trim JSON output

Stop showing `docid' since it's not useful with shards.

`bytes' and `lines' are probably noise, but maybe could be
visible in some "fuller" view.

v2: t/lei_xsearch: fix warnings from {docid} removal

3 years agolei: tie ALE lifetime to config file
Eric Wong [Sat, 20 Mar 2021 10:04:07 +0000 (19:04 +0900)]
lei: tie ALE lifetime to config file

This should make a future change to "lei import" work more
nicely, since we'll be needing ALE to vivify external-only
messages upon explicit "lei import".

3 years agolei_to_mail: match mutt order of status headers
Eric Wong [Sat, 20 Mar 2021 10:04:06 +0000 (19:04 +0900)]
lei_to_mail: match mutt order of status headers

These changes may make it easier to do byte-for-byte comparisons
with mail copied out of mutt, a popular MUA for our target
audience.

mutt currently outputs the 'R' (seen) flag before the 'O'
character in the Status: header.  We'll assume that stays
the case (it has been for a while).

Status now comes before X-Status, also matching mutt behavior.

3 years agolei q: put keywords on one line in --pretty output
Eric Wong [Sat, 20 Mar 2021 10:04:05 +0000 (19:04 +0900)]
lei q: put keywords on one line in --pretty output

Don't waste precious terminal space when there are only a small
number of possible keywords supported/reserved for JMAP.  In the
future, we may implement more sophisticated wrapping for labels,
but it we'll cross tha bridge when we come to it.

3 years agolei q: support vmd for external-only messages
Eric Wong [Sat, 20 Mar 2021 10:04:04 +0000 (19:04 +0900)]
lei q: support vmd for external-only messages

"lei q" now preserves changes per-message keywords across
invocations when it's --output (Maildir or mbox) is reused
(with or without --augment).

In the future, these changes will be monitored via inotify,
EVFILT_VNODE or IMAP IDLE, too.

Unfortunately, this currently prevents "lei import" from ever
importing a message that's in an external.  That will be fixed
in a future change.

3 years agolei: All Local Externals: bare git dir for alternates
Eric Wong [Sat, 20 Mar 2021 10:04:03 +0000 (19:04 +0900)]
lei: All Local Externals: bare git dir for alternates

This will be used for keyword (and label) storage for externals.
We'll be using this to ensure we don't redundantly auto-import
messages into lei/store if they're already in a local external
(they can still be imported explicitly via "lei import").

3 years agolei_store: initialize IPC lock properly
Eric Wong [Sat, 20 Mar 2021 02:38:00 +0000 (07:38 +0500)]
lei_store: initialize IPC lock properly

This was causing errors in a mass keyword import patch
I'm working on.

3 years agomaildir: avoid redundant slashes
Eric Wong [Sat, 20 Mar 2021 00:56:33 +0000 (20:56 -0400)]
maildir: avoid redundant slashes

Redundant slashes look ugly in strace(1) output.

3 years agolei q: -I/--include overrides --no-(external|local|remote)
Eric Wong [Fri, 19 Mar 2021 22:38:49 +0000 (20:38 -0200)]
lei q: -I/--include overrides --no-(external|local|remote)

Assume that anybody using -I/--include for external locations
will want to override --no-$FOO if they're explicitly including
a location.

With some effort, we could make it order-dependent (e.g.
"-I $LOCATION --no-$FOO" and "--no-$FOO -I $LOCATION"
behave differently).  However that's not straightforward
when using Getopt::Long to parse command-line options into
a hashref.

I'm also not sure if order-dependent switches are a desirable
UI/UX quality.

3 years agoconfig: ignore extindex entries with newlines in paths
Eric Wong [Fri, 19 Mar 2021 12:35:57 +0000 (10:35 -0200)]
config: ignore extindex entries with newlines in paths

git 2.11 and earlier could not handle git directories with
newlines in them, nor does libgit2 support them.

Followup-to: d87dd0e679587043 ("config: reject `\n' in `inboxdir'")
3 years agolei: disallow "\n" in local externals paths
Eric Wong [Fri, 19 Mar 2021 12:35:56 +0000 (10:35 -0200)]
lei: disallow "\n" in local externals paths

git 2.11 and earlier could not handle git directories with
newlines in them, nor does libgit2 support them.

Followup-to: d87dd0e679587043 ("config: reject `\n' in `inboxdir'")
3 years agoxt/create-many-inboxes: adjust for detect_nproc, no fsync
Eric Wong [Fri, 19 Mar 2021 04:22:58 +0000 (07:22 +0300)]
xt/create-many-inboxes: adjust for detect_nproc, no fsync

detect_nproc is in the IPC module, now; and we can safely
disable fsync when creating test data.
And "modernize" up to 5.10.1 while we're at it.

The use fsync was causing this to run for hours instead
of minutes since I forgot to use eatmydata.

3 years agodoc: glossary: add missing over/back POD directives
Eric Wong [Fri, 19 Mar 2021 04:21:03 +0000 (07:21 +0300)]
doc: glossary: add missing over/back POD directives

Oops :x

3 years agolei_overview: unnecessary g2m capture
Eric Wong [Fri, 19 Mar 2021 04:20:32 +0000 (07:20 +0300)]
lei_overview: unnecessary g2m capture

Nothing like the -Wunused C compiler flag in perl, AFAIK...

3 years agoexamples: cgit-commit-filter: drop <tt> HTML tag, use title=
Eric Wong [Fri, 19 Mar 2021 04:18:54 +0000 (04:18 +0000)]
examples: cgit-commit-filter: drop <tt> HTML tag, use title=

<tt> doesn't seem necessary and it's deprecated in HTML, nowadays.
In any case, dillo's CSS support seems to show it as fixed-width
even without <tt>.  Use the title= attribute to highlight that
it goes to the mail thread, too.

In the future, we'll probably link to something like "lei p2q"
(patch-to-query) to include OIDs in the search.

3 years agocgit: fix fallout from lazy coderepo loading
Eric Wong [Thu, 18 Mar 2021 23:27:51 +0000 (23:27 +0000)]
cgit: fix fallout from lazy coderepo loading

We can't completely instantiate our cgit wrapper without knowing
knowing cgit locations for serving static content.

Fixes: a5968dc059f655a ("config: lazy-load coderepos, support extindex")
3 years agolei_store: keywords => vmd (volatile metadata), prepare for labels
Eric Wong [Wed, 17 Mar 2021 09:39:22 +0000 (15:39 +0600)]
lei_store: keywords => vmd (volatile metadata), prepare for labels

Since keywords and mailboxes (AKA labels) are separate things in
JMAP; and only keywords can map reliably to Maildir and mbox;
we'll keep them separate in our internal data representations,
too.

I initially wanted to call this just "meta" for "metadata", but
that might be confused with our mailing list name.  "metadata"
is already used in Xapian's own API, to add another layer of
confusion.

"tags" was also considered, but probably confusing to notmuch
users since our "labels" are analogous to "tags" in notmuch,
and notmuch doesn't seem to cover "keywords" separately...

So "vmd" it is, since we haven't used this particular
three-letter-abbreviation anywhere before; and "volatile" seems
like a good description of this metadata since everything else
up to this point has been mostly WORM (write-once, read-many).

3 years agotests: show lsof output on deleted-file-check failures
Eric Wong [Wed, 17 Mar 2021 07:02:18 +0000 (23:02 -0800)]
tests: show lsof output on deleted-file-check failures

This may help track down some occasional test failures I'm
seeing.

3 years agowww: improve visibility of coderepos
Eric Wong [Wed, 17 Mar 2021 07:02:17 +0000 (23:02 -0800)]
www: improve visibility of coderepos

By adding "+code" next to "mirror" at the top next to the search
box.  Instead of showing "/path/to/$FOO", showing "$FOO.git"
makes it more obvious we're talking about a git repo, here,
instead of some random directory.

3 years agoconfig: lazy-load coderepos, support extindex
Eric Wong [Wed, 17 Mar 2021 07:02:16 +0000 (23:02 -0800)]
config: lazy-load coderepos, support extindex

Extsearch objects are duck-types of Inbox objects, and
are capable of supporting code repos all the same.

3 years agoextindex: add some validation and config knobs for WWW
Eric Wong [Wed, 17 Mar 2021 07:02:15 +0000 (23:02 -0800)]
extindex: add some validation and config knobs for WWW

We'll try to share a bit more configuration with
extindex entries for WWW PSGI usage.

3 years agowww_stream: add trailing slash for help and color links
Eric Wong [Wed, 17 Mar 2021 07:02:14 +0000 (23:02 -0800)]
www_stream: add trailing slash for help and color links

This saves clients a redirect

3 years agoeml: decode Bcc, and Resent-* address variants
Eric Wong [Tue, 16 Mar 2021 10:28:50 +0000 (16:28 +0600)]
eml: decode Bcc, and Resent-* address variants

This is closer to matching RFC 8621 section 4.1.2.3,
though we don't support the "Any header field not defined in
RFC5322 or RFC2369" rule, since that could get tricky...

3 years agolock: remove new_tmp method
Eric Wong [Tue, 16 Mar 2021 09:14:28 +0000 (03:14 -0600)]
lock: remove new_tmp method

Unused as of commit dda8237aeb5722b3a48c31896d9b7398e50823f1
("lei_to_mail: prepare for worker offload") when we switched
to using the LeiOverview output lock.

3 years agogit: drop async_prefetch method
Eric Wong [Tue, 16 Mar 2021 08:48:07 +0000 (03:48 -0500)]
git: drop async_prefetch method

That logic is inlined directly into git_async_prefetch
in GitAsyncCat and I don't see it being useful outside
of a DS event loop.

3 years agonntp: remove unused header_append method
Eric Wong [Tue, 16 Mar 2021 08:48:06 +0000 (03:48 -0500)]
nntp: remove unused header_append method

It was unused since 1bf653ad139bf7bb3d853ab0b5eae3eaa1b13a95
("nntp+www: drop List-* and Archived-At headers")

3 years agolei_store: remove maildir_keywords
Eric Wong [Tue, 16 Mar 2021 01:43:45 +0000 (07:43 +0600)]
lei_store: remove maildir_keywords

It's redundant and the same functionality is in MdirReader.

3 years agombox: move mbox_keywords to MboxReader
Eric Wong [Tue, 16 Mar 2021 01:43:44 +0000 (07:43 +0600)]
mbox: move mbox_keywords to MboxReader

MboxReader is a more appropriate place for it than LeiStore.