Here again we restrict a few tests to version 2, to keep them passing.
---
devel/schemata | 2 ++
lib/message.cc | 20 ++++++++++++++++++++
lib/notmuch.h | 8 ++++++++
notmuch-show.c | 7 +++++++
test/T190-multipart.sh | 6 +++---
test/T220-reply.sh | 2 +-
6 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/devel/schemata b/devel/schemata
index 76dad01..02f7cc0 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -71,6 +71,8 @@ message = {
match: bool,
filename: string,
timestamp: unix_time, # date header as unix time
+ lastmod: int, # database revision when message
+ # was update
date_relative: string, # user-friendly timestamp
tags: [string*],
diff --git a/lib/message.cc b/lib/message.cc
index 26b5e76..9d04438 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -939,6 +939,26 @@ notmuch_message_get_date (notmuch_message_t *message)
return Xapian::sortable_unserialise (value);
}
+time_t
+notmuch_message_get_last_mod (notmuch_message_t *message)
+{
+ std::string value;
+
+ try {
+ value = message->doc.get_value (NOTMUCH_VALUE_LAST_MOD);
+ } catch (Xapian::Error &error) {
+ _notmuch_database_log(_notmuch_message_database (message), "A Xapian
exception occurred when reading last modification: %s\n",
+ error.get_msg().c_str());
+ message->notmuch->exception_reported = TRUE;
+ return 0;
+ }
+
+ if (value.empty ())
+ /* sortable_unserialise is undefined on empty string */
+ return -1;
+ return Xapian::sortable_unserialise (value);
+}
+
notmuch_tags_t *
notmuch_message_get_tags (notmuch_message_t *message)
{
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 5c17d97..b4897ab 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1324,6 +1324,14 @@ time_t
notmuch_message_get_date (notmuch_message_t *message);
/**
+ * Get the last database modifaction revision of 'message' as an
+ * integer.
+ *
+ */
+long int
+notmuch_message_get_last_mod (notmuch_message_t *message);
+
+/**
* Get the value of the specified header from 'message' as a UTF-8 string.
*
* Common headers are stored in the database when the message is
diff --git a/notmuch-show.c b/notmuch-show.c
index 4489ea5..3917b82 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -121,6 +121,7 @@ format_message_sprinter (sprinter_t *sp, notmuch_message_t
*message)
void *local = talloc_new (NULL);
notmuch_tags_t *tags;
time_t date;
+ long int revision;
const char *relative_date;
sp->map_key (sp, "id");
@@ -139,6 +140,12 @@ format_message_sprinter (sprinter_t *sp, notmuch_message_t
*message)
date = notmuch_message_get_date (message);
sp->integer (sp, date);
+ if (notmuch_format_version >= 3) {
+ sp->map_key (sp, "lastmod");
+ revision = notmuch_message_get_last_mod (message);
+ sp->integer (sp, revision);
+ }
+
sp->map_key (sp, "date_relative");
relative_date = notmuch_time_relative_date (local, date);
sp->string (sp, relative_date);
diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh
index f8b805f..a6b4fca 100755
--- a/test/T190-multipart.sh
+++ b/test/T190-multipart.sh
@@ -343,7 +343,7 @@ test_expect_success \
"notmuch show --format=text --part=8
'id:[email protected]'"
test_begin_subtest "--format=json --part=0, full message"
-notmuch show --format=json --part=0 'id:[email protected]'
>OUTPUT
+notmuch show --format=json --format-version=2 --part=0
'id:[email protected]' >OUTPUT
cat <<EOF >EXPECTED
{"id": "[email protected]", "match": true, "excluded":
false, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437,
"date_relative": "2001-01-05", "tags":
["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart
message", "From": "Carl Worth <[email protected]>", "To": "[email protected]",
"Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
{"id": 1, "content-type": "multipart/signed", "content": [
@@ -449,7 +449,7 @@ notmuch show --format=raw
'id:[email protected]' >OUTPUT
test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
test_begin_subtest "--format=raw --part=0, full message"
-notmuch show --format=raw --part=0 'id:[email protected]'
>OUTPUT
+NOTMUCH_SHOW --format=raw --part=0 'id:[email protected]'
>OUTPUT
test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
test_begin_subtest "--format=raw --part=1, message body"
@@ -617,7 +617,7 @@ EOF
test_expect_equal_file OUTPUT EXPECTED
test_begin_subtest "'notmuch reply' to a multipart message with json format"
-notmuch reply --format=json 'id:[email protected]' |
notmuch_json_show_sanitize >OUTPUT
+notmuch reply --format=json --format-version=2
'id:[email protected]' | notmuch_json_show_sanitize >OUTPUT
notmuch_json_show_sanitize <<EOF >EXPECTED
{"reply-headers": {"Subject": "Re: Multipart message",
"From": "Notmuch Test Suite <[email protected]>",
diff --git a/test/T220-reply.sh b/test/T220-reply.sh
index b0d854a..e72f2e4 100755
--- a/test/T220-reply.sh
+++ b/test/T220-reply.sh
@@ -216,7 +216,7 @@ On Tue, 05 Jan 2010 15:43:56 -0000, ☃ <[email protected]>
wrote:
> Encoding"
test_begin_subtest "Reply with RFC 2047-encoded headers (JSON)"
-output=$(notmuch reply --format=json id:${gen_msg_id})
+output=$(notmuch reply --format=json --format-version=2 id:${gen_msg_id})
test_expect_equal_json "$output" '
{
"original": {
--
2.1.4
_______________________________________________
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch