Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / 2a / 416a31ecd4710a4fd876021be0a07aec8e2a2f
1 Return-Path: <bremner@tesseract.cs.unb.ca>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id D18286DE1BB6\r
6  for <notmuch@notmuchmail.org>; Sun,  5 Apr 2015 16:03:44 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.495\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.495 tagged_above=-999 required=5 tests=[AWL=0.485, \r
12  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id tX931MVO-Mzt for <notmuch@notmuchmail.org>;\r
16  Sun,  5 Apr 2015 16:03:43 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18  [87.98.215.224])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id 24B2E6DE1BAD\r
20  for <notmuch@notmuchmail.org>; Sun,  5 Apr 2015 16:03:36 -0700 (PDT)\r
21 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
22  4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
23  id 1YetZ8-0002qC-Gw; Sun, 05 Apr 2015 23:02:54 +0000\r
24 Received: (nullmailer pid 2251 invoked by uid 1000); Sun, 05 Apr 2015\r
25  22:59:25 -0000\r
26 From: David Bremner <david@tethera.net>\r
27 To: notmuch@notmuchmail.org\r
28 Subject: [WIP2 08/12] cli/show: add lastmod to structured output\r
29 Date: Mon,  6 Apr 2015 07:59:10 +0900\r
30 Message-Id: <1428274754-1698-9-git-send-email-david@tethera.net>\r
31 X-Mailer: git-send-email 2.1.4\r
32 In-Reply-To: <1428274754-1698-1-git-send-email-david@tethera.net>\r
33 References: <1428274754-1698-1-git-send-email-david@tethera.net>\r
34 MIME-Version: 1.0\r
35 Content-Type: text/plain; charset=UTF-8\r
36 Content-Transfer-Encoding: 8bit\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.18\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41  <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Sun, 05 Apr 2015 23:03:44 -0000\r
50 \r
51 Here again we restrict a few tests to version 2, to keep them passing.\r
52 ---\r
53  devel/schemata         |  2 ++\r
54  lib/message.cc         | 20 ++++++++++++++++++++\r
55  lib/notmuch.h          |  8 ++++++++\r
56  notmuch-show.c         |  7 +++++++\r
57  test/T190-multipart.sh |  6 +++---\r
58  test/T220-reply.sh     |  2 +-\r
59  6 files changed, 41 insertions(+), 4 deletions(-)\r
60 \r
61 diff --git a/devel/schemata b/devel/schemata\r
62 index 76dad01..02f7cc0 100644\r
63 --- a/devel/schemata\r
64 +++ b/devel/schemata\r
65 @@ -71,6 +71,8 @@ message = {\r
66      match:          bool,\r
67      filename:      string,\r
68      timestamp:      unix_time, # date header as unix time\r
69 +    lastmod:       int,       # database revision when message\r
70 +                              # was update\r
71      date_relative:  string,   # user-friendly timestamp\r
72      tags:           [string*],\r
73  \r
74 diff --git a/lib/message.cc b/lib/message.cc\r
75 index 26b5e76..9d04438 100644\r
76 --- a/lib/message.cc\r
77 +++ b/lib/message.cc\r
78 @@ -939,6 +939,26 @@ notmuch_message_get_date (notmuch_message_t *message)\r
79      return Xapian::sortable_unserialise (value);\r
80  }\r
81  \r
82 +time_t\r
83 +notmuch_message_get_last_mod (notmuch_message_t *message)\r
84 +{\r
85 +    std::string value;\r
86 +\r
87 +    try {\r
88 +       value = message->doc.get_value (NOTMUCH_VALUE_LAST_MOD);\r
89 +    } catch (Xapian::Error &error) {\r
90 +       _notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred when reading last modification: %s\n",\r
91 +                error.get_msg().c_str());\r
92 +       message->notmuch->exception_reported = TRUE;\r
93 +       return 0;\r
94 +    }\r
95 +\r
96 +    if (value.empty ())\r
97 +       /* sortable_unserialise is undefined on empty string */\r
98 +       return -1;\r
99 +    return Xapian::sortable_unserialise (value);\r
100 +}\r
101 +\r
102  notmuch_tags_t *\r
103  notmuch_message_get_tags (notmuch_message_t *message)\r
104  {\r
105 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
106 index 5c17d97..b4897ab 100644\r
107 --- a/lib/notmuch.h\r
108 +++ b/lib/notmuch.h\r
109 @@ -1324,6 +1324,14 @@ time_t\r
110  notmuch_message_get_date  (notmuch_message_t *message);\r
111  \r
112  /**\r
113 + * Get the last database modifaction revision of 'message' as an\r
114 + * integer.\r
115 + *\r
116 + */\r
117 +long int\r
118 +notmuch_message_get_last_mod  (notmuch_message_t *message);\r
119 +\r
120 +/**\r
121   * Get the value of the specified header from 'message' as a UTF-8 string.\r
122   *\r
123   * Common headers are stored in the database when the message is\r
124 diff --git a/notmuch-show.c b/notmuch-show.c\r
125 index 4489ea5..3917b82 100644\r
126 --- a/notmuch-show.c\r
127 +++ b/notmuch-show.c\r
128 @@ -121,6 +121,7 @@ format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)\r
129      void *local = talloc_new (NULL);\r
130      notmuch_tags_t *tags;\r
131      time_t date;\r
132 +    long int revision;\r
133      const char *relative_date;\r
134  \r
135      sp->map_key (sp, "id");\r
136 @@ -139,6 +140,12 @@ format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)\r
137      date = notmuch_message_get_date (message);\r
138      sp->integer (sp, date);\r
139  \r
140 +    if (notmuch_format_version >= 3) {\r
141 +       sp->map_key (sp, "lastmod");\r
142 +       revision = notmuch_message_get_last_mod (message);\r
143 +       sp->integer (sp, revision);\r
144 +    }\r
145 +\r
146      sp->map_key (sp, "date_relative");\r
147      relative_date = notmuch_time_relative_date (local, date);\r
148      sp->string (sp, relative_date);\r
149 diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh\r
150 index f8b805f..a6b4fca 100755\r
151 --- a/test/T190-multipart.sh\r
152 +++ b/test/T190-multipart.sh\r
153 @@ -343,7 +343,7 @@ test_expect_success \\r
154      "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"\r
155  \r
156  test_begin_subtest "--format=json --part=0, full message"\r
157 -notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
158 +notmuch show --format=json --format-version=2 --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
159  cat <<EOF >EXPECTED\r
160  {"id": "87liy5ap00.fsf@yoom.home.cworth.org", "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 <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [\r
161  {"id": 1, "content-type": "multipart/signed", "content": [\r
162 @@ -449,7 +449,7 @@ notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
163  test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart\r
164  \r
165  test_begin_subtest "--format=raw --part=0, full message"\r
166 -notmuch show --format=raw --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
167 +NOTMUCH_SHOW --format=raw --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
168  test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart\r
169  \r
170  test_begin_subtest "--format=raw --part=1, message body"\r
171 @@ -617,7 +617,7 @@ EOF\r
172  test_expect_equal_file OUTPUT EXPECTED\r
173  \r
174  test_begin_subtest "'notmuch reply' to a multipart message with json format"\r
175 -notmuch reply --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_json_show_sanitize >OUTPUT\r
176 +notmuch reply --format=json --format-version=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_json_show_sanitize >OUTPUT\r
177  notmuch_json_show_sanitize <<EOF >EXPECTED\r
178  {"reply-headers": {"Subject": "Re: Multipart message",\r
179   "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
180 diff --git a/test/T220-reply.sh b/test/T220-reply.sh\r
181 index b0d854a..e72f2e4 100755\r
182 --- a/test/T220-reply.sh\r
183 +++ b/test/T220-reply.sh\r
184 @@ -216,7 +216,7 @@ On Tue, 05 Jan 2010 15:43:56 -0000, ☃ <snowman@example.com> wrote:\r
185  > Encoding"\r
186  \r
187  test_begin_subtest "Reply with RFC 2047-encoded headers (JSON)"\r
188 -output=$(notmuch reply --format=json id:${gen_msg_id})\r
189 +output=$(notmuch reply --format=json --format-version=2 id:${gen_msg_id})\r
190  test_expect_equal_json "$output" '\r
191  {\r
192      "original": {\r
193 -- \r
194 2.1.4\r
195 \r