David Bremner [Sat, 15 May 2021 13:05:07 +0000 (10:05 -0300)]
test: add known broken test for duplicate thread-id terms
According to my bijection, this bug has been present since commit 411675a6ce in 2017. It is not completely clear what harm it causes in
regulary use, but it (at least) makes notmuch crash when compiled with
-DDEBUG_DATABASE_SANITY.
David Bremner [Sat, 8 May 2021 13:57:35 +0000 (10:57 -0300)]
perf-test/T00-new: fix backup creation.
"xargs tar cf backup.tar < $manifest" recreates the tar file with each
"batch" execed by xargs. In general this results in only a fraction of
the desired files being backed up.
Jani Nikula [Tue, 18 May 2021 21:40:44 +0000 (00:40 +0300)]
doc: fix man page build for Sphinx 4.x
Sphinx 4.0 changed the default value of man_make_section_directory
from False to True. We create the section directories and move the
files manually, so fix the immediate man build failure by disabling
the feature.
The Sphinx documentation on this [1] is confusing, and has the change
backwards. Git history says the default changed from False to True.
David Bremner [Mon, 10 May 2021 10:39:18 +0000 (07:39 -0300)]
lib/open: restore default database path of $HOME/mail
Although this default worked for "notmuch config get", it didn't work
most other places. Restore the previous functionality, with the
wrinkle that XDG locations will shadow $HOME/mail if they exist.
This fixes a bug reported by Jack Kamm in id:87eeefdc8b.fsf@gmail.com
Kyle Meyer [Sat, 8 May 2021 12:11:12 +0000 (09:11 -0300)]
emacs: restore tag-changes and query bindings for tag hooks
notmuch-before-tag-hook and notmuch-after-tag-hook are supposed to
have access to two dynamic variables, tag-changes and query, but these
were lost with the switch to lexical binding in fc4cda07 (emacs: use
lexical-bindings in all libraries, 2021-01-13).
Add a variant of Emacs's dlet (not available until Emacs 28) and use
it in notmuch-tag to expose tag-changes and query to the hooks.
Michael J Gruber [Tue, 11 May 2021 20:48:52 +0000 (22:48 +0200)]
test: change database from within pre-new hook
Due to the change in the config system, notmuch keeps a notmuch database
open when it would not do so before. Consequently, it can miss changes
to the database which are done from a hook (while notmuch holds the
databse in read only mode). When notmuch itself writes to the database
after that it uses wrong assumptions about the last used doc id etc.
Demonstrate this by triggering an assertion. (This new test succeeds
with notmuch 0.31.4.)
Signed-off-by: Michael J Gruber <git@grubix.eu> Amended-by: db. Check for both messages
David Bremner [Fri, 7 May 2021 00:16:38 +0000 (21:16 -0300)]
lib/config: canonicalize paths relative to $HOME.
Prior to 0.32, notmuch had the (undocumented) behaviour that it
expanded a relative value of database.path with respect to $HOME. In
0.32 this was special cased for database.path but broken for
database.mail_root, which causes problems for at least notmuch-new
when database.path is set to a relative path.
The change in T030-config.sh reflects a user visible, but hopefully
harmless behaviour change; the expanded form of the paths will now be
printed by notmuch config.
test: check for GNU parallel with --version options
The lastest versions of GNU parallel no longer make mention of GNU
within their help output. This causes the test script to mistakenly use
the moreutils parallel execution. In order to fix this, while
maintaining compatibility with previous versions of GNU parallel,
--version should be used.
When compat canonicalize_file_name was introduced, it was limited to
C code only because it was used by C code only during that time.
>From 5ec6fd4d, (lib/open: check for split configuration when creating
database., 2021-02-16), lib/open.cc, which is C++, relies on the
existent of canonicalize_file_name.
However, we can't blindly enable canonicalize_file_name for C++ code,
because different implementation has different additional signature for
C++ and users can arbitrarily add -DHAVE_CANONICALIZE_FILE_NAME=0 to
{C,CXX}FLAGS.
Let's move our implementation into a util library.
Helped-by: Tomi Ollila <tomi.ollila@iki.fi> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
David Bremner [Sat, 20 Mar 2021 13:10:52 +0000 (10:10 -0300)]
lib/n_d_index_file: check return value from _n_m_add_filename
Ignoring this return value seems like a bad idea in general, and in
particular it has been hiding one or more bugs related to handling
long directory names.
lib/open.cc:_load_key_file will only open xdg-config files in
$XDG_CONFIG_HOME if it's defined, $HOME/.config will be considered if
and only if XDG_CONFIG_HOME not defined.
Let's unset said variable before running the test.
David Bremner [Fri, 16 Apr 2021 12:00:39 +0000 (09:00 -0300)]
lib: directly traverse postlists in _n_message_delete
This is intended to fix the slow behaviour of "notmuch new" (and possibly
"notmuch reindex") when large numbers of files are deleted.
The underlying issue [1] seems to be the Xapian glass backend spending
a large amount of time in db.has_positions when running queries with
large-ish amounts of unflushed changes.
This commit removes two uses of Xapian queries [2], and replaces them with
an approximation of what Xapian would do after optimizing the
queries. This avoids the calls to has_positions (which are in any case
un-needed because we are only using boolean terms here).
[1] Thanks to "andres" on IRC for narrowing down the performance
bottleneck.
[2] Thanks to Olly Betts of Xapian fame for talking me a through a fix
that does not require people to update Xapian.
David Bremner [Fri, 16 Apr 2021 12:00:38 +0000 (09:00 -0300)]
perf-tests: add test for removing files.
Without the proposed fix for deletion performance [1], this test is
probably unreasonably slow compared to others at the same
small/medium/large scale.
David Bremner [Sat, 13 Mar 2021 12:43:37 +0000 (08:43 -0400)]
test: put shim at end of LD_PRELOAD path
Certain tools like the address-sanitizer fail if they are not the
first LD_PRELOADed library. It does not seem to matter for our shims,
as long as they are loaded before libnotmuch.
David Bremner [Sat, 27 Feb 2021 14:11:23 +0000 (10:11 -0400)]
CLI: rename notmuch_config_t to notmuch_conffile_t
The name is a compromise between keeping function names from getting
too long, and avoiding confusion with the newer notmuch_config library
API. Try to make clear that the residual functionality is only about
updating configuration files.
David Bremner [Thu, 25 Feb 2021 12:00:26 +0000 (08:00 -0400)]
CLI/config: support set/get with split configuration
There are two small code changes. The main one is to retrieve the
possibly updated config file name found during the database opening
call. The second change is to allow empty config file names, as
a (currently broken) way of specifying that configuration should only
be taken from the database.
David Bremner [Sun, 21 Feb 2021 11:34:52 +0000 (07:34 -0400)]
lib: provide notmuch_config_path
Since the library searches in several locations for a config file, the
caller does not know which of these is chosen in the usual case of
passing NULL as a config file. This changes provides an API for the
caller to retrieve the name of the config file chosen. It will be
tested in a following commit.
David Bremner [Tue, 23 Feb 2021 20:19:13 +0000 (16:19 -0400)]
CLI+lib: detect missing database in split configurations.
Eventually we want to do all opening of databases in the top
level (main function). This means that detection of missing databases
needs to move out of subcommands. It also requires updating the
library to use the new NO_DATABASE status code.
David Bremner [Fri, 19 Feb 2021 12:41:36 +0000 (08:41 -0400)]
CLI/config: default to storing all config in external files
Previously the fact that some configuration options were only stored
in the database (and thus editing the config file had no effect) was a
source of user confusion. This was fixed with the series ending at d9af0af1646.
On the other hand, the underlying partition of config options into
those stored by default in the database and those stored in the config
file remained. This is also confusing, since now some invocations of
"notmuch config set" modify the config file, and others silently
modify the database instead.
With this commit, it is up to the user to decide which configuration
to modify. A new "--database" option is provided for notmuch config to
enable modifying the configuration information in the database;
otherwise the default is to update an external config file.
David Bremner [Tue, 23 Feb 2021 13:22:37 +0000 (09:22 -0400)]
CLI/notmuch: switch notmuch_command to notmuch_config_get
The goal at this point is to remove the dependence on
notmuch_config_get_* without breaking any existing functionality. This
is a step towards removing notmuch_config_get_* in a future commit.
David Bremner [Sat, 13 Feb 2021 17:49:32 +0000 (13:49 -0400)]
CLI/setup: switch to new configuration framework
Most of the changes are the elimination of notmuch_config_t accessor
use. We also migrate some of the diagnostics to the top level where we
are opening the files in question.
David Bremner [Sat, 13 Feb 2021 13:01:50 +0000 (09:01 -0400)]
CLI/config: use merged config for "config get"
This commit starts the conversion of notmuch-config.c
functionality (as opposed to just interface) to the new config
framework.
The change to T030-config is because of the move of the
canonicalization database paths from the notmuch_config_t accessor to
the internal function _choose_database_path.
David Bremner [Wed, 3 Mar 2021 12:31:44 +0000 (08:31 -0400)]
lib/open: canonicalize relative path read from config file
This matches functionality in the the CLI function
notmuch_config_get_database_path, which was previously used in the CLI
code for all calls to open a database.
David Bremner [Sun, 14 Feb 2021 11:42:58 +0000 (07:42 -0400)]
lib/config: add config_pairs iterators
The layer of shims here seems a bit wasteful compared to just calling
the corresponding string map functions directly, but it allows control
over the API (calling with notmuch_database_t *) and flexibility for
future changes.
David Bremner [Sat, 27 Mar 2021 12:12:28 +0000 (09:12 -0300)]
lib/open: fix leaks calling _trial_open
_trial_open can't know if the PATH_ERROR return value will cause the
error message to be returned from the library, so it's up the caller
to clean up if not.
David Bremner [Wed, 17 Feb 2021 15:26:15 +0000 (11:26 -0400)]
CLI/new: use configuration variable for backup directory
The stat is essentially replaced by the mkdir for error detection
purposes. This changes the default location for backups to make
things tidier, even in non-split configurations. Hopefully there is
not too many user scripts relying on the previous location.
Because the default location may not exist, replace the use of stat
for error detection with a call to mkdir.
David Bremner [Wed, 17 Feb 2021 15:04:54 +0000 (11:04 -0400)]
lib/config: add configuration variable for backup directory
Like the hook directory, we primarily need a way to communicate this
directory between various components, but we may as well let the user
configure it.
Most of the diff is generalizing choose_hook_dir to work for both
backup and hook directories.
David Bremner [Sat, 9 Jan 2021 11:29:07 +0000 (07:29 -0400)]
CLI/insert: support split database and mail root
The new test is in T055-path-config because it uses the helper
function split_config, and because it seems easier to put the
database path related tests in one place.
David Bremner [Mon, 4 Jan 2021 00:04:46 +0000 (20:04 -0400)]
lib/open: support XDG_DATA_HOME as a fallback database location.
This changes some error reporting, either intentionally by reporting
the highest level missing directory, or by side effect from looking in
XDG locations when given null database location.
David Bremner [Sat, 9 Jan 2021 11:25:25 +0000 (07:25 -0400)]
CLI/new: support split database and mail location
This adds new state variable for the mail root, and uses it most
places db_path was used. The notable exception is dumps from
backups. The latter will be dealt with properly in a future commit.
David Bremner [Wed, 17 Feb 2021 00:08:23 +0000 (20:08 -0400)]
lib/open: check for split configuration when creating database.
The main functionality will be tested when notmuch-new is converted to
support split configuration. Here only the somewhat odd case of split
mail root which is actually symlinked to the database path is tested.
David Bremner [Thu, 31 Dec 2020 22:20:31 +0000 (18:20 -0400)]
lib: support splitting mail from database location.
Introduce a new configuration value for the mail root, and use it to
locate mail messages in preference to the database.path (which
previously implied the mail messages were also in this location.
Initially only a subset of the CLI is tested in a split
configuration. Further changes will be needed for the remainder of the
CLI to work in split configurations.
David Bremner [Sat, 30 Jan 2021 17:57:32 +0000 (13:57 -0400)]
lib/open: factor out the second half of n_d_open_with_config
The idea is to allow reuse in n_d_create_with_config. This is
primarily code movement, with some changes in error messages to reduce
the number of input parameters.
David Bremner [Fri, 29 Jan 2021 11:44:18 +0000 (07:44 -0400)]
lib/open: factor out library initialization
This is slightly more tidy, but more importantly it allows for re-use
of this code in n_d_create_with_config. That re-use will be crucial
when we no longer call n_d_open_with_config from
n_d_create_with_config.
David Bremner [Tue, 2 Feb 2021 20:43:58 +0000 (16:43 -0400)]
lib: remove "path" from notmuch struct
This removes duplication between the struct element and the
configuration string_map entry. Create a simple wrapper for setting
the database path that makes sure the trailing / is stripped.
David Bremner [Sat, 6 Feb 2021 22:50:20 +0000 (18:50 -0400)]
CLI/show: complete conversion to new configuration framework.
In order to open the database in main() for this command, we may need
to re-open it in the (possibly less common) case where crypto options
require write access.