Commit graph

5970 commits

Author SHA1 Message Date
Daniel Kahn Gillmor
eb232ee0ab reindex: drop notmuch_param_t, use notmuch_indexopts_t instead
There are at least three places in notmuch that can trigger an
indexing action:

 * notmuch new
 * notmuch insert
 * notmuch reindex

I have plans to add some indexing options (e.g. indexing the cleartext
of encrypted parts, external filters, automated property injection)
that should properly be available in all places where indexing
happens.

I also want those indexing options to be exposed by (and constrained
by) the libnotmuch C API.

This isn't yet an API break because we've never made a release with
notmuch_param_t.

These indexing options are relevant in the listed places (and in the
libnotmuch analogues), but they aren't relevant in the other kinds of
functionality that notmuch offers (e.g. dump/restore, tagging, search,
show, reply).

So i think a generic "param" object isn't well-suited for this case.
In particular:

 * a param object sounds like it could contain parameters for some
   other (non-indexing) operation.  This sounds confusing -- why would
   i pass non-indexing parameters to a function that only does
   indexing?

 * bremner suggests online a generic param object would actually be
   passed as a list of param objects, argv-style.  In this case (at
   least in the obvious argv implementation), the params might be some
   sort of generic string.  This introduces a problem where the API of
   the library doesn't grow as new options are added, which means that
   when code outside the library tries to use a feature, it first has
   to test for it, and have code to handle it not being available.
   The indexopts approach proposed here instead makes it clear at
   compile time and at dynamic link time that there is an explicit
   dependency on that feature, which allows automated tools to keep
   track of what's needed and keeps the actual code simple.

My proposal adds the notmuch_indexopts_t as an opaque struct, so that
we can extend the list of options without causing ABI breakage.

The cost of this proposal appears to be that the "boilerplate" API
increases a little bit, with a generic constructor and destructor
function for the indexopts struct.

More patches will follow that make use of this indexopts approach.
2017-08-23 07:55:12 -03:00
Daniel Kahn Gillmor
b10ce6bc23 database: add n_d_index_file (deprecates n_d_add_message)
We need a way to pass parameters to the indexing functionality on the
first index, not just on reindexing.  The obvious place is in
notmuch_database_add_message.  But since modifying the argument list
would break both API and ABI, we needed a new name.

I considered notmuch_database_add_message_with_params(), but the
functionality we're talking about doesn't always add a message.  It
tries to index a specific file, possibly adding a message, but
possibly doing other things, like adding terms to an existing message,
or failing to deal with message objects entirely (e.g. because the
file didn't contain a message).

So i chose the function name notmuch_database_index_file.

I confess i'm a little concerned about confusing future notmuch
developers with the new name, since we already have a private
_notmuch_message_index_file function, and the two do rather different
things.  But i think the added clarity for people linking against the
future libnotmuch and the capacity for using index parameters makes
this a worthwhile tradeoff.  (that said, if anyone has another name
that they strongly prefer, i'd be happy to go with it)

This changeset also adjusts the tests so that we test whether the new,
preferred function returns bad values (since the deprecated function
just calls the new one).

We can keep the deprecated n_d_add_message function around as long as
we like, but at the next place where we're forced to break API or ABI
we can probably choose to drop the name relatively safely.

NOTE: there is probably more cleanup to do in the ruby and go bindings
to complete the deprecation directly.  I don't know those languages
well enough to attempt a fix; i don't know how to test them; and i
don't know the culture around those languages about API additions or
deprecations.
2017-08-23 07:38:37 -03:00
Yuri Volchkov
09fa51303c show: workaround for the missing file problem
This patch fixes the 'Deleted first duplicate file does not stop
notmuch show from working' test.

If a message to be shown has several duplicated files, and for some
reason the first file in the list is not available anymore, notmuch
will exit with an error.

This is clearly a problem in the database, but we are not going to let
this problem be a show-stopper. Let's walk through the list, and show
the first existing file.

Signed-off-by: Yuri Volchkov <yuri.volchkov@gmail.com>
2017-08-22 18:48:29 -03:00
Yuri Volchkov
39cc84e9fc test: show id:<> works even if the first duplicate is deleted
Signed-off-by: Yuri Volchkov <yuri.volchkov@gmail.com>
2017-08-22 18:48:19 -03:00
Yuri Volchkov
33a170e116 insert: strip trailing / in folder path
This patch fixes the "Insert message into folder with trailing /"
test. The problem was insufficient path canonization.

From database's point of view, "Sent" and "Sent/" are different
folders. If user runs (note the last '/'):

    notmuch insert --folder=maildir/Sent/ < test.msg

notmuch will create an extra XDIRECTORY record for the folder
'Sent/'. This means that database will have _TWO_ records for _ONE_
physical folder: 'Sent' and 'Sent/'. However, the 'notmuch new'
command will update only records related to the first one (the correct
one).

Now, if user moved the email file (e.g. from 'Sent/new' to
'Sent/cur'), 'notmuch new' will add a record about the new file, but
will not delete the old record.

Signed-off-by: Yuri Volchkov <yuri.volchkov@gmail.com>
2017-08-22 18:48:09 -03:00
Yuri Volchkov
cec4a87539 database: move striping of trailing '/' into helper function
Stripping trailing character is not that uncommon
operation. Particularly, the next patch has to perform it as
well. Lets move it to the separate function to avoid code duplication.

Also the new function has a little improvement: if the character to
strip is repeated several times in the end of a string, function
strips them all.

Signed-off-by: Yuri Volchkov <yuri.volchkov@gmail.com>
2017-08-22 18:47:51 -03:00
David Bremner
49d4f52f27 perf-test: add memory test for notmuch-insert
In the future it might be worthwhile selecting corpus messages to
insert, but that seems a bit overcomplicated for now
2017-08-20 08:48:43 -03:00
David Bremner
6da87a1369 perf-test: renumber tests
One test per number so ordering is clear.
2017-08-20 08:34:12 -03:00
David Bremner
1092c747ef test: move generate_message, add_message into test-lib-common.sh
The plan is to use at least the former in the perf test suite.
2017-08-20 08:34:03 -03:00
Daniel Kahn Gillmor
55f9f6505e lib: clarify description of notmuch_database_add_message
Since we're accumulating the index when we add a new file to the
message, the semantics have slightly changed.  This tries to align the
documentation with the actual functionality.
2017-08-20 08:33:46 -03:00
Vladimir Panteleev
fdf2b3007a emacs: Use make-process when available
make-process is a new function introduced in Emacs 25, which provides
greater control over process creation. Crucially, it allows
separately redirecting stderr directly to a buffer, which allows us to
avoid needing to use the shell to redirect to a temporary file in
order to correctly distinguish stdout and stderr.

* notmuch-lib.el: Use make-process when it is available; fall back to
  the previous method when not.
2017-08-20 08:33:09 -03:00
Vladimir Panteleev
69946c47c9 emacs: Refactor subprocess stderr propagation
Load subprocess error output to a string in the callers, and propagate
the error messages as a string parameter instead of a path to file
names.

Required to be able to avoid using temporary files for subprocess
error output.

* notmuch-lib.el: Update notmuch-check-async-exit-status,
  notmuch-check-exit-status: accept an err parameter instead of
  err-file; shift the responsibility of loading error messages from
  files up the call stack.
2017-08-20 08:32:47 -03:00
Vladimir Panteleev
938ec0f80c doc: Disable SmartyPants in generated manual pages
By default, Sphinx tries to pre-process text through SmartyPants,
which attempts to convert ASCII quotes and dashes to Unicode
characters. Unfortunately, this mangles technical text such as command
lines. For instance, this excerpt from notmuch-tag.rst:

  **notmuch** **tag** **--batch** [--input=<*filename*>]

got turned into:

  notmuch tag –batch [–input=<filename>]

That's an en-dash and an em-dash respectively.

Not only are these characters visually confusing and could easily be
mistaken for a single dash, copying and pasting such command lines
into a terminal is doomed to result in incomprehensible error
messages.

* doc/conf.py: Disable SmartyPants.
2017-08-20 08:32:29 -03:00
Jani Nikula
cb5253578d emacs: set query-context to nil if its "" or "*"
The queries "" and "*" are special cased in the notmuch library to
match all messages, but only if they're the entire query. They can't
be combined with other queries, such as "* AND foo", in which case
they "leak" down to the Xapian query parser.

Notmuch show and tree buffers inadvertently combine the thread query
with said special queries, causing incorrect collapsing of
messages. Handle the special queries specially. We already do a
similar thing in notmuch-search-filter.
2017-08-20 08:32:07 -03:00
Yuri Volchkov
cd8551d53a test: insert into the folder with trailing /
From database's point of view, "Drafts" and "Drafts/" are different
folders

Signed-off-by: Yuri Volchkov <yuri.volchkov@gmail.com>
Amended: add test_subtest_known_broken (db)
2017-08-20 08:28:55 -03:00
Daniel Kahn Gillmor
dea75b5dd6 completion: add bash completion for "notmuch reindex"
The main thing that notmuch reindex does is to use search terms, so we
can reuse a bunch of the existing completion framework.
2017-08-18 19:50:21 -03:00
Daniel Kahn Gillmor
0155411e05 fix typo 2017-08-18 19:47:40 -03:00
Yuri Volchkov
02761b2e5c test: remove remainder of previously killed basic test
In the commit 51cd69feb1 the part of the
test "test runs if prerequisite is satisfied" has been
removed. However, there was a remainder of that test - variable
'haveit'.

Kill it, to not to confuse people.

Signed-off-by: Yuri Volchkov <yuri.volchkov@gmail.com>
2017-08-18 19:45:17 -03:00
Vladimir Panteleev
ca4688e103 Use rooted paths in .gitignore files
A leading / in paths in a .gitignore file matches the beginning of the
path, meaning that for patterns without slashes, git will match files
only in the current directory as opposed to in any subdirectory.

Prefix relevant paths with / in .gitignore files, to prevent
accidentally ignoring files in subdirectories and possibly slightly
improve the performance of "git status".
2017-08-18 19:42:35 -03:00
Vladimir Panteleev
4d44976135 test: Update extant references to corpus.mail
971cdc72cd renamed corpus.mail to
corpora.mail. Although 971cdc72cd
updated some of the remaining corpus.mail references, two remained,
causing the test suite to leave behind an unignored corpora.mail
directory.
2017-08-18 19:42:19 -03:00
Daniel Kahn Gillmor
23eed88e32 remove boolean "first" argument from format_part_sprinter
This argument seems to be unused, and format_part_sprinter isn't
required to meet any specific API so it seems cleaner and simpler to
drop it.
2017-08-16 21:56:58 -03:00
David Bremner
f385055528 test: add test for ,S message without 'unread' in new.tags
This is arguably overkill, but it helps to understand the complicated
interactions here between maildir tags and configuration.
2017-08-16 21:53:43 -03:00
David Bremner
e1f9ab4849 test: add missing quotes in maildir-sync test.
Oops. ';' is significant in the shell. Who knew.
2017-08-16 21:48:51 -03:00
David Bremner
9836a8f42b Merge branch 'release'
merge in debian-only changes
2017-08-16 21:44:43 -03:00
David Bremner
1307868f1e cli/new: improve error reporting
Recently a user reported a crash in notmuch new, but because of
missing error reporting, all they could say was "A Xapian exception
occured". This commit adds the extra information available about
the error message in the exception.
2017-08-16 21:38:54 -03:00
David Bremner
d7b5db32c3 debian: start changelog for next debian upload 2017-08-16 21:38:26 -03:00
Daniel Kahn Gillmor
34e5d4d31a do not use bullets in debian/NEWS
see lintian's debian-news-entry-uses-asterisk for justification
2017-08-16 21:36:06 -03:00
Daniel Kahn Gillmor
56f2f362e1 remove obsolete lintian-override (see https://bugs.debian.org/865055) 2017-08-16 21:34:36 -03:00
David Bremner
84ae74aada uploaded to unstable
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCAAdFiEE3VS2dnyDRXKVCQCp8gKXHaSnniwFAlmS3LAACgkQ8gKXHaSn
 niyTLgv8DZnqoy2Pv0ulDXZTFD9ruPXL2yDI3CJVdDJ6Mc6ku1M/W3fL8DLOmbpo
 mQE6hBTwnx2BbPqbt7yiz0Bidb//YqY/ow2oRbrMb0SxdXZKFcekXiwLiXiO9sXW
 Y1L2bl1hMDEVOYlndDYS5okJHx6AKpLTVUCdXFALl0AD748yHQlSeBXnpA6pNEVr
 TlQrvts14CPMjmyf+OSf1GeWEOObxf5j1iKouEB2IwyqQ08MPuOey7sqtO0jrPHi
 ev4CiV/hveem5Odlh5w1+CF5BTvsW1vbfdSyZ+krjvSk5oBSZrSYHD+y/k1mWBH6
 FCmi5/EYa674r8N12lA+ME7ExHMk40UeBC1+1uba9viR1YfKSkcZTjZnRRf2HvL4
 IxyEr1LUTOnLAlRMYK4huC1vsR4u9WESGppJ1az5yEQwSTIj4uXXi3OmU4c9oLEW
 +WcjqkNFQ6pfaqvjL/nIvvlWqAVhap34thlFOIo0z6850atm+ICGh3NyBl8D798W
 mFG7+NNm
 =vAlG
 -----END PGP SIGNATURE-----

Merge tag 'debian/0.25-6'

uploaded to unstable
2017-08-15 08:38:10 -03:00
David Bremner
6354745dcd debian: actually stop shipping 50notmuch.el 2017-08-15 07:52:47 -03:00
David Bremner
178d62cf9c uploaded to unstable
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCAAdFiEE3VS2dnyDRXKVCQCp8gKXHaSnniwFAlmMPCwACgkQ8gKXHaSn
 nixThAwAgKxHKZDmg1C99HeDxXtyTYdAxcZaRg9+vceiaaeXksmrEM33Ywz9Cl0A
 g6Ozg+QKhn+ZfNMwjZ9gGzejjIqUY0My9Bw0xOniaXkj3oOuIWGQNJ3rgZdV9hGP
 TQ6QRhjllQjqlkbFWJSkj4NruaZPTBTKh6P3W5PsK7AqC4kKP5BijZHi9/b6CCDY
 fOs06fGMgGKGA5J82aBbNLRUN3qmGH4eL4e+ppAyPMlzTxxuXqTMgiGXlaGNJuBt
 Kmgj7ZI/3zWTNhe0rgIR1vMzTwevgCSHgSf/yiGeM5GQDOJ4PnSZjS7LZar682Qf
 nWjknJZXGg7ZB5mvmjlpfv6aDQ5zIwRMnZ9whWXGmKVjalWJolbGf/JYVKHs+QU1
 STx+WalcAjvAaix+Pe5T4k005zn8mwIVxKesJ1An5b2/tdWp0m8dhOacFl1bbpcN
 9RTAO+PWmKnpl9O1C+BIfTW1rNv1IsdGWhX7Ukmt3RG0kigwkU8FjoXKhxNCKzTm
 S20sDqXk
 =TJlv
 -----END PGP SIGNATURE-----

Merge tag 'debian/0.25-5'

uploaded to unstable
2017-08-10 07:08:49 -04:00
David Bremner
68dc19659a debian upload 0.25-5
fix typo in -4
2017-08-10 06:44:07 -04:00
David Bremner
0967e46475 test: add broken tests for maildir syncing
Users should be able to specify synced tags in new.tags
2017-08-06 15:40:28 -04:00
David Bremner
aa2abd2958 uploaded to unstable
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCAAdFiEE3VS2dnyDRXKVCQCp8gKXHaSnniwFAlmE+IIACgkQ8gKXHaSn
 nizz2Qv/VClaGkXw48oJ8CIx/eKgSdYSQs8S2YjtRA/wcQzC5ORUa531hJnMCyiE
 nEJk6y9YJnkArr/lO7bwllBwtmcxjPqXW1V6O4+Zz6Fv2OHm4ZJwcfNgmJlaQzWt
 d4WpdFuA/wXqkcl23rJGNW6VyXc/jG11FoSmhge5ldco2AVvfDyzmjvA8C3wSc0l
 DJsPrzIwnrjvuGaHizoyEenFRTuaQpD76105xW3qiKzXCWg6UTMpxp7G4nNq2OkK
 hD9pv+IUJe2JuLbHAtgfXmZpJaicMNY31YlkQi5hrzVlWxE/ia0CckSxQcf7qYb6
 SCLBogOT1Q7Ik566FdEA6KIRs9bcePluxyNQ9ukFTMfasVtnibX7tVY4T9LWyh3r
 GeBk0nSOPMHc6j4KjIt6YI8p5K1HFWHhTN5ZU/NgnvBFOhHYmc5tqCOAGzX886yb
 pHYPQHRMGdJGMHIb3utnCXDrp0JWlD5vPihFTDfiRxUMokCh5DUpCHaxaCHCqpr7
 4sdsXakb
 =2fD2
 -----END PGP SIGNATURE-----

Merge tag 'debian/0.25-4'

uploaded to unstable
2017-08-04 18:43:33 -04:00
David Bremner
cdfeeda5e4 debian: upload 0.25-4
replace notmuch-emacs with elpa-emacs as a recommend
2017-08-04 18:15:09 -04:00
David Bremner
65b17dab46 uploaded to unstable
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCAAdFiEE3VS2dnyDRXKVCQCp8gKXHaSnniwFAlmDOgMACgkQ8gKXHaSn
 niyZewwAjss63G1DccKBCQRY9FQ/QltrriBRKzzSCjUBUECXvMPuYDlVbrFXxRrS
 bgbAX2rxb+hujJkprJ4+FVDAsiP3WKhwuAcXvQsp7JFn68V1Gu8C9lidzKYeqKQI
 ZpAYYw0/h4Sy+5n72W2vmot5Xb5/8dQ9ktmh/UHNCXk4AbrpHtQPm9j03M/yQZj/
 tSs6+Z23hQf7DjQYmoSG27rdKFXtpIMDoiQiezxoI2VRob6ZmFtebXHLUAQ3H8Pj
 fasJcxywey39y3LlFMAzih2+zdb1Hvh0V5rgyX6Ww2OZJlevHfputjGWZz+cRTgZ
 wDefnv9fxQbqObiy4RWX1oJ5jCKq/onV40h/8x6fJSHIjMmoy8Lz5DNgqzlZ4q3x
 ZsGkFmaNrkxRFpfsPh9KnckjdshAsYuj7DlSqpA9Zq7+iLcfqR+5pPg4V4pfE0vV
 ANAbdprp0qMA0hCVpmW9t3jp8jvgX0UJJqAWVtOTKjIPM4JCDip26Dwz4sq0z9zD
 souH4rlk
 =xFSs
 -----END PGP SIGNATURE-----

Merge tag 'debian/0.25-3'

uploaded to unstable
2017-08-03 10:59:32 -04:00
David Bremner
479b14570b debian: changelog stanza for 0.25-3 2017-08-03 10:43:28 -04:00
David Bremner
0187785414 debian: add maintainer scripts to remove old startup file
We do it for notmuch and notmuch-emacs because the history is a bit
unclear. It seems to be safe to call when that conffile is not owned
by a given package
2017-08-03 10:42:54 -04:00
Daniel Kahn Gillmor
e5beec39d6 add "notmuch reindex" subcommand
This new subcommand takes a set of search terms, and re-indexes the
list of matching messages.
2017-08-01 21:17:47 -04:00
Daniel Kahn Gillmor
5b93fa6e70 lib: add notmuch_message_reindex
This new function asks the database to reindex a given message.
The parameter `indexopts` is currently ignored, but is intended to
provide an extensible API to support e.g. changing the encryption or
filtering status (e.g. whether and how certain non-plaintext parts are
indexed).
2017-08-01 21:17:47 -04:00
David Bremner
34d7753992 lib: add _notmuch_message_remove_indexed_terms
Testing will be provided via use in notmuch_message_reindex
2017-08-01 21:17:47 -04:00
David Bremner
ed4a9082c0 cli/search: print total number of files matched in summary output.
The structured output formats already have all of the filenames. This
is an easy bit of UI change to make the multiple files visible.
2017-08-01 21:17:47 -04:00
David Bremner
50340bcb78 lib: add notmuch_thread_get_total_files
This is relatively inexpensive in terms of run time and implementation
cost as we are already traversing the list of messages in a thread.
2017-08-01 21:17:47 -04:00
David Bremner
8a8e2b11c2 lib: add notmuch_message_count_files
This operation is relatively inexpensive, as the needed metadata is
already computed by our lazy metadata fetching. The goal is to support
better UI for messages with multipile files.
2017-08-01 21:17:47 -04:00
David Bremner
411675a6ce lib: index message files with duplicate message-ids
The corresponding xapian document just gets more terms added to it,
but this doesn't seem to break anything. Values on the other hand get
overwritten, which is a bit annoying, but arguably it is not worse to
take the values (from, subject, date) from the last file indexed
rather than the first.
2017-08-01 21:17:47 -04:00
David Bremner
639aced9c9 test: add known broken tests for duplicate message id
There are many other problems that could be tested, but these ones we
have some hope of fixing because it doesn't require UI changes, just
indexing changes.
2017-08-01 21:17:47 -04:00
David Bremner
4fdabd636e lib: refactor notmuch_database_add_message header parsing
This function is large and hard to understand and modify. Start to
break it down into meaningful pieces.
2017-08-01 21:17:47 -04:00
David Bremner
2f94b3090c lib: factor out message-id parsing to separate file.
This is really pure C string parsing, and doesn't need to be mixed in
with the Xapian/C++ layer. Although not strictly necessary, it also
makes it a bit more natural to call _parse_message_id from multiple
compilation units.
2017-08-01 21:17:47 -04:00
David Bremner
95b52e85b2 lib/n_d_add_message: refactor test for new/ghost messages
The switch is easier to understand than the side effects in the if
test. It also potentially allows us more flexibility in breaking up
this function into smaller pieces, since passing private_status around
is icky.
2017-08-01 21:17:47 -04:00
David Bremner
4034a7cec7 lib: isolate n_d_add_message and helper functions into own file
'database.cc' is becoming a monster, and it's hard to follow what the
various static functions are used for. It turns out that about 1/3 of
this file notmuch_database_add_message and helper functions not used
by any other function. This commit isolates this code into it's own
file.

Some side effects of this refactoring:

- find_doc_ids becomes the non-static (but still private)
  _notmuch_database_find_doc_ids
- a few instances of 'string' have 'std::' prepended, avoiding the
  need for 'using namespace std;' in the new file.
2017-08-01 21:17:47 -04:00