test/multipart: test for absence of "Non-text part:" lines in reply for multipart/* and message/rfc822 parts
There's no reason to output "Non-text part:" lines for parts that are
not leaf nodes, eg. multipart/* and message/rfc822. We fix the text
here to test for their absence. The next patch will fix reply
accordingly.
Technically, this is a superfluous change, as the self.status variable
currently gets set in NotmuchErrors's __new__ function. However, in the
long run I would like to get rid of the weird __new__ implementation which
might be somewhat confusing for users (NotmuchError(status) returns a
different class, e.g. OutOfMemoryError)
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
python: help function Query._assert_query_is_initialized
Remove code duplication by using the new helper function. Also raise the
new fine grained exceptions in many cases, rather than the more generic
NotmuchErrors.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Catch up with the major version bump. I wonder if this could somehow be
automatically made the correct version number. Oh well, I hope it
doesn't change too often :-).
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
David Bremner [Tue, 4 Oct 2011 17:01:21 +0000 (14:01 -0300)]
debian: update packaging for new soname
we need
- a new changelog stanza, because the symbols files need a new version
- s/libnotmuch1/libnotmuch2/ everywhere
- update symbols file, s/.so.1/.so.2/, and bump minimum versions on changed
symbols (although the latter is just documentation)
David Bremner [Tue, 4 Oct 2011 16:47:04 +0000 (13:47 -0300)]
lib: bump SONAME
Based on discussions with amdragon, tschwinge, and others on IRC, I concluded that
1) symbol versioning was probably overkill for libnotmuch
2) It was also probably GNU ld specific
3) Most importantly, nobody could tell me on short notice how exactly it works.
So since the change to the notmuch_database_find_message breaks the
previous ABI, we need to bump the SONAME.
Ali Polatel [Tue, 4 Oct 2011 13:48:34 +0000 (16:48 +0300)]
ruby: Really add wrappers for database_find_message*
Commit 898613116db746aa0f915ae43da8aba28545203d only added wrapper
functions but did not register them. Register the functions in module's
initialization function.
Ali Polatel [Tue, 4 Oct 2011 13:06:20 +0000 (16:06 +0300)]
ruby: Add wrappers for database_find_message*
Two new wrappers:
Notmuch::Database.find_message(id) => Notmuch::Message or nil
Notmuch::Database.find_message_by_filename(path) => Notmuch::Message or nil
Ali Polatel [Tue, 4 Oct 2011 04:55:29 +0000 (07:55 +0300)]
lib: make find_message{,by_filename) report errors
Previously, the functions notmuch_database_find_message() and
notmuch_database_find_message_by_filename() functions did not properly
report error condition to the library user.
For more information, read the thread on the notmuch mailing list
starting with my mail "id:871uv2unfd.fsf@gmail.com"
Make these functions accept a pointer to 'notmuch_message_t' as argument
and return notmuch_status_t which may be used to check for any error
condition.
restore: Modify for the new notmuch_database_find_message()
new: Modify for the new notmuch_database_find_message_by_filename()
Thomas Jost [Fri, 30 Sep 2011 10:16:47 +0000 (12:16 +0200)]
python: fix Message.get_filenames()
Previously, the Filenames generator only yielded *one* filename before
returning, making Message.get_filenames() behave as Message.get_filename(). This
commit fixes this incorrect behavior: now the generator yields all the
filenames, as expected.
Sebastian Spaeth [Fri, 30 Sep 2011 14:04:42 +0000 (16:04 +0200)]
python: rework creating of Subclasses
Add some smart magic, so that when we invoke a
NotmuchError(STATUSVALUE), a nicely derived subclass is created, e.g. a
OutOfMemoryError. This way users can easily distinguish between error
types, while still catching NotmuchError.
I have tested this, and hope it works for others too.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
To make the exception handling more effective in code using the
python bindings it is necessary to differentiate between the
different kind of failures.
Add an exception class for each status code and add a decode
classmethod to the NotmuchError class that acts as a factory.
Import the new classes in __init__.py so they can be easily
imported by anyone.
Patch modifed by Sebastian Spaeth.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Sebastian Spaeth [Thu, 29 Sep 2011 08:47:28 +0000 (10:47 +0200)]
python: Improve code documentation
1) Fix added .gitignore from commit dc8a1745 to work on the docs folder
2) Improve in-code developer documentation to produce better
sphinx-generated documentation. No code changes.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Sebastian Spaeth [Thu, 29 Sep 2011 07:55:14 +0000 (09:55 +0200)]
NEWS: Note implementation bug for python binding
Make note that find_message_by_name currently crashes the python process
if the Database is READ-ONLY. This should be fixed in the underlying
libnotmuch.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
python: add a .gitignore file and refine the toplevel one
The line 'notmuch' in the toplevel .gitignore file is to broad
and matches bindings/python/notmuch making it cumbersome to
git-add files within that directory.
Refine the toplevel file to only match the generated notmuch
executable and add a more specialized .gitignore file to the
python directory.
Sebastian Spaeth [Wed, 28 Sep 2011 15:50:57 +0000 (17:50 +0200)]
python: add begin|end_atomic bindings
* Add UNBALANCED_ATOMIC status code
Catch up with the notmuch status codes, and add the UNBALANCED_ATOMIC
one.
* Add the begin_atomic and end_atomic calls to libnotmuch
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
David Bremner [Sun, 25 Sep 2011 01:45:33 +0000 (22:45 -0300)]
test: make atomicity setup conditional on gdb being present.
The setup is useless if gdb is not present, so it doesn't hurt to skip
it. The diff here is huge, but the commit is really just moving most
of the script inside the initial if, and adding an else block to print
a warning.
David Bremner [Sat, 24 Sep 2011 18:37:27 +0000 (14:37 -0400)]
debian: set versioned dependency on notmuch for notmuch-emacs
As long as we have no version information in the json output, this
seems like the only possible way of ensuring that the emacs client
code understands the output from the command line tool notmuch.
State up front that these functions may add a filename to an existing
message or remove only a filename (and not the message), respectively.
Previously, this key information was buried in return value
documentation or in "notes", which made it seem secondary to these
functions' semantics.
Austin Clements [Sat, 29 Jan 2011 16:25:56 +0000 (11:25 -0500)]
new: Wrap adding and removing messages in atomic sections.
This addresses atomicity of tag synchronization, the last atomicity
problems in notmuch new. Each message add or remove is wrapped in its
own atomic section, so interrupting notmuch new doesn't lose progress.
Austin Clements [Fri, 28 Jan 2011 01:51:04 +0000 (20:51 -0500)]
new: Synchronize maildir flags eagerly.
Because flag synchronization is stateless, it can be performed at any
time as long as it's guaranteed to be performed after any change to a
message's filename list. Take advantage of this to synchronize tags
immediately after a filename is added or removed.
This does not yet make adding or removing a message atomic, but it is
a big step toward atomicity because it reduces the window where the
database tags are inconsistent from nearly the entire notmuch-new to
just around when the message is added or removed.
Austin Clements [Sat, 11 Jun 2011 16:54:05 +0000 (12:54 -0400)]
new: Cleanup. Put removed/renamed message count in add_files_state_t.
Previously, pointers to these variables were passed around
individually. This was okay when only one function needed them, but
we're about to need them in a few more places.
Austin Clements [Sat, 11 Jun 2011 04:42:58 +0000 (00:42 -0400)]
lib: Wrap notmuch_database_add_message in an atomic section.
Adding a message may involve changes to multiple database documents,
and thus needs to be done in a transaction. This makes add_message
(and, I think, the whole library) atomicity-safe: library callers only
needs to use atomic sections if they needs atomicity across multiple
library calls.
Austin Clements [Sat, 11 Jun 2011 04:19:31 +0000 (00:19 -0400)]
lib: Add an API to find a message by filename.
notmuch_database_find_message_by_filename is mostly stolen from
notmuch_database_remove_message, so this patch also vastly simplfies
the latter using the former.
This API is also useful in its own right and will be used in a later
patch for eager maildir flag synchronization.
Ali Polatel [Sat, 24 Sep 2011 12:25:24 +0000 (15:25 +0300)]
ruby: Rename destroy to destroy!
According to the common Ruby function naming convention, potentially
dangerous functions or functions which operate on the object itself are
suffixed with an exclamation mark. Both of these are true for object
destroying functions.
The following modules are affected:
- Notmuch::Directory
- Notmuch::FileNames
- Notmuch::Query
- Notmuch::Threads
- Notmuch::Thread
- Notmuch::Messages
- Notmuch::Message
- Notmuch::Tags
Austin Clements [Sat, 11 Jun 2011 04:07:54 +0000 (00:07 -0400)]
lib: Remove message document directly after removing the last file name.
Previously, notmuch_database_remove_message would remove the message
file name, sync the change to the message document, re-find the
message document, and then delete it if there were no more file names.
An interruption after sync'ing would result in a file-name-less,
permanently un-removable zombie message that would produce errors and
odd results in searches. We could wrap this in an atomic section, but
it's much simpler to eliminate the round-about approach and just
delete the message document instead of sync'ing it if we removed the
last filename.
Austin Clements [Tue, 8 Feb 2011 23:24:33 +0000 (18:24 -0500)]
new: Defer updating directory mtimes until the end.
Previously, if notmuch new were interrupted between updating the
directory mtime and handling removals from that directory, a
subsequent notmuch new would not handle those removals until something
else changed in that directory. This defers recording the updated
mtime until after removals are handled to eliminate this problem.
Austin Clements [Wed, 9 Feb 2011 01:56:31 +0000 (20:56 -0500)]
new: Don't lose messages on SIGINT.
Previously, message removals were always performed, even after a
SIGINT. As a result, when a message was moved from one folder to
another, a SIGINT between processing the directory the message was
removed from and processing the directory it was added to would result
in notmuch removing that message from the database.
Austin Clements [Fri, 28 Jan 2011 18:03:24 +0000 (13:03 -0500)]
test: Test atomicity of notmuch new.
This tests notmuch new's ability to recover from arbitrary stopping
failures. It interrupts notmuch new after every database commit and,
on every resulting database snapshot, re-runs notmuch new to
completion and checks that the final database state is invariant.
Austin Clements [Fri, 10 Jun 2011 19:58:18 +0000 (15:58 -0400)]
lib: Add missing status check in _notmuch_message_remove_filename.
Previously, this function would synchronize the folder list even if
removing the file name failed. Now it returns immediately if removing
the file name fails.
David Bremner [Tue, 13 Sep 2011 01:40:57 +0000 (22:40 -0300)]
test: reset test_subtest_known_broken_ after each success/failure.
This means that test_subtest_known_broken needs to be called before
every known broken subtest, which is no different than what is
documented for the test_begin_subtest case.
The assumption is that every test ends up calling either skipping,
calling test_ok_ or test_failure_ and and the latter in turn delegate
to the known_broken versions in the case where
test_subtest_known_broken_ is set.
The Glib docs state "Prior to any use of the type system, g_type_init() has to
be called".[1] To not do so can lead to segfaults. The g_type system is
currently used by various "filters" that operate on uuencoded text, message
headers, etc.
test: add emacs test for hiding a message following an HTML part
Human-friendly scenario:
* open a thread where a message which ends with an HTML part is
followed by another message
* make the first message visible
* goto the beginning of the second message (first line, first colon)
* hit "RET"
Result: nothing happens except for "No URL at point" message
Expected result: the second message is shown/hidden
The root cause is that the HTML part has `keymap' text property set.
In particular, "RET" is bound to visit a URL at point. The problem is
that `keymap' property affects the next character following the region
it is set to (see elisp manual [1]). Hence, the first character of
the next message has a keymap inherited from the HTML part.
There is existing support for broken tests. But it is not convenient
to use. The primary issue is that we have to maintain a set of
test_expect_*_failure functions which are equivalent to the normal
test_expect_* counterparts except for what functions are called for
result reporting. The patch adds test_subtest_known_broken function
which marks a subset as broken, making the normal test_expect_*
functions behave as test_expect_*_failure. All test_expect_*_failure
functions are removed. Test_known_broken_failure_ is changed to
format details the same way as test_failure_ does.
Another benefit of this change is that the diff when a broken test is
fixed would be small and nice.
test: update documentation for test_emacs in test/README
Update test_emacs documentation in test/README according to the latest
changes in emacs tests. Move the note regarding setting variables
from test/emacs to test/README.
Do not attempt to output part raw if part is not GMimePart.
This was a minor oversite in checking of part type when outputing
content raw. This was causing gmime was to throw an exception to
stderr.
Unfortunately the gmime exception was not being caught by notmuch, or
the test suite. I'm not sure if notmuch should have done anything in
this case, but certainly the test suite should be capable of detecting
that something unexpected was output to stderr.
The insert-part-message/rfc822 function is overhauled to properly
processes the new formatting of message/rfc822 parts. The json output
for message parts now includes "headers" and "body" fields, which are
now parsed and output appropriately.
Improve handling of message/rfc822 parts by adding a new header_message_part function to the formating structure.
This new function takes a GMimeMessage as input, and outputs the
formatted headers. This allows for message/rfc822 parts to be
formatted on output in a similar way to full messages (see previous
patch that overhauls the multipart test for more info).
test: overhaul multipart test to test for improved message/rfc822 handling
The main goal of this overhaul is to define how message/rfc822 parts
should be handled. message/rfc822 parts should be output in a similar
fashion to the outer message, including some subset of the rfc822
headers. The following decisions about formatting of message/rfc822
parts were made:
The format and content of message/rfc822 parts shall be as similar as
possible to that of full messages. In particular, for formatted
outputs, the "content" of rfc822 part output should include "headers"
and "body" fields).
The "body" field shall include the body of the message.
The "headers" field shall include the following headers, since these
are the ones available from the GMimeMessage:
"From"
"To"
"Cc"
"Subject"
"Date"
However, for the case of --format=raw the raw rfc822 should be output,
including all headers.
A subset of relevant headers shall be output in reply.
The test embedded rfc822 message is also modified to be itself
multipart, so we can more fully test how all sub parts of the message
part are output.
Note added by Committer:
Currently, expect one test (--format=raw --part=3, rfc822 part) to fail.
Decode and Encode from/to unicode objects as required to be able to take
unicode path names. Previously we would error out when an unicode object
were handed it.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
The test message date, "Tue, 05 Jan 2001 15:43:57 -0000", is not
actually a real date. 05 Jan 2001 was in fact a Friday, not a
Tuesday. Date parsers (such as "date" in coreutils) will return "Fri"
as the day for this string, even if "Tue" is specified.
Also, the time zone "-0000" is actually always returned as "+0000", so
we change that here was well.
This will be relevant for later patches when we begin parsing rfc822
part headers, where gmime returns a parsed date string.
If we do want to test date parsing, we should do that in a separate
test.
David Bremner [Mon, 5 Sep 2011 11:45:28 +0000 (08:45 -0300)]
build system: Check that python bindings have consistent version when releasing
Thanks to Sebastian Spaeth breaking out version.py, this can be done
without loading notmuch.py, or using sed. version.py is not (yet)
autogenerated because it seems more important to minimize the
differences between the tagged version and the tarball.
David Bremner [Mon, 5 Sep 2011 03:19:32 +0000 (00:19 -0300)]
lib/gen-version-script.h: add getline and getdelim to notmuch.sym if needed
If the configure script detects missing getline and/or getdelim
symbols, then notmuch will use it's own versions. This patch, based on
id:"87k49v12i5.fsf@pc44es141.cs.uni-magdeburg.de" by Matthias
Guedemann, adds the symbols to notmuch.sym as well so they are
properly exported from the library.
Tomi Ollila [Mon, 22 Aug 2011 11:59:02 +0000 (14:59 +0300)]
fix checking whether header is member of message-hidden-headers
Emacs lisp function 'member' takes element and list as an
argument. I.e. the second argument is list, not symbol
referencing the list.
On emacs 23.x the member call always returned nil (thus buggy),
on emacs 22.x the call failed, making it unusable.
Sebastian Spaeth [Wed, 24 Aug 2011 07:13:34 +0000 (09:13 +0200)]
python: Have setup.py read the version number without importing
Importing the notmuch module in setup.py is a no-no, and we want
to auto-generate the version number in the release process.
Outsource __VERSION__ to the new version.py which contains nothing else
and which can therefor easily be autogenerated. Have setup.py read in
the file via execfile and test if importing the version number actually
worked.
This should make all happy.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>