aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
Commit message (Collapse)AuthorAge
* lib/database.cc: coding styleGravatar Chris Wilson2009-11-22
| | | | | | Carl claims he must have been distracted when he wrote this... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Makefile: Magic silent rules.Gravatar Chris Wilson2009-11-22
| | | | | | | | | | | | | Use the facilities of GNU make to create a magic function that will on the first invocation print a description of how to enable verbose compile lines and then print the quiet rule. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Carl Worth <cworth@cworth.org> Cc: Mikhail Gusarov <dottedmag@dottedmag.net> [ickle: Rebased, and duplicate command string eliminated.] [ickle: Fixed verbose bug pointed out by Mikhail]
* add_message: Use sha-1 in place of overly long message ID.Gravatar Carl Worth2009-11-22
| | | | | | | | | | | | | Since Xapian has a limit on the maximum length of a term, we have to check for that before trying to add the message ID as a term. This fixes the bug reported by Mike Hommey here: <20091120132625.GA19246@glandium.org> I've also constructed 20 files with a range of message ID lengths centered around the Xapian term-length limit which I'll use to seed a new test suite soon.
* get_timestamp: Ensure that return value is 0 in case of exception.Gravatar Carl Worth2009-11-22
| | | | Just to be on the safe side of things.
* Catch and optionally print about exception at database->flush.Gravatar Carl Worth2009-11-22
| | | | | | | If an earlier exception occurred, then it's not unexpected for the flush to fail as well. So in that case, we'll silently catch the exception. Otherwise, make some noise about things going wrong at the time of flush.
* Add a missing print after catching an exception.Gravatar Carl Worth2009-11-22
| | | | Without this, trying to debug this exception was *really* confusing.
* Print information about where Xapian exception occurred.Gravatar Carl Worth2009-11-22
| | | | | Previously, our Xapian exception reports where identical so they were hard to track down.
* Fix freak case problem that broke the compile.Gravatar Carl Worth2009-11-21
| | | | | I think I must have bumped some emacs keybinding that changed the case of a word here.
* Rename NOTMUCH_DATABASE_MODE_WRITABLE to NOTMUCH_DATABASE_MODE_READ_WRITEGravatar Carl Worth2009-11-21
| | | | And correspondingly, READONLY to READ_ONLY.
* Permit opening the notmuch database in read-only mode.Gravatar Chris Wilson2009-11-21
| | | | | | | | | We only rarely need to actually open the database for writing, but we always create a Xapian::WritableDatabase. This has the effect of preventing searches and like whilst updating the index. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Carl Worth <cworth@cworth.org>
* When a search query triggers a Xapian exception, log what the query was.Gravatar Eric Anholt2009-11-21
| | | | | | | In my script containing a series of queries to be run on new mail for setting up tags, it's nice to see which query I typed wrong. Signed-off-by: Eric Anholt <eric@anholt.net>
* add_message: Re-fix handling of non-mail files.Gravatar Carl Worth2009-11-20
| | | | | | | | | | | More fallout from _get_header now returning "" for missing headers. The bug here is that we would no longer detect that a file is not an email message and give up on it like we should. And this time, I actually audited all callers to notmuch_message_get_header, so hopefully we're done fixing this bug over and over.
* notmuch_database_add_message: Add missing error-value propagation.Gravatar Carl Worth2009-11-20
| | | | | Thanks to Mike Hommey for doing the analysis that led to noticing that this was missing.
* add_message: Properly handle missing Message-ID once again.Gravatar Carl Worth2009-11-20
| | | | | | | | There's been a fair amount of fallout from when we changed message_file_get_header from returning NULL to returning "" for missing headers. This is yet more fallout from that, (where we were accepting an empty message-ID rather than generating one like we want to).
* Avoid access of a Xapian iterator's object when there's nothing there.Gravatar Carl Worth2009-11-20
| | | | | | | This eliminates a crash when a message (either corrupted or a non-mail file that wasn't properly detected as not being mail) has no In-Reply-To header, (and so few terms that trying to skip to the prefix of the In-Reply-To terms actually brings us to the end of the termlist).
* Allow lone "not" search operatorsGravatar Adrian Perez2009-11-19
| | | | | | | | | | | | | | | | | | As suggested by Keith in FLAG_PURE_NOT allows for expressions like: notmuch search NOT tag:inbox Note that this way a search like: notmuch search foobar NOT tag:inbox should not be written instead: notmuch search foobar AND NOT tag:inbox In my opinion, the latter feels more natural and is somewhat more explicit. It gives a better clue of what the search is about instead of assuming that an implicit AND operator is there.
* TypsosGravatar Ingmar Vanhassel2009-11-18
|
* linke_message: Avoid segfault when In-Reply-to header is empty.Gravatar Carl Worth2009-11-18
| | | | | | | | | | | | | This was recently introduced in commit: 64c03ae97f2f5294c60ef25d7f41849864e6ebd3 which was adding extra checks to avoid adding a self-referencing message. How many times am I going to fix a dumb regression like this and say "we really need a test suite" before I actually sit down and write the test suite?
* notmuch search: Change default search order to be newest messages first.Gravatar Carl Worth2009-11-17
| | | | | | | | | | | | | | | | | This is what most people want for a _search_ command. It's often different for actually reading mail in an inbox, (where it makes more sense to have results displayed in chronological order), but in such a case, ther user is likely using an interface that can simply pass the --sort=oldest-first option to "notmuch search". Here we're also change the sort enum from NOTMUCH_SORT_DATE and NOTMUCH_SORT_DATE_REVERSE to NOTMUCH_SORT_OLDEST_FIRST and NOTMUCH_SORT_NEWEST_FIRST. Similarly we replace the --reverse option to "notmuch search" with two options: --sort=oldest-first and --sort=newest-first. Finally, these changes are all tracked in the emacs interface, (which has no change in its behavior).
* database: Make _parse_message_id static once again.Gravatar Carl Worth2009-11-17
| | | | | | | We had exposed this to the internal implementation for a short time, (only while we had the silly code fetching In-Reply-To values from message files instead of from the database). Make this private again as it should be.
* database: Add "replyto" to the database schema documentation.Gravatar Carl Worth2009-11-17
| | | | | | Maybe ths lack of this documentation is why I forgot we were actually storing this and wrote the ugly code to fetch In-Reply-To from message files rather than from the database.
* database: Rename "ref" prefix name to "reference"Gravatar Carl Worth2009-11-17
| | | | | | | Which is more consistent with the XREFERENCE prefix used in the terms in the database. Also remove some stale documentation describing the removal of resolved references from the database (we no longer do this).
* message_file_get_header: Use break where more clear than continue.Gravatar Carl Worth2009-11-17
| | | | | | Calling continue here worked only because we set a flag before the continue, and, check the flag at the beginning of the loop, and *then* break. It's much more clear to just break in the first place.
* Fix "too many open files" bug by closing message files when done with them.Gravatar Keith Packard2009-11-17
| | | | | | | | | | | | | | | | | | | | | The message file header parsing code parses only enough of the file to find the desired header fields, then it leaves the file open until the next header parsing call or when the message is no longer in use. If a large number of messages end up being active, this will quickly run out of file descriptors. Here, we add support to explicitly close the message file within a message, (_notmuch_message_close) and call that from thread construction code. Signed-off-by: Keith Packard <keithp@keithp.com> Edited-by: Carl Worth <cworth@cworth.org>: Many portions of Keith's original patch have since been solved other ways, (such as the code that changed the handling of the In-Reply-To header). So the final version is clean enough that I think even Keith would be happy to have his name on it.
* add_message: Don't add any self-references to the database.Gravatar Carl Worth2009-11-17
| | | | | | In our scheme it's illegal for any message to refer to itself, (nor would it be useful for anything anyway). Cut these self-references off at the source, before they trip up any internal errors.
* message_get_thread_id: Generate internal error if message has no thread ID.Gravatar Carl Worth2009-11-17
| | | | | | | | | | | This case was happening when a message had its own message ID in its In-Reply-To header. The thread-resolution code would find the partially constructed message, (with no thread ID yet), get garbage from this function, and then march right along with that garbage. With this commit, a self-cyclic message like this will now trigger an internal error rather than marching along silienty. (And a subsequent commit will remove the call to this function in this case.)
* Remove the talloc_owner argument from create_for_message_id.Gravatar Carl Worth2009-11-17
| | | | | | | This function has only one caller, and that one caller was passing the same value for both talloc_owner and the notmuch database. Dropping the redundant argument simplifies the documentation of this function considerably.
* get_in_reply_to: Implement via the database, not by opening mail file.Gravatar Carl Worth2009-11-17
| | | | | | | This reduces our reliance on open message_file objects, (so is a step toward fixing the "too many open files" bug), but more importantly, it means we don't load a self-referencing in-reply-to header, (since we weed those out before adding any replyto terms to the database).
* Fix broken commit.Gravatar Carl Worth2009-11-17
| | | | Oops. I should have actually compiled before pushing.
* Include <stdint.h> to get uint32_t in C++ file with gcc 4.4Gravatar Mikhail Gusarov2009-11-17
| | | | Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
* Close message file after parsing message headersGravatar Mikhail Gusarov2009-11-17
| | | | | | Keeping unused files open helps to see "Too many open files" often. Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
* add_message: Avoid a memory leak when user holds on to message return.Gravatar Carl Worth2009-11-17
| | | | | | | | | | When this function was originally written, the 'message' object was always destroyed locally, so I thought it would be good to use a NULL talloc context to make it more obvious if there was any leak. Since then, however, this function has been changed to optionally return the added message, and in that case we *don't* free the message locally, so let's let the database be the talloc context.
* notmuch show: Implement proper thread ordering/nesting of messages.Gravatar Carl Worth2009-11-15
| | | | | | | | We now properly analyze the in-reply-to headers to create a proper tree representing the actual thread and present the messages in this correct thread order. Also, there's a new "depth:" value added to the "message{" header so that clients can format the thread as desired, (such as by indenting replies).
* Add _notmuch_message_get_in_reply_to.Gravatar Carl Worth2009-11-15
| | | | | | | The existing notmuch_message_get_header is *almost* good enough for this, except that we also need to remove the '<' and '>' delimiters. We'll probably want to implement this function with database storage in the future rather than loading the email message.
* Remove obsolete notmuch_message_get_subject prototype.Gravatar Carl Worth2009-11-15
| | | | | | This prototype has been sitting around for a while with no function implementing it. I wonder if there's a compiler warning I could turn on to catch these things.
* lib/messages: Add new notmuch_message_list_t to internal interface.Gravatar Carl Worth2009-11-15
| | | | | | | | | | | | Previously, the notmuch_messages_t object was a linked list built on top of a linked-list node with the odd name of notmuch_message_list_t. Now, we've got much more sane naming with notmuch_message_list_t being a list built on a linked-list node named notmuch_message_node_t. And now the public notmuch_messages_t object is a separate iterator based on notmuch_message_node_t. This means the interfaces for the new notmuch_message_list_t object are now made available to the library internals.
* database: Fix a typo in a commit.Gravatar Carl Worth2009-11-15
| | | | | Nothing significant here, but we might as well not keep things misspelled when we notice.
* Export _parse_message_id to the library implementation.Gravatar Carl Worth2009-11-15
| | | | | | Not exported through the public interface, but the thread code is going to want to be able to parse In-Reply-To headers so needs access to this code.
* _thread_add_messages: Remove unused variable.Gravatar Carl Worth2009-11-15
| | | | | I'm not sure how I let this warning go by unfixed for a while. Fix it now.
* lib: Move notmuch_messages_t code from query.cc to new messages.cGravatar Carl Worth2009-11-14
| | | | | | | | | | | | | The new object is simply a linked-list of notmuch_message_t objects, (unlike the old object which contained a couple of Xapian iterators). This works now by the query code immediately iterator over all results and creating notmuch_message_t objects for them, (rather than waiting to create the objects until the notmuch_messages_get call as we did earlier). The point of this change is to allow other instances of lists of messages, (such as in notmuch_thread_t), that are not directly related to Xapian search results.
* notmuch_tags_advance: Make safe against excessive calls.Gravatar Carl Worth2009-11-14
| | | | | | Previously, an excess call would have caused a crash. Now it simply does nothing. Also, make notmuch_tags_get use a similar, consistent early return for a NULL iterator.
* notmuch search: Fix thread dates to come only from matched messages.Gravatar Carl Worth2009-11-12
| | | | | | We were properly sorting the threads based only on matched messages, but we were displaying the date based on the total messages in the thread, which led to inconsistent and very confusing results.
* notmuch search: Add support for a --reverse option to reverse sort order.Gravatar Carl Worth2009-11-12
| | | | | | | | | | | | | | Note that the difference between thread results in date order and thread results in reverse-date order is not simply a matter of reversing the final results. When sorting in date order, the threads are sorted by the oldest message in the thread. When sorting in reverse-date order, the threads are sorted by the newest message in the thread. This difference means that we might want an explicit option in the interface to reverse the order, (even though the default will be to display the inbox in date order and global searches in reverse-date order).
* notmuch search: Print the number of matched/total messages for each thread.Gravatar Carl Worth2009-11-12
| | | | | | | | | | | | | | | | | | | Note that we don't print the number of *unread* messages, but instead the number of messages that matched the search terms. This is in keeping with our philosophy that the inbox is nothing more than a search view. If we search for messages with an inbox tag, then that's what we'll get a count of. (And if somebody does want to see unread counts, then they can search for the "unread" tag.) Getting the number of matched messages is really nice when doing historical searches. For example in a search like: notmuch search tag:sent (where the "sent" tag has been applied to all messages originating from the user's email address)---here it's really nice to be able to see a thread where the user just mentioned one point [1/13] vs. really getting involved in the discussion [10/29].
* Use $(MAKE) when invoking make from make.Gravatar Carl Worth2009-11-12
| | | | Without this, things like MAKEFLAGS=-j4 can't work.
* notmuch search: Avoid printing duplicate author names.Gravatar Carl Worth2009-11-12
| | | | | | | | We add a hash to the thread object so that we can detect author names that have already been added to the list, and avoid adding them redundantly. This avoids the giant chain of "bugzilla-daemon, bugzilla-daemon, bugzilla-daemon, bugzilla-daemon, ..." author lists that we would get otherwise, for example.
* notmuch search: Print all authors contributing to a thread.Gravatar Carl Worth2009-11-12
| | | | | | | | We've now expanded the notmuch_thread_create function to fire off a secondary database query to find all the messages that belong to this particular thread. This allows us to now have the complete authors' list for the thread, and will also make it trivial to print accurate message counts for threads in the future.
* notmuch_query_search_threads: Avoid returning more threads than asked for.Gravatar Carl Worth2009-11-12
| | | | | | | | | I thought it would be safe enough to return a few extra threads, (since we happened to already get the relevant messages out of the database). The problem is that then requires the caller to carefully read the number of threads returned and adjust its next "first" value accordingly. The interface is much simpler to use if we simply return exactly what is asked for and no more.
* notmuch search: Fix a second bug in the change to support incremental searches.Gravatar Carl Worth2009-11-12
| | | | | | | The search was dropping the first thread from the results. When am I going to break down and write a test suite? It's long overdue now.
* notmuch search: Fix to actually return something.Gravatar Carl Worth2009-11-12
| | | | | | | This serves me right for committing untested code. The notmuch_query_search_threads was totally broken, (it didn't properly treat -1 as being unlimited and instead returned no threads in that case).