[PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010, Mike Kelly wrote: > On Wed, 13 Oct 2010 10:24:25 -0400 > Mike Kelly wrote: > > > Looks like this may also require a newer xapian than i have now > > (xapian-core 1.0.18), as notmuch new aborts with: > > > > terminate called after throwing an instance of > > 'Xapian::InvalidArgumentError' > > > > I'll see if I can track down anything more concrete as a cause. > > Well, the full backtrace looks like this: So you were able to compile it? What was the problem? > > #0 __cxa_throw (obj=0x2883d560, tinfo=0x8070278, dest=0x806132e > <~InvalidArgumentError>) > at ../../.././../gcc-4.4-20100309/libstdc++-v3/libsupc++/eh_throw.cc:67 > header = (__cxxabiv1::__cxa_refcounted_exception *) 0x2883d500 > #1 0x28353b72 in Xapian::Document::Internal::remove_term () from > /usr/local/lib/libxapian.so.21 > No symbol table info available. > #2 0x28353c96 in Xapian::Document::remove_term () from > /usr/local/lib/libxapian.so.21 > No symbol table info available. > #3 0x080604bc in _notmuch_message_remove_term (message=0x28a85c10, > prefix_name=0x806c887 "tag", value=0x806c564 "draft") > at lib/message.cc:737 > term = 0x28806ab0 "Kdraft" > #4 0x0806086a in notmuch_message_remove_tag (message=0x28a85c10, > tag=0x806c564 "draft") at lib/message.cc:832 > private_status = 134662454 > status = NOTMUCH_STATUS_SUCCESS I guess the problem would be that it removes nonexistent tag. I do not experience such a problem on Linux with Xapian 1.2.3. -Michal
[PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010, Servilio Afre Puentes wrote: > On 13 October 2010 08:13, Michal Sojka wrote: > [...] > > THERE IS CURRENTLY ONE KNOWN ISSUE: Viewing/storing of attachments of > > unread messages doesn't work. The reason is that when you view the > > message its unread tag is removed which causes the file to be renamed, > > but Emacs still uses the original name to access the attachment. You can > > workaround this by closing the message and opening it again. This issue > > will be fixed after we (I) implement "notmuch cat" command. With this > > command, emacs would not access the messages by the file name, but by > > running notmuch cat id: which will always give the correct > > content. > > Wouldn't it be more efficient to query notmuch for the filename using > the message ID we store in the DB? When network usage is implemented, > tramp can give us transparent remote file access in emacs. Tramp would not be available in non-emacs GUIs. Also, when notmuch cat is implemented, emacs gui will be usable remotely by simply defining notmuch-command variable to contain the name of the script containing: ssh user at host notmuch "$@" -Michal
[PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010 22:34:34 +0200, Michal Sojka wrote: > On Wed, 13 Oct 2010, Servilio Afre Puentes wrote: > > On 13 October 2010 08:13, Michal Sojka wrote: > > [...] > > > THERE IS CURRENTLY ONE KNOWN ISSUE: Viewing/storing of attachments of > > > unread messages doesn't work. The reason is that when you view the > > > message its unread tag is removed which causes the file to be renamed, > > > but Emacs still uses the original name to access the attachment. You can > > > workaround this by closing the message and opening it again. This issue > > > will be fixed after we (I) implement "notmuch cat" command. With this > > > command, emacs would not access the messages by the file name, but by > > > running notmuch cat id: which will always give the correct > > > content. > > > > Wouldn't it be more efficient to query notmuch for the filename using > > the message ID we store in the DB? When network usage is implemented, > > tramp can give us transparent remote file access in emacs. > > Tramp would not be available in non-emacs GUIs. Also, when notmuch cat > is implemented, emacs gui will be usable remotely by simply defining > notmuch-command variable to contain the name of the script containing: > > ssh user at host notmuch "$@" That to me is certainly a very elegant solution... so what's stopping us from implementing notmuch cat? No one taken the time to do it? Or is there a design issue left to be resolved? /D
[PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010 22:59:49 +0200 Michal Sojka wrote: > So you were able to compile it? What was the problem? I mentioned at the bottom of a previous message: > This is with "gcc (GCC) 4.2.1 20070719 [FreeBSD]" > > Switching to gcc44 seems to allow it to compile correctly, however > notmuch didn't used to have that dependency. -- Mike Kelly -- next part -- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20101013/f454a0f3/attachment.pgp>
[PATCH 2/4] Maildir synchronization
> +/* ASCII ordered table of Maildir flags and associated tags */ > +struct maildir_flag_tag flag2tag[] = { > +{ 'D', "draft", false}, > +{ 'F', "flagged", false}, > +{ 'P', "passed", false}, > +{ 'R', "replied", false}, > +{ 'S', "unread", true }, > +{ 'T', "delete", false}, > +}; for all of the 4 patches a: Signed-off-by: Sebastian Spaeth with one caveat: you use the tag "delete" to mark the state "trashed". I think people have slowly settled on the convention "deleted" which is also more consistent with a state, such as unread, replied, etc... They work fine and obsolete my notmuchsync (except for the pruning of deleted mails and the tagging based on folder names). +1 for merging in notmuch-next or wherever we collect that stuff. Sebastian -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20101013/4bc1b7d0/attachment-0001.pgp>
[PATCH v3 0/5] Git-based modularization of test suite
On Wed, 22 Sep 2010, Michal Sojka wrote: > On Mon, 20 Sep 2010, Carl Worth wrote: > > I've now pushed this out, along with some changes of my own on top of > > it. My changes make things in the test suite look more like they did > > before the git-based modularization, (both output from the test suite > > and how the tests themselves are written). I couldn't stand the approach > > of doing long chains of shell commands within strings for the tests, and > > I also didn't like the numeric filenames. > > > > Take a look at what I've done, and let me know if I defeated any > > intended benefits of the git-based modularization of the test suite. > > I went through your changes and they seems reasonable to me. I'll try to > update my tests for maildir synchronization and let you know (or send a > patch) if I find some problems. Hi Carl, here is my experience with test_begin_subtest and test_expect_equal functions in test-lib.sh. I see there two significant differences from the git's test_expect_success and similar functions. First, when the test fails, you only see the differences in the real output and the expected output. If you use test_expect_success you also see the actual commands that were executed. Second, when some command between test_begin_subtest and test_expect_success fails (e.g. because of segfault) you may not detect it. You can add "set -e" the test-lib.sh (see the patch bellow), but in this case when a test fails you would see FATAL: Unexpected exit with code 1 without any additional information. -Michal diff --git a/test/test-lib.sh b/test/test-lib.sh index 2036669..c98ea2f 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -395,6 +395,7 @@ add_email_corpus () test_begin_subtest () { test_subtest_name="$1" +set -e } # Pass test if two arguments match
notmuch setup: segfault in prompt macro
On Wed, 13 Oct 2010 09:43:40 -0400, Mike Kelly wrote: > Hi, > > While testing Michal Sojka's latest patches, I tried running notmuch > setup, only to find that it segfaults. It does this on a vanilla > branch, too, though: > > #0 0x286e3ba5 in memcpy () from /lib/libc.so.7 > No symbol table info available. What environment is this where you have libc7 ? d
[PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010 10:50:36 -0400, Servilio Afre Puentes wrote: > > Wouldn't it be more efficient to query notmuch for the filename using > the message ID we store in the DB? When network usage is implemented, > tramp can give us transparent remote file access in emacs. > We can of course do both. From an implementation point of view, they would both fall under "selective output in plain text" which various people have been meaning to do, and I think one is no harder than the other. On the other hand I doubt that there is an efficiency advantage to using tramp, it is is more fragile (for example it depends on the remote shell prompt). d
[PATCH 4/4] Tests for maildir synchronization
Signed-off-by: Michal Sojka --- test/maildir-sync | 216 + test/notmuch-test |2 +- test/test-lib.sh | 14 +++- 3 files changed, 229 insertions(+), 3 deletions(-) create mode 100755 test/maildir-sync diff --git a/test/maildir-sync b/test/maildir-sync new file mode 100755 index 000..a5f8c36 --- /dev/null +++ b/test/maildir-sync @@ -0,0 +1,216 @@ +#!/bin/bash + +test_description="Test maildir synchronization" + +. ./test-lib.sh + +filter_show() { +sed -e 's/, /,\n/g'|sed -e "s|${MAIL_DIR}/||" -e '/^"tags"/d' +echo +} + +cat >> "$NOTMUCH_CONFIG" < expected < actual && +test_cmp expected actual +#emacs --eval "(gdb \"gdb --annotate=3 --args $(which notmuch) new\")" +' +cat > expected < actual && +test_cmp expected actual +' +cat > expected < actual && +test_cmp expected actual +' +cat > expected < actual && +test_cmp expected actual +' +cat > expected < actual && +test_cmp expected actual +' +cat > expected < actual && +test_cmp expected actual +' +test_expect_success 'Tag the seen messages as replied' ' +notmuch tag +replied -inbox tag:inbox and not tag:unread +' + +cat > expected < actual && +test_cmp expected actual +' +cat < show-expected +[[[{"id": "msg-001 at notmuch-test-suite", +"match": true, +"filename": "msg-001:2,RS", +"timestamp": 946728000, +"date_relative": "2000-01-01", +"headers": {"Subject": "test message", +"From": "Notmuch Test Suite ", +"To": "Notmuch Test Suite ", +"Cc": "", +"Bcc": "", +"Date": "Sat, +01 Jan 2000 12:00:00 -"}, +"body": [{"id": 1, +"content-type": "text/plain", +"content": "This is just a test message (#1)\n"}]}, +[ +EOF + +test_expect_success 'Renamed message can be shown without running notmuch new' ' +notmuch show --format=json id:msg-001 at notmuch-test-suite | filter_show > show-actual && +test_cmp show-expected show-actual +' + +test_expect_success 'Test that we can reply to the renamed message' ' +notmuch reply id:msg-001 at notmuch-test-suite +' + +echo "No new mail." > expected +test_expect_success 'No rename should be detected by notmuch new' ' +increment_mtime "$(dirname "${gen_msg_filename}")" && +notmuch new > actual && +test_cmp expected actual +' +test_expect_success "Add a message to new/ without info" ' +generate_message [subject]="\"test message 3\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -\"" [dir]=new && +NOTMUCH_NEW > actual && +test_cmp - actual < actual && +test_cmp - actual < expected && +notmuch show id:$gen_msg_id|grep -o "filename:.*$" > actual && +test_cmp expected actual && +test -f "$gen_msg_filename" +' +test_expect_success "Check that the message was not renamed" ' +ls "${MAIL_DIR}/new" > actual && +test_cmp - actual < actual && +test_cmp - actual < actual && +test_cmp - actual < actual && +test_cmp - actual < actual +test_cmp - actual < actual && +test_cmp - actual < actual && +test_cmp - actual < actual && +test_cmp - actual < actual && +test_cmp - actual /dev/null diff --git a/test/test-lib.sh b/test/test-lib.sh index 5f7fa14..2036669 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -237,6 +237,12 @@ increment_mtime () # Generate the message in directory 'directory/of/choice' within # the mail store. The directory will be created if necessary. # +# [filename]=name +# +# Store the message in file 'name'. The default is to store it +# in 'msg-', where is three-digit number of the +# message. +# # [body]=text # # Text to use as the body of the email message @@ -273,10 +279,14 @@ generate_message () local additional_headers gen_msg_cnt=$((gen_msg_cnt + 1)) -gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt) +if [ -z "${template[filename]}" ]; then + gen_msg_name="msg-$(printf "%03d" $gen_msg_cnt)" +else + gen_msg_name=${template[filename]} +fi if [ -z "${template[id]}" ]; then - gen_msg_id="${gen_msg_name}@notmuch-test-suite" + gen_msg_id="${gen_msg_name%:2,*}@notmuch-test-suite" else gen_msg_id="${template[id]}" fi -- 1.7.1.3.g75e44
[PATCH 3/4] Make maildir synchronization configurable
This adds group [maildir] and key 'sync_level' to the configuration file. The value of sync_level is used to control how the synchronization happens. The default value is no synchronization. --- lib/database-private.h |2 +- lib/database.cc|9 + lib/message.cc |2 +- lib/notmuch.h | 19 +++ notmuch-client.h |7 +++ notmuch-config.c | 48 notmuch-new.c |8 ++-- notmuch-restore.c |2 ++ notmuch-setup.c| 17 + notmuch-tag.c |2 ++ 10 files changed, 112 insertions(+), 4 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index bd72f67..3c80f99 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -49,7 +49,7 @@ struct _notmuch_database { Xapian::QueryParser *query_parser; Xapian::TermGenerator *term_gen; Xapian::ValueRangeProcessor *value_range_processor; - +enum notmuch_maildir_sync maildir_sync; }; /* Convert tags from Xapian internal format to notmuch format. diff --git a/lib/database.cc b/lib/database.cc index 9652013..d6b6f47 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -689,6 +689,8 @@ notmuch_database_open (const char *path, notmuch = NULL; } +notmuch_database_set_maildir_sync (notmuch, NOTMUCH_MAILDIR_SYNC_NONE); + DONE: if (notmuch_path) free (notmuch_path); @@ -718,6 +720,13 @@ notmuch_database_close (notmuch_database_t *notmuch) talloc_free (notmuch); } +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync) +{ +database->maildir_sync = maildir_sync; +} + const char * notmuch_database_get_path (notmuch_database_t *notmuch) { diff --git a/lib/message.cc b/lib/message.cc index 96c402c..1b945c6 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -626,7 +626,7 @@ _notmuch_message_sync (notmuch_message_t *message) if (message->notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY) return; -if (// todo_sync_enabled && +if (message->notmuch->maildir_sync == NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED && !notmuch_message_get_flag(message, NOTMUCH_MESSAGE_FLAG_TAGS_INVALID)) { status = _notmuch_message_tags_to_maildir (message); if (status != NOTMUCH_PRIVATE_STATUS_SUCCESS) { diff --git a/lib/notmuch.h b/lib/notmuch.h index 408d633..34b3bcf 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -108,6 +108,19 @@ typedef enum _notmuch_status { const char * notmuch_status_to_string (notmuch_status_t status); +/* Level of synchronization between notmuch tags and maildir flags. */ +enum notmuch_maildir_sync { +NOTMUCH_MAILDIR_SYNC_INVALID = 0, +/* No synchronization */ +NOTMUCH_MAILDIR_SYNC_NONE, +/* Tag new messages accoring to maildir flags */ +NOTMUCH_MAILDIR_SYNC_NEW, +/* The above + update tags for renamed messages */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED, +/* The above + update flags when tags are added/removed. */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED, +}; + /* Various opaque data types. For each notmuch__t see the various * notmuch_ functions below. */ typedef struct _notmuch_database notmuch_database_t; @@ -176,6 +189,12 @@ notmuch_database_open (const char *path, void notmuch_database_close (notmuch_database_t *database); +/* Sets the level of synchronization between maildir flags and notmuch + * tags. */ +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync); + /* Return the database path of the given database. * * The return value is a string owned by notmuch so should not be diff --git a/notmuch-client.h b/notmuch-client.h index 20be43b..50be95c 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -191,6 +191,13 @@ notmuch_config_set_new_tags (notmuch_config_t *config, const char *new_tags[], size_t length); +enum notmuch_maildir_sync +notmuch_config_get_maildir_sync (notmuch_config_t *config); + +void +notmuch_config_set_maildir_sync (notmuch_config_t *config, +enum notmuch_maildir_sync maildir_sync); + notmuch_bool_t debugger_is_active (void); diff --git a/notmuch-config.c b/notmuch-config.c index cf30603..60d5730 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -61,6 +61,21 @@ static const char user_config_comment[] = " recipient list of replies, and will set the From address based on the\n" " address to which the original email was addressed.\n"; +static const char maildir_config_comment[] = +" Maildir compatibility configuration\n" +"\n" +" Here you can configure whether and how will notmuch synchronize its\n" +" tags with maildir flags." +"\n" +"\tsync_level Integer in the
[PATCH 2/4] Maildir synchronization
This patch allows bi-directional synchronization between maildir flags and certain tags. The flag-to-tag mapping is defined by flag2tag array. The synchronization works this way: 1) Whenever notmuch new is executed, the following happens: o New messages are tagged with configured new_tags. o For new or renamed messages with maildir info present in the file name, the tags defined in flag2tag are either added or removed depending on the flags from the file name. 2) Whenever notmuch tag (or notmuch restore) is executed, a new set of flags based on the tags is constructed for every message and a new file name is prepared based on the old file name but with the new flags. If the flags differs and the old message was in 'new' directory then this is replaced with 'cur' in the new file name. If the new and old file names differ, the file is renamed and notmuch database is updated accordingly. The rename happens before the database is updated. In case of crash between rename and database update, the next run of notmuch new brings the database in sync with the mail store again. There is currenlty one known issue: Viewing/storing of attachments of unread messages doesn't work. The reason is that when you view the message its unread tag is removed which leads to rename of the file, but Emacs still uses the original name to access the attachment. Workaround: close the message and open it again. --- lib/database.cc |7 ++ lib/message.cc| 226 + lib/notmuch-private.h |4 + lib/notmuch.h |7 ++ notmuch-new.c |3 +- 5 files changed, 246 insertions(+), 1 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 9a4f715..9652013 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -1643,6 +1643,13 @@ notmuch_database_add_message (notmuch_database_t *notmuch, _notmuch_message_add_filename (message, filename); + /* This is a new message or it has a new filename and as such, +* its tags in database either do not exists or might be out +* of date. We assign the tags later in notmuch new, but until +* then we should not synchronize the tags back to the maildir +* flags (if notmuch is configured to do so). */ + notmuch_message_set_flag(message, NOTMUCH_MESSAGE_FLAG_TAGS_INVALID, TRUE); + /* Is this a newly created message object? */ if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) { _notmuch_message_add_term (message, "type", "mail"); diff --git a/lib/message.cc b/lib/message.cc index 71f5619..96c402c 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -43,6 +43,24 @@ struct _notmuch_message { Xapian::Document doc; }; +#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0])) + +struct maildir_flag_tag { +char flag; +const char *tag; +bool inverse; +}; + +/* ASCII ordered table of Maildir flags and associated tags */ +struct maildir_flag_tag flag2tag[] = { +{ 'D', "draft", false}, +{ 'F', "flagged", false}, +{ 'P', "passed", false}, +{ 'R', "replied", false}, +{ 'S', "unread", true }, +{ 'T', "delete", false}, +}; + /* We end up having to call the destructor explicitly because we had * to use "placement new" in order to initialize C++ objects within a * block that we allocated with talloc. So C++ is making talloc @@ -595,15 +613,29 @@ _notmuch_message_set_date (notmuch_message_t *message, Xapian::sortable_serialise (time_value)); } +static notmuch_private_status_t +_notmuch_message_tags_to_maildir (notmuch_message_t *message); + /* Synchronize changes made to message->doc out into the database. */ void _notmuch_message_sync (notmuch_message_t *message) { Xapian::WritableDatabase *db; +notmuch_private_status_t status; if (message->notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY) return; +if (// todo_sync_enabled && + !notmuch_message_get_flag(message, NOTMUCH_MESSAGE_FLAG_TAGS_INVALID)) { + status = _notmuch_message_tags_to_maildir (message); + if (status != NOTMUCH_PRIVATE_STATUS_SUCCESS) { + fprintf (stderr, "Error: Cannot sync tags to maildir (%s)\n", +notmuch_status_to_string ((notmuch_status_t)status)); + /* Exit to avoid unsynchronized mailstore. */ + exit(1); + } +} db = static_cast (message->notmuch->xapian_db); db->replace_document (message->doc_id, message->doc); } @@ -715,6 +747,44 @@ _notmuch_message_remove_term (notmuch_message_t *message, return NOTMUCH_PRIVATE_STATUS_SUCCESS; } +/* Change the message filename stored in the database. + * + * This change will not be reflected in the database until the next + * call to _notmuch_message_sync. + */ +notmuch_private_status_t +_notmuch_message_rename (notmuch_message_t *message, +const char
[PATCH 1/4] lib: Return added message even if it already was in the database
--- lib/database.cc |3 ++- lib/notmuch.h |3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index e4ac970..9a4f715 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -1671,7 +1671,8 @@ notmuch_database_add_message (notmuch_database_t *notmuch, DONE: if (message) { - if (ret == NOTMUCH_STATUS_SUCCESS && message_ret) + if ((ret == NOTMUCH_STATUS_SUCCESS || +ret == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) && message_ret) *message_ret = message; else notmuch_message_destroy (message); diff --git a/lib/notmuch.h b/lib/notmuch.h index 505ad19..0ba1416 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -238,7 +238,8 @@ notmuch_database_get_directory (notmuch_database_t *database, * notmuch database will reference the filename, and will not copy the * entire contents of the file. * - * If 'message' is not NULL, then, on successful return '*message' + * If 'message' is not NULL, then, on successful return + * (NOTMUCH_STATUS_SUCCESS or NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) '*message' * will be initialized to a message object that can be used for things * such as adding tags to the just-added message. The user should call * notmuch_message_destroy when done with the message. On any failure -- 1.7.1.3.g75e44
[PATCH 0/4] Maildir synchronization v2
Hi, this is an updated version of patches sent in id:1273580061-22580-1-git-send-email-sojkam1 at fel.cvut.cz. Only the last patch (tests) was actually updated to work with new test suite. These patches has already been tested by several people and I think they are ready to be merged. They can be pulled by: git pull git://rtime.felk.cvut.cz/notmuch maildir-sync-v2 These patches implement synchronization between maildir flags and notmuch tags. The synchronization can be configured to not happen at all (default), to set/unset tags when importing new (or new and renamed) messages and to happen in both directions - set/unset tags during importing and change maildir flags during tagging. THERE IS CURRENTLY ONE KNOWN ISSUE: Viewing/storing of attachments of unread messages doesn't work. The reason is that when you view the message its unread tag is removed which causes the file to be renamed, but Emacs still uses the original name to access the attachment. You can workaround this by closing the message and opening it again. This issue will be fixed after we (I) implement "notmuch cat" command. With this command, emacs would not access the messages by the file name, but by running notmuch cat id: which will always give the correct content. Michal Sojka (4): lib: Return added message even if it already was in the database Maildir synchronization Make maildir synchronization configurable Tests for maildir synchronization lib/database-private.h |2 +- lib/database.cc| 19 - lib/message.cc | 226 lib/notmuch-private.h |4 + lib/notmuch.h | 29 ++- notmuch-client.h |7 ++ notmuch-config.c | 48 ++ notmuch-new.c |7 ++- notmuch-restore.c |2 + notmuch-setup.c| 17 notmuch-tag.c |2 + test/maildir-sync | 216 + test/notmuch-test |2 +- test/test-lib.sh | 14 +++- 14 files changed, 588 insertions(+), 7 deletions(-) create mode 100755 test/maildir-sync
notmuch setup: segfault in prompt macro
(sorry, forgot to reply to list) On Wed, 13 Oct 2010 14:26:56 -0300 David Bremner wrote: > On Wed, 13 Oct 2010 09:43:40 -0400, Mike Kelly > wrote: > > Hi, > > > > While testing Michal Sojka's latest patches, I tried running notmuch > > setup, only to find that it segfaults. It does this on a vanilla > > branch, too, though: > > > > #0 0x286e3ba5 in memcpy () from /lib/libc.so.7 > > No symbol table info available. > > What environment is this where you have libc7 ? FreeBSD 8.0 -- Mike Kelly
[PATCH] Allow user to specify ignored directories
On Thu, 30 Sep 2010, Andreas Amann wrote: > Hi list, > > this is my first post. I found notmuch a couple of days ago and it works > great. However I wanted to be able to ignore certain directories (mostly > .git in my case) when "notmuch new" is running. > > With this patch the user can provide a list of directories which are > ignored during the recursive search for new messages. An "ignore" > label in the "new" section of the configuration file is added for this > purpose to enable for example something like Hi, thanks, the patch seems good to me. See the comment bellow. > @@ -202,7 +219,8 @@ _entries_resemble_maildir (struct dirent **entries, int > count) > static notmuch_status_t > add_files_recursive (notmuch_database_t *notmuch, > const char *path, > -add_files_state_t *state) > +add_files_state_t *state, > + notmuch_config_t *config) I would not add additional parameter here. It's IMHO better to add field "ignored_files" to add_files_state_t similarly as it is done for new_tags. -Michal
[PATCH 0/4] Maildir synchronization v2
On 13 October 2010 08:13, Michal Sojka wrote: [...] > THERE IS CURRENTLY ONE KNOWN ISSUE: Viewing/storing of attachments of > unread messages doesn't work. The reason is that when you view the > message its unread tag is removed which causes the file to be renamed, > but Emacs still uses the original name to access the attachment. You can > workaround this by closing the message and opening it again. This issue > will be fixed after we (I) implement "notmuch cat" command. With this > command, emacs would not access the messages by the file name, but by > running notmuch cat id: which will always give the correct > content. Wouldn't it be more efficient to query notmuch for the filename using the message ID we store in the DB? When network usage is implemented, tramp can give us transparent remote file access in emacs. Regards, Servilio
opening attachment
Ah, thank you. Works like a charm. d. On Tue, 12 Oct 2010 10:53:09 +0200, Michal Sojka wrote: > On Sun, 10 Oct 2010, Daniel Goldin wrote: > > > > Setting my .mailcap doesn't seem to have any effect on how notmuch/emacs > > handles attachments. Hitting return saves no matter what. > > I use 'v' key to display attachments. This shows all attachments at > once with the programs configured in .mailcap. > > -Michal -- Daniel Goldin, LMFT 626.817.2462 www.danielgoldinpractice.com
[PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010 10:24:25 -0400 Mike Kelly wrote: > Looks like this may also require a newer xapian than i have now > (xapian-core 1.0.18), as notmuch new aborts with: > > terminate called after throwing an instance of > 'Xapian::InvalidArgumentError' > > I'll see if I can track down anything more concrete as a cause. Well, the full backtrace looks like this: #0 __cxa_throw (obj=0x2883d560, tinfo=0x8070278, dest=0x806132e <~InvalidArgumentError>) at ../../.././../gcc-4.4-20100309/libstdc++-v3/libsupc++/eh_throw.cc:67 header = (__cxxabiv1::__cxa_refcounted_exception *) 0x2883d500 #1 0x28353b72 in Xapian::Document::Internal::remove_term () from /usr/local/lib/libxapian.so.21 No symbol table info available. #2 0x28353c96 in Xapian::Document::remove_term () from /usr/local/lib/libxapian.so.21 No symbol table info available. #3 0x080604bc in _notmuch_message_remove_term (message=0x28a85c10, prefix_name=0x806c887 "tag", value=0x806c564 "draft") at lib/message.cc:737 term = 0x28806ab0 "Kdraft" #4 0x0806086a in notmuch_message_remove_tag (message=0x28a85c10, tag=0x806c564 "draft") at lib/message.cc:832 private_status = 134662454 status = NOTMUCH_STATUS_SUCCESS #5 0x08060a56 in notmuch_message_maildir_to_tags (message=0x28a85c10, filename=0x28a860f0 "/usr/home/staff/mike/mail/staff-support/cur/1286944232_2.71920.pit84.pair.com,U=26762,FMD5=74eb4e66bae4700f6b79b81477ef9cfa:2,S") at lib/message.cc:889 flags = 0x28a8616e "S" i = 0 status = NOTMUCH_STATUS_SUCCESS p = 0x28a8616f "" f = 83 'S' valid = true unread = true #6 0x08050bbe in add_files_recursive (notmuch=0x2881e7f0, path=0x2881ec70 "/usr/home/staff/mike/mail/staff-support/cur", state=0xbfbfe238) at notmuch-new.c:420 err = 32 dir = (DIR *) 0x0 entry = (struct dirent *) 0x28a68640 next = 0x28a860f0 "/usr/home/staff/mike/mail/staff-support/cur/1286944232_2.71920.pit84.pair.com,U=26762,FMD5=74eb4e66bae4700f6b79b81477ef9cfa:2,S" fs_mtime = 1286978382 db_mtime = 1286944232 status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID ret = NOTMUCH_STATUS_SUCCESS message = (notmuch_message_t *) 0x28a85c10 fs_entries = (struct dirent **) 0x28a6f000 i = 4915 num_fs_entries = 4922 directory = (notmuch_directory_t *) 0x288069f0 db_files = (notmuch_filenames_t *) 0x28806af0 db_subdirs = (notmuch_filenames_t *) 0x28806b30 st = {st_dev = 89, st_ino = 4172664, st_mode = 16832, st_nlink = 2, st_uid = 1118, st_gid = 0, st_rdev = 16689352, st_atimespec = {tv_sec = 1286979943, tv_nsec = 0}, st_mtimespec = {tv_sec = 1286978382, tv_nsec = 0}, st_ctimespec = { tv_sec = 1286978382, tv_nsec = 0}, st_size = 1205760, st_blocks = 2400, st_blksize = 4096, st_flags = 0, st_gen = 0, st_lspare = 0, st_birthtimespec = {tv_sec = 1264441077, tv_nsec = 0}} is_maildir = 0 new_directory = 0 tag = (const char **) 0x8069d62 #7 0x08050780 in add_files_recursive (notmuch=0x2881e7f0, path=0x2881e790 "/usr/home/staff/mike/mail/staff-support", state=0xbfbfe238) at notmuch-new.c:302 dir = (DIR *) 0x0 entry = (struct dirent *) 0x288cc5b0 next = 0x2881ec70 "/usr/home/staff/mike/mail/staff-support/cur" fs_mtime = 1264003223 db_mtime = 1264003223 status = NOTMUCH_STATUS_SUCCESS ret = NOTMUCH_STATUS_SUCCESS message = (notmuch_message_t *) 0x0 fs_entries = (struct dirent **) 0x2883d480 i = 2 num_fs_entries = 5 directory = (notmuch_directory_t *) 0x28806870 db_files = (notmuch_filenames_t *) 0x28806a30 db_subdirs = (notmuch_filenames_t *) 0x28806a70 st = {st_dev = 89, st_ino = 3889110, st_mode = 16832, st_nlink = 5, st_uid = 1118, st_gid = 0, st_rdev = 15524535, st_atimespec = {tv_sec = 1286979943, tv_nsec = 0}, st_mtimespec = {tv_sec = 1264003223, tv_nsec = 0}, st_ctimespec = { tv_sec = 1264473647, tv_nsec = 0}, st_size = 512, st_blocks = 4, st_blksize = 4096, st_flags = 0, st_gen = 0, st_lspare = 0, st_birthtimespec = {tv_sec = 1264003223, tv_nsec = 0}} is_maildir = 1 new_directory = 0 tag = (const char **) 0x8069d62 #8 0x08050780 in add_files_recursive (notmuch=0x2881e7f0, path=0x2881f680 "/usr/home/staff/mike/mail", state=0xbfbfe238) at notmuch-new.c:302 dir = (DIR *) 0x0 entry = (struct dirent *) 0x28808900 next = 0x2881e790 "/usr/home/staff/mike/mail/staff-support" fs_mtime = 1284781182 db_mtime = 1284781182 status = NOTMUCH_STATUS_SUCCESS ret = NOTMUCH_STATUS_SUCCESS message = (notmuch_message_t *) 0x0 fs_entries = (struct dirent **)
[PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010 09:31:58 -0400 Mike Kelly wrote: > On Wed, 13 Oct 2010 14:13:54 +0200 > Michal Sojka wrote: > > > Hi, > > > > this is an updated version of patches sent in > > id:1273580061-22580-1-git-send-email-sojkam1 at fel.cvut.cz. Only the > > last patch (tests) was actually updated to work with new test suite. > > These patches has already been tested by several people and I think > > they are ready to be merged. They can be pulled by: > > > > git pull git://rtime.felk.cvut.cz/notmuch maildir-sync-v2 > > This sounds like just the sort of feature set I'd want from this sort > of patch, except unfortunately it won't compile for me on FreeBSD: Looks like this may also require a newer xapian than i have now (xapian-core 1.0.18), as notmuch new aborts with: terminate called after throwing an instance of 'Xapian::InvalidArgumentError' I'll see if I can track down anything more concrete as a cause. -- Mike Kelly
notmuch setup: segfault in prompt macro
Hi, While testing Michal Sojka's latest patches, I tried running notmuch setup, only to find that it segfaults. It does this on a vanilla branch, too, though: #0 0x286e3ba5 in memcpy () from /lib/libc.so.7 No symbol table info available. #1 0x28620f6b in getline () from /lib/libc.so.7 No symbol table info available. #2 0x2862113b in getdelim () from /lib/libc.so.7 No symbol table info available. #3 0x28620f03 in getline () from /lib/libc.so.7 No symbol table info available. #4 0x08053c1c in notmuch_setup_command (ctx=0x288090a0, argc=0, argv=0xbfbfe320) at notmuch-setup.c:121 response = 0x0 response_size = 671820800 config = (notmuch_config_t *) 0x2881e490 old_other_emails = (char **) 0xbfbfe324 old_other_emails_len = 0 other_emails = (GPtrArray *) 0xbfbfe2d8 i = 671549033 is_new = 0 new_tags = (const char **) 0x280ae000 new_tags_len = 3217023608 #5 0x0804ec46 in main (argc=2, argv=0xbfbfe318) at notmuch.c:499 local = (void *) 0x288090a0 command = (command_t *) 0x806fd00 i = 0 -- Mike Kelly
notmuch-next branch
> I'd be glad to host something on notmuchmail.org too. > > I suppose I should just set that up... +1 which would make it easier to find for new users. Who would have push rights? (not me). Sebastian
[PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010 14:13:54 +0200 Michal Sojka wrote: > Hi, > > this is an updated version of patches sent in > id:1273580061-22580-1-git-send-email-sojkam1 at fel.cvut.cz. Only the > last patch (tests) was actually updated to work with new test suite. > These patches has already been tested by several people and I think > they are ready to be merged. They can be pulled by: > > git pull git://rtime.felk.cvut.cz/notmuch maildir-sync-v2 This sounds like just the sort of feature set I'd want from this sort of patch, except unfortunately it won't compile for me on FreeBSD: gcc -c -DNOTMUCH_VERSION=0.3.1-96-g6e0dca9 -O2 -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wmissing-declarations -DHAVE_GETLINE=1 -D_REENTRANT -I/usr/local/include/gmime-2.4 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include -DHAVE_VALGRIND=0 -DHAVE_STRCASESTR=1 -Icompat -Ilib -fPIC notmuch-config.c -o notmuch-config.o notmuch-config.c:90: error: field 'maildir_sync' has incomplete type notmuch-config.c: In function 'notmuch_config_open': notmuch-config.c:241: error: 'NOTMUCH_MAILDIR_SYNC_INVALID' undeclared (first use in this function) notmuch-config.c:241: error: (Each undeclared identifier is reported only once notmuch-config.c:241: error: for each function it appears in.) notmuch-config.c:335: error: invalid use of undefined type 'enum notmuch_maildir_sync' notmuch-config.c:336: error: 'NOTMUCH_MAILDIR_SYNC_NONE' undeclared (first use in this function) notmuch-config.c:336: error: type of formal parameter 2 is incomplete notmuch-config.c: At top level: notmuch-config.c:596: error: return type is an incomplete type notmuch-config.c:596: error: conflicting types for 'notmuch_config_get_maildir_sync' notmuch-client.h:195: error: previous declaration of 'notmuch_config_get_maildir_sync' was here notmuch-config.c: In function 'notmuch_config_get_maildir_sync': notmuch-config.c:597: error: 'NOTMUCH_MAILDIR_SYNC_INVALID' undeclared (first use in this function) notmuch-config.c:602: warning: 'return' with a value, in function returning void notmuch-config.c: At top level: notmuch-config.c:607: error: parameter 2 ('maildir_sync') has incomplete type notmuch-config.c: In function 'notmuch_config_set_maildir_sync': notmuch-config.c:607: warning: unused parameter 'maildir_sync' gmake: *** [notmuch-config.o] Error 1 This is with "gcc (GCC) 4.2.1 20070719 [FreeBSD]" Switching to gcc44 seems to allow it to compile correctly, however notmuch didn't used to have that dependency. -- Mike Kelly
[PATCH v3 0/5] Git-based modularization of test suite
On Wed, 13 Oct 2010 14:44:23 +0200, Michal Sojka wrote: > here is my experience with test_begin_subtest and test_expect_equal > functions in test-lib.sh. I see there two significant differences from > the git's test_expect_success and similar functions. > > First, when the test fails, you only see the differences in the real > output and the expected output. If you use test_expect_success you also > see the actual commands that were executed. Yes. For me, I never found the printing of the exact commands as something useful. We probably should fix our test suite to behave consistently regardless of which interface is used. > Second, when some command between test_begin_subtest and > test_expect_success fails (e.g. because of segfault) you may not detect > it. You can add "set -e" the test-lib.sh (see the patch bellow), but in > this case when a test fails you would see > > FATAL: Unexpected exit with code 1 > > without any additional information. What do you recommend here? Frankly, I'm fine if the test cases are easy to read, (and I think they are easier without having many commands chained by "&&" and concatenated into a single string). Then if any test fails, (whether a segfault or simply incorrect output), it shouldn't be hard to just open the test case and manually inspect the commands. But if you've got some idea for anything more useful, (some magic action with trap for example?), I'd be glad to hear it. -Carl -- carl.d.worth at intel.com -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20101013/4aca2474/attachment.pgp>
Re: notmuch-next branch
I'd be glad to host something on notmuchmail.org too. I suppose I should just set that up... +1 which would make it easier to find for new users. Who would have push rights? (not me). Sebastian ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/4] Make maildir synchronization configurable
This adds group [maildir] and key 'sync_level' to the configuration file. The value of sync_level is used to control how the synchronization happens. The default value is no synchronization. --- lib/database-private.h |2 +- lib/database.cc|9 + lib/message.cc |2 +- lib/notmuch.h | 19 +++ notmuch-client.h |7 +++ notmuch-config.c | 48 notmuch-new.c |8 ++-- notmuch-restore.c |2 ++ notmuch-setup.c| 17 + notmuch-tag.c |2 ++ 10 files changed, 112 insertions(+), 4 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index bd72f67..3c80f99 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -49,7 +49,7 @@ struct _notmuch_database { Xapian::QueryParser *query_parser; Xapian::TermGenerator *term_gen; Xapian::ValueRangeProcessor *value_range_processor; - +enum notmuch_maildir_sync maildir_sync; }; /* Convert tags from Xapian internal format to notmuch format. diff --git a/lib/database.cc b/lib/database.cc index 9652013..d6b6f47 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -689,6 +689,8 @@ notmuch_database_open (const char *path, notmuch = NULL; } +notmuch_database_set_maildir_sync (notmuch, NOTMUCH_MAILDIR_SYNC_NONE); + DONE: if (notmuch_path) free (notmuch_path); @@ -718,6 +720,13 @@ notmuch_database_close (notmuch_database_t *notmuch) talloc_free (notmuch); } +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync) +{ +database-maildir_sync = maildir_sync; +} + const char * notmuch_database_get_path (notmuch_database_t *notmuch) { diff --git a/lib/message.cc b/lib/message.cc index 96c402c..1b945c6 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -626,7 +626,7 @@ _notmuch_message_sync (notmuch_message_t *message) if (message-notmuch-mode == NOTMUCH_DATABASE_MODE_READ_ONLY) return; -if (// todo_sync_enabled +if (message-notmuch-maildir_sync == NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED !notmuch_message_get_flag(message, NOTMUCH_MESSAGE_FLAG_TAGS_INVALID)) { status = _notmuch_message_tags_to_maildir (message); if (status != NOTMUCH_PRIVATE_STATUS_SUCCESS) { diff --git a/lib/notmuch.h b/lib/notmuch.h index 408d633..34b3bcf 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -108,6 +108,19 @@ typedef enum _notmuch_status { const char * notmuch_status_to_string (notmuch_status_t status); +/* Level of synchronization between notmuch tags and maildir flags. */ +enum notmuch_maildir_sync { +NOTMUCH_MAILDIR_SYNC_INVALID = 0, +/* No synchronization */ +NOTMUCH_MAILDIR_SYNC_NONE, +/* Tag new messages accoring to maildir flags */ +NOTMUCH_MAILDIR_SYNC_NEW, +/* The above + update tags for renamed messages */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED, +/* The above + update flags when tags are added/removed. */ +NOTMUCH_MAILDIR_SYNC_NEW_RENAMED_TAGGED, +}; + /* Various opaque data types. For each notmuch_foo_t see the various * notmuch_foo functions below. */ typedef struct _notmuch_database notmuch_database_t; @@ -176,6 +189,12 @@ notmuch_database_open (const char *path, void notmuch_database_close (notmuch_database_t *database); +/* Sets the level of synchronization between maildir flags and notmuch + * tags. */ +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + enum notmuch_maildir_sync maildir_sync); + /* Return the database path of the given database. * * The return value is a string owned by notmuch so should not be diff --git a/notmuch-client.h b/notmuch-client.h index 20be43b..50be95c 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -191,6 +191,13 @@ notmuch_config_set_new_tags (notmuch_config_t *config, const char *new_tags[], size_t length); +enum notmuch_maildir_sync +notmuch_config_get_maildir_sync (notmuch_config_t *config); + +void +notmuch_config_set_maildir_sync (notmuch_config_t *config, +enum notmuch_maildir_sync maildir_sync); + notmuch_bool_t debugger_is_active (void); diff --git a/notmuch-config.c b/notmuch-config.c index cf30603..60d5730 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -61,6 +61,21 @@ static const char user_config_comment[] = recipient list of replies, and will set the From address based on the\n address to which the original email was addressed.\n; +static const char maildir_config_comment[] = + Maildir compatibility configuration\n +\n + Here you can configure whether and how will notmuch synchronize its\n + tags with maildir flags. +\n +\tsync_level Integer in the range 1 - 4
[PATCH 4/4] Tests for maildir synchronization
Signed-off-by: Michal Sojka sojk...@fel.cvut.cz --- test/maildir-sync | 216 + test/notmuch-test |2 +- test/test-lib.sh | 14 +++- 3 files changed, 229 insertions(+), 3 deletions(-) create mode 100755 test/maildir-sync diff --git a/test/maildir-sync b/test/maildir-sync new file mode 100755 index 000..a5f8c36 --- /dev/null +++ b/test/maildir-sync @@ -0,0 +1,216 @@ +#!/bin/bash + +test_description=Test maildir synchronization + +. ./test-lib.sh + +filter_show() { +sed -e 's/, /,\n/g'|sed -e s|${MAIL_DIR}/|| -e '/^tags/d' +echo +} + +cat $NOTMUCH_CONFIG EOF +[maildir] +sync_level=4 +EOF + +test_begin_subtest No new messages +output=$(NOTMUCH_NEW) +test_expect_equal $output No new mail. + +cat expected EOF +Added 1 new message to the database. +EOF +test_expect_success Add a message, no flags ' +generate_message [subject]=\test message\ [date]=\Sat, 01 Jan 2000 12:00:00 -\ [filename]=\msg-001:2,\ +NOTMUCH_NEW actual +test_cmp expected actual +#emacs --eval (gdb \gdb --annotate=3 --args $(which notmuch) new\) +' +cat expected EOF +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox unread) +EOF +test_expect_success 'Search for the message' ' +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize actual +test_cmp expected actual +' +cat expected EOF +No new mail. Detected 1 file rename. +EOF +test_expect_success 'Add seen flag' ' +mv ${gen_msg_filename} ${gen_msg_filename}S +increment_mtime $(dirname ${gen_msg_filename}) +NOTMUCH_NEW actual +test_cmp expected actual +' +cat expected EOF +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox) +EOF +test_expect_success 'Check that tags were updated' ' +notmuch search tag:inbox and not tag:unread | notmuch_search_sanitize actual +test_cmp expected actual +' +cat expected EOF +Added 1 new message to the database. +EOF +test_expect_success Add a seen message ' +generate_message [subject]=\test message 2\ [date]=\Sat, 01 Jan 2000 12:00:00 -\ [filename]=\msg-002:2,S\ +NOTMUCH_NEW actual +test_cmp expected actual +' +cat expected EOF +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox) +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 2 (inbox) +EOF +test_expect_success 'Check that the seen message is not tagged unread' ' +notmuch search tag:inbox and not tag:unread | notmuch_search_sanitize actual +test_cmp expected actual +' +test_expect_success 'Tag the seen messages as replied' ' +notmuch tag +replied -inbox tag:inbox and not tag:unread +' + +cat expected EOF +msg-001:2,RS +msg-002:2,RS +EOF +test_expect_success 'Check that R flag was added' ' +ls -1 ${MAIL_DIR} actual +test_cmp expected actual +' +cat EOF show-expected +[[[{id: msg-...@notmuch-test-suite, +match: true, +filename: msg-001:2,RS, +timestamp: 946728000, +date_relative: 2000-01-01, +headers: {Subject: test message, +From: Notmuch Test Suite test_su...@notmuchmail.org, +To: Notmuch Test Suite test_su...@notmuchmail.org, +Cc: , +Bcc: , +Date: Sat, +01 Jan 2000 12:00:00 -}, +body: [{id: 1, +content-type: text/plain, +content: This is just a test message (#1)\n}]}, +[ +EOF + +test_expect_success 'Renamed message can be shown without running notmuch new' ' +notmuch show --format=json id:msg-...@notmuch-test-suite | filter_show show-actual +test_cmp show-expected show-actual +' + +test_expect_success 'Test that we can reply to the renamed message' ' +notmuch reply id:msg-...@notmuch-test-suite +' + +echo No new mail. expected +test_expect_success 'No rename should be detected by notmuch new' ' +increment_mtime $(dirname ${gen_msg_filename}) +notmuch new actual +test_cmp expected actual +' +test_expect_success Add a message to new/ without info ' +generate_message [subject]=\test message 3\ [date]=\Sat, 01 Jan 2000 12:00:00 -\ [dir]=new +NOTMUCH_NEW actual +test_cmp - actual EOF +Added 1 new message to the database. +EOF +' +test_expect_success Check that the message has inbox and unread tags ' +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize actual +test_cmp - actual EOF +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox unread) +EOF +' +test_expect_success Tag the message with 'tmp' tag ' +notmuch tag +tmp tag:inbox and tag:unread' + +test_expect_success Check that the message was not moved from new/ to cur/ ' +echo filename:$gen_msg_filename expected +notmuch show id:$gen_msg_id|grep -o filename:.*$ actual +test_cmp expected actual +test -f $gen_msg_filename +' +test_expect_success Check that the message was not renamed ' +ls ${MAIL_DIR}/new actual +test_cmp - actual EOF +msg-003 +EOF +' +test_expect_success 'Removing of unread tag should fail without cur/' ' +test_must_fail notmuch tag -unread tag:inbox and tag:unread +' +test_expect_success Check that the tags were not changed ' +notmuch search tag:inbox and tag:unread |
Re: [PATCH v3 0/5] Git-based modularization of test suite
On Wed, 22 Sep 2010, Michal Sojka wrote: On Mon, 20 Sep 2010, Carl Worth wrote: I've now pushed this out, along with some changes of my own on top of it. My changes make things in the test suite look more like they did before the git-based modularization, (both output from the test suite and how the tests themselves are written). I couldn't stand the approach of doing long chains of shell commands within strings for the tests, and I also didn't like the numeric filenames. Take a look at what I've done, and let me know if I defeated any intended benefits of the git-based modularization of the test suite. I went through your changes and they seems reasonable to me. I'll try to update my tests for maildir synchronization and let you know (or send a patch) if I find some problems. Hi Carl, here is my experience with test_begin_subtest and test_expect_equal functions in test-lib.sh. I see there two significant differences from the git's test_expect_success and similar functions. First, when the test fails, you only see the differences in the real output and the expected output. If you use test_expect_success you also see the actual commands that were executed. Second, when some command between test_begin_subtest and test_expect_success fails (e.g. because of segfault) you may not detect it. You can add set -e the test-lib.sh (see the patch bellow), but in this case when a test fails you would see FATAL: Unexpected exit with code 1 without any additional information. -Michal diff --git a/test/test-lib.sh b/test/test-lib.sh index 2036669..c98ea2f 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -395,6 +395,7 @@ add_email_corpus () test_begin_subtest () { test_subtest_name=$1 +set -e } # Pass test if two arguments match ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
notmuch setup: segfault in prompt macro
Hi, While testing Michal Sojka's latest patches, I tried running notmuch setup, only to find that it segfaults. It does this on a vanilla branch, too, though: #0 0x286e3ba5 in memcpy () from /lib/libc.so.7 No symbol table info available. #1 0x28620f6b in getline () from /lib/libc.so.7 No symbol table info available. #2 0x2862113b in getdelim () from /lib/libc.so.7 No symbol table info available. #3 0x28620f03 in getline () from /lib/libc.so.7 No symbol table info available. #4 0x08053c1c in notmuch_setup_command (ctx=0x288090a0, argc=0, argv=0xbfbfe320) at notmuch-setup.c:121 response = 0x0 response_size = 671820800 config = (notmuch_config_t *) 0x2881e490 old_other_emails = (char **) 0xbfbfe324 old_other_emails_len = 0 other_emails = (GPtrArray *) 0xbfbfe2d8 i = 671549033 is_new = 0 new_tags = (const char **) 0x280ae000 new_tags_len = 3217023608 #5 0x0804ec46 in main (argc=2, argv=0xbfbfe318) at notmuch.c:499 local = (void *) 0x288090a0 command = (command_t *) 0x806fd00 i = 0 -- Mike Kelly ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 2/4] Maildir synchronization
+/* ASCII ordered table of Maildir flags and associated tags */ +struct maildir_flag_tag flag2tag[] = { +{ 'D', draft, false}, +{ 'F', flagged, false}, +{ 'P', passed, false}, +{ 'R', replied, false}, +{ 'S', unread, true }, +{ 'T', delete, false}, +}; for all of the 4 patches a: Signed-off-by: Sebastian Spaeth sebast...@sspaeth.de with one caveat: you use the tag delete to mark the state trashed. I think people have slowly settled on the convention deleted which is also more consistent with a state, such as unread, replied, etc... They work fine and obsolete my notmuchsync (except for the pruning of deleted mails and the tagging based on folder names). +1 for merging in notmuch-next or wherever we collect that stuff. Sebastian pgpNLrh1HgxKD.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010 10:24:25 -0400 Mike Kelly pi...@pioto.org wrote: Looks like this may also require a newer xapian than i have now (xapian-core 1.0.18), as notmuch new aborts with: terminate called after throwing an instance of 'Xapian::InvalidArgumentError' I'll see if I can track down anything more concrete as a cause. Well, the full backtrace looks like this: #0 __cxa_throw (obj=0x2883d560, tinfo=0x8070278, dest=0x806132e ~InvalidArgumentError) at ../../.././../gcc-4.4-20100309/libstdc++-v3/libsupc++/eh_throw.cc:67 header = (__cxxabiv1::__cxa_refcounted_exception *) 0x2883d500 #1 0x28353b72 in Xapian::Document::Internal::remove_term () from /usr/local/lib/libxapian.so.21 No symbol table info available. #2 0x28353c96 in Xapian::Document::remove_term () from /usr/local/lib/libxapian.so.21 No symbol table info available. #3 0x080604bc in _notmuch_message_remove_term (message=0x28a85c10, prefix_name=0x806c887 tag, value=0x806c564 draft) at lib/message.cc:737 term = 0x28806ab0 Kdraft #4 0x0806086a in notmuch_message_remove_tag (message=0x28a85c10, tag=0x806c564 draft) at lib/message.cc:832 private_status = 134662454 status = NOTMUCH_STATUS_SUCCESS #5 0x08060a56 in notmuch_message_maildir_to_tags (message=0x28a85c10, filename=0x28a860f0 /usr/home/staff/mike/mail/staff-support/cur/1286944232_2.71920.pit84.pair.com,U=26762,FMD5=74eb4e66bae4700f6b79b81477ef9cfa:2,S) at lib/message.cc:889 flags = 0x28a8616e S i = 0 status = NOTMUCH_STATUS_SUCCESS p = 0x28a8616f f = 83 'S' valid = true unread = true #6 0x08050bbe in add_files_recursive (notmuch=0x2881e7f0, path=0x2881ec70 /usr/home/staff/mike/mail/staff-support/cur, state=0xbfbfe238) at notmuch-new.c:420 err = 32 dir = (DIR *) 0x0 entry = (struct dirent *) 0x28a68640 next = 0x28a860f0 /usr/home/staff/mike/mail/staff-support/cur/1286944232_2.71920.pit84.pair.com,U=26762,FMD5=74eb4e66bae4700f6b79b81477ef9cfa:2,S fs_mtime = 1286978382 db_mtime = 1286944232 status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID ret = NOTMUCH_STATUS_SUCCESS message = (notmuch_message_t *) 0x28a85c10 fs_entries = (struct dirent **) 0x28a6f000 i = 4915 num_fs_entries = 4922 directory = (notmuch_directory_t *) 0x288069f0 db_files = (notmuch_filenames_t *) 0x28806af0 db_subdirs = (notmuch_filenames_t *) 0x28806b30 st = {st_dev = 89, st_ino = 4172664, st_mode = 16832, st_nlink = 2, st_uid = 1118, st_gid = 0, st_rdev = 16689352, st_atimespec = {tv_sec = 1286979943, tv_nsec = 0}, st_mtimespec = {tv_sec = 1286978382, tv_nsec = 0}, st_ctimespec = { tv_sec = 1286978382, tv_nsec = 0}, st_size = 1205760, st_blocks = 2400, st_blksize = 4096, st_flags = 0, st_gen = 0, st_lspare = 0, st_birthtimespec = {tv_sec = 1264441077, tv_nsec = 0}} is_maildir = 0 new_directory = 0 tag = (const char **) 0x8069d62 #7 0x08050780 in add_files_recursive (notmuch=0x2881e7f0, path=0x2881e790 /usr/home/staff/mike/mail/staff-support, state=0xbfbfe238) at notmuch-new.c:302 dir = (DIR *) 0x0 entry = (struct dirent *) 0x288cc5b0 next = 0x2881ec70 /usr/home/staff/mike/mail/staff-support/cur fs_mtime = 1264003223 db_mtime = 1264003223 status = NOTMUCH_STATUS_SUCCESS ret = NOTMUCH_STATUS_SUCCESS message = (notmuch_message_t *) 0x0 fs_entries = (struct dirent **) 0x2883d480 i = 2 num_fs_entries = 5 directory = (notmuch_directory_t *) 0x28806870 db_files = (notmuch_filenames_t *) 0x28806a30 db_subdirs = (notmuch_filenames_t *) 0x28806a70 st = {st_dev = 89, st_ino = 3889110, st_mode = 16832, st_nlink = 5, st_uid = 1118, st_gid = 0, st_rdev = 15524535, st_atimespec = {tv_sec = 1286979943, tv_nsec = 0}, st_mtimespec = {tv_sec = 1264003223, tv_nsec = 0}, st_ctimespec = { tv_sec = 1264473647, tv_nsec = 0}, st_size = 512, st_blocks = 4, st_blksize = 4096, st_flags = 0, st_gen = 0, st_lspare = 0, st_birthtimespec = {tv_sec = 1264003223, tv_nsec = 0}} is_maildir = 1 new_directory = 0 tag = (const char **) 0x8069d62 #8 0x08050780 in add_files_recursive (notmuch=0x2881e7f0, path=0x2881f680 /usr/home/staff/mike/mail, state=0xbfbfe238) at notmuch-new.c:302 dir = (DIR *) 0x0 entry = (struct dirent *) 0x28808900 next = 0x2881e790 /usr/home/staff/mike/mail/staff-support fs_mtime = 1284781182 db_mtime = 1284781182 status = NOTMUCH_STATUS_SUCCESS ret = NOTMUCH_STATUS_SUCCESS message = (notmuch_message_t *) 0x0 fs_entries = (struct dirent **) 0x28825000
Re: [PATCH 0/4] Maildir synchronization v2
On 13 October 2010 08:13, Michal Sojka sojk...@fel.cvut.cz wrote: [...] THERE IS CURRENTLY ONE KNOWN ISSUE: Viewing/storing of attachments of unread messages doesn't work. The reason is that when you view the message its unread tag is removed which causes the file to be renamed, but Emacs still uses the original name to access the attachment. You can workaround this by closing the message and opening it again. This issue will be fixed after we (I) implement notmuch cat command. With this command, emacs would not access the messages by the file name, but by running notmuch cat id:message-id which will always give the correct content. Wouldn't it be more efficient to query notmuch for the filename using the message ID we store in the DB? When network usage is implemented, tramp can give us transparent remote file access in emacs. Regards, Servilio ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v3 0/5] Git-based modularization of test suite
On Wed, 13 Oct 2010 14:44:23 +0200, Michal Sojka sojk...@fel.cvut.cz wrote: here is my experience with test_begin_subtest and test_expect_equal functions in test-lib.sh. I see there two significant differences from the git's test_expect_success and similar functions. First, when the test fails, you only see the differences in the real output and the expected output. If you use test_expect_success you also see the actual commands that were executed. Yes. For me, I never found the printing of the exact commands as something useful. We probably should fix our test suite to behave consistently regardless of which interface is used. Second, when some command between test_begin_subtest and test_expect_success fails (e.g. because of segfault) you may not detect it. You can add set -e the test-lib.sh (see the patch bellow), but in this case when a test fails you would see FATAL: Unexpected exit with code 1 without any additional information. What do you recommend here? Frankly, I'm fine if the test cases are easy to read, (and I think they are easier without having many commands chained by and concatenated into a single string). Then if any test fails, (whether a segfault or simply incorrect output), it shouldn't be hard to just open the test case and manually inspect the commands. But if you've got some idea for anything more useful, (some magic action with trap for example?), I'd be glad to hear it. -Carl -- carl.d.wo...@intel.com pgpJrNyqisRfc.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010 10:50:36 -0400, Servilio Afre Puentes servi...@gmail.com wrote: Wouldn't it be more efficient to query notmuch for the filename using the message ID we store in the DB? When network usage is implemented, tramp can give us transparent remote file access in emacs. We can of course do both. From an implementation point of view, they would both fall under selective output in plain text which various people have been meaning to do, and I think one is no harder than the other. On the other hand I doubt that there is an efficiency advantage to using tramp, it is is more fragile (for example it depends on the remote shell prompt). d ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: notmuch setup: segfault in prompt macro
On Wed, 13 Oct 2010 09:43:40 -0400, Mike Kelly pi...@pioto.org wrote: Hi, While testing Michal Sojka's latest patches, I tried running notmuch setup, only to find that it segfaults. It does this on a vanilla branch, too, though: #0 0x286e3ba5 in memcpy () from /lib/libc.so.7 No symbol table info available. What environment is this where you have libc7 ? d ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: notmuch setup: segfault in prompt macro
(sorry, forgot to reply to list) On Wed, 13 Oct 2010 14:26:56 -0300 David Bremner brem...@unb.ca wrote: On Wed, 13 Oct 2010 09:43:40 -0400, Mike Kelly pi...@pioto.org wrote: Hi, While testing Michal Sojka's latest patches, I tried running notmuch setup, only to find that it segfaults. It does this on a vanilla branch, too, though: #0 0x286e3ba5 in memcpy () from /lib/libc.so.7 No symbol table info available. What environment is this where you have libc7 ? FreeBSD 8.0 -- Mike Kelly ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010, Mike Kelly wrote: On Wed, 13 Oct 2010 10:24:25 -0400 Mike Kelly pi...@pioto.org wrote: Looks like this may also require a newer xapian than i have now (xapian-core 1.0.18), as notmuch new aborts with: terminate called after throwing an instance of 'Xapian::InvalidArgumentError' I'll see if I can track down anything more concrete as a cause. Well, the full backtrace looks like this: So you were able to compile it? What was the problem? #0 __cxa_throw (obj=0x2883d560, tinfo=0x8070278, dest=0x806132e ~InvalidArgumentError) at ../../.././../gcc-4.4-20100309/libstdc++-v3/libsupc++/eh_throw.cc:67 header = (__cxxabiv1::__cxa_refcounted_exception *) 0x2883d500 #1 0x28353b72 in Xapian::Document::Internal::remove_term () from /usr/local/lib/libxapian.so.21 No symbol table info available. #2 0x28353c96 in Xapian::Document::remove_term () from /usr/local/lib/libxapian.so.21 No symbol table info available. #3 0x080604bc in _notmuch_message_remove_term (message=0x28a85c10, prefix_name=0x806c887 tag, value=0x806c564 draft) at lib/message.cc:737 term = 0x28806ab0 Kdraft #4 0x0806086a in notmuch_message_remove_tag (message=0x28a85c10, tag=0x806c564 draft) at lib/message.cc:832 private_status = 134662454 status = NOTMUCH_STATUS_SUCCESS I guess the problem would be that it removes nonexistent tag. I do not experience such a problem on Linux with Xapian 1.2.3. -Michal ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010 22:59:49 +0200 Michal Sojka sojk...@fel.cvut.cz wrote: So you were able to compile it? What was the problem? I mentioned at the bottom of a previous message: This is with gcc (GCC) 4.2.1 20070719 [FreeBSD] Switching to gcc44 seems to allow it to compile correctly, however notmuch didn't used to have that dependency. -- Mike Kelly signature.asc Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/4] Maildir synchronization v2
On Wed, 13 Oct 2010 22:34:34 +0200, Michal Sojka sojk...@fel.cvut.cz wrote: On Wed, 13 Oct 2010, Servilio Afre Puentes wrote: On 13 October 2010 08:13, Michal Sojka sojk...@fel.cvut.cz wrote: [...] THERE IS CURRENTLY ONE KNOWN ISSUE: Viewing/storing of attachments of unread messages doesn't work. The reason is that when you view the message its unread tag is removed which causes the file to be renamed, but Emacs still uses the original name to access the attachment. You can workaround this by closing the message and opening it again. This issue will be fixed after we (I) implement notmuch cat command. With this command, emacs would not access the messages by the file name, but by running notmuch cat id:message-id which will always give the correct content. Wouldn't it be more efficient to query notmuch for the filename using the message ID we store in the DB? When network usage is implemented, tramp can give us transparent remote file access in emacs. Tramp would not be available in non-emacs GUIs. Also, when notmuch cat is implemented, emacs gui will be usable remotely by simply defining notmuch-command variable to contain the name of the script containing: ssh u...@host notmuch $@ That to me is certainly a very elegant solution... so what's stopping us from implementing notmuch cat? No one taken the time to do it? Or is there a design issue left to be resolved? /D ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch