1 Return-Path: <jani@nikula.org>
\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 olra.theworths.org (Postfix) with ESMTP id 80958431FAE
\r
6 for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 15:37:28 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id nbDGbLS05XxI for <notmuch@notmuchmail.org>;
\r
16 Fri, 30 Nov 2012 15:37:24 -0800 (PST)
\r
17 Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com
\r
18 [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id CF581431FAF
\r
21 for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 15:37:23 -0800 (PST)
\r
22 Received: by mail-lb0-f181.google.com with SMTP id ge1so976616lbb.26
\r
23 for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 15:37:22 -0800 (PST)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=google.com; s=20120113;
\r
26 h=from:to:cc:subject:in-reply-to:references:user-agent:date
\r
27 :message-id:mime-version:content-type:x-gm-message-state;
\r
28 bh=aGY7tumjfDKNLlBKh+QA7jViXLnCvdeOKyMUdWVxOSo=;
\r
29 b=ANF2zQAdzwfdHRkUnI5upBzWgc83NMxN4YTk3/4a8DjEl1q7mShffiSS7LH1l9mAKe
\r
30 Zka7UcKqTbqK6QFYSpWldYKB2FDDhmgLJCf/z0r7iKj/RrZWz7BTcF/5H+FvBHAaU4DF
\r
31 dNQbfuf8hH4hkj5F+Q+4OdDtMyOkrQP+0ihaeCBa8zkHcsu4bckZRkmi5S8o+869ylG5
\r
32 9y6ZgqITHCxCTyDtteFr09KAmWn/rnEIwasF/xf3yu/LV1Wa9CTu15PtYLknMeHqpNOm
\r
33 F/+kTRD7jGcZkT5sGzDXKo0VnjJ/46CwKGCywhzPq1YufkkWB4Gr6mK23Vi+ZEKojLeU
\r
35 Received: by 10.112.25.168 with SMTP id d8mr1513108lbg.62.1354318642317;
\r
36 Fri, 30 Nov 2012 15:37:22 -0800 (PST)
\r
37 Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.
\r
39 by mx.google.com with ESMTPS id q2sm2581307lbd.14.2012.11.30.15.37.20
\r
40 (version=SSLv3 cipher=OTHER); Fri, 30 Nov 2012 15:37:21 -0800 (PST)
\r
41 From: Jani Nikula <jani@nikula.org>
\r
42 To: david@tethera.net, notmuch@notmuchmail.org
\r
43 Subject: Re: [Patch v2 07/17] notmuch-dump: add --format=(batch-tag|sup)
\r
44 In-Reply-To: <1353792017-31459-8-git-send-email-david@tethera.net>
\r
45 References: <1353792017-31459-1-git-send-email-david@tethera.net>
\r
46 <1353792017-31459-8-git-send-email-david@tethera.net>
\r
47 User-Agent: Notmuch/0.14+124~g3b17402 (http://notmuchmail.org) Emacs/23.4.1
\r
49 Date: Sat, 01 Dec 2012 01:37:19 +0200
\r
50 Message-ID: <87ip8maci8.fsf@nikula.org>
\r
52 Content-Type: text/plain; charset=us-ascii
\r
54 ALoCoQlvcGtYDemL1cPY0KSExPODMlyXdIQUNAj8xDHQ6HrTCMEx/4FVRGcbXEHN6omMRuzpT8+z
\r
55 Cc: David Bremner <bremner@debian.org>
\r
56 X-BeenThere: notmuch@notmuchmail.org
\r
57 X-Mailman-Version: 2.1.13
\r
59 List-Id: "Use and development of the notmuch mail system."
\r
60 <notmuch.notmuchmail.org>
\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
64 List-Post: <mailto:notmuch@notmuchmail.org>
\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
68 X-List-Received-Date: Fri, 30 Nov 2012 23:37:28 -0000
\r
70 On Sat, 24 Nov 2012, david@tethera.net wrote:
\r
71 > From: David Bremner <bremner@debian.org>
\r
73 > sup is the old format, and remains the default, at least until
\r
74 > restore is converted to parse this format.
\r
76 > Each line of the batch- format is valid for notmuch tag, (with the
\r
77 > "notmuch tag" omitted from the front of the line). The dump format
\r
78 > only uses query strings of a single message-id.
\r
80 Valid for notmuch tag except for the hex encoding and empty set of tags.
\r
82 > Each space seperated tag/message-id is 'hex-encoded' to remove
\r
83 > troubling characters. In particular this format won't have the same
\r
84 > problem with e.g. spaces in message-ids or tags; they will be
\r
87 > dump-restore-private.h | 13 +++++++++++++
\r
88 > notmuch-dump.c | 42 ++++++++++++++++++++++++++++++++++++------
\r
89 > 2 files changed, 49 insertions(+), 6 deletions(-)
\r
90 > create mode 100644 dump-restore-private.h
\r
92 > diff --git a/dump-restore-private.h b/dump-restore-private.h
\r
93 > new file mode 100644
\r
94 > index 0000000..896a004
\r
96 > +++ b/dump-restore-private.h
\r
98 > +#ifndef DUMP_RESTORE_PRIVATE_H
\r
99 > +#define DUMP_RESTORE_PRIVATE_H
\r
101 > +#include "hex-escape.h"
\r
102 > +#include "command-line-arguments.h"
\r
104 > +typedef enum dump_formats {
\r
105 > + DUMP_FORMAT_AUTO,
\r
106 > + DUMP_FORMAT_BATCH_TAG,
\r
107 > + DUMP_FORMAT_SUP
\r
108 > +} dump_format_t;
\r
111 > diff --git a/notmuch-dump.c b/notmuch-dump.c
\r
112 > index 88f598a..045ca9e 100644
\r
113 > --- a/notmuch-dump.c
\r
114 > +++ b/notmuch-dump.c
\r
115 > @@ -19,6 +19,7 @@
\r
118 > #include "notmuch-client.h"
\r
119 > +#include "dump-restore-private.h"
\r
122 > notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
123 > @@ -43,7 +44,13 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
124 > char *output_file_name = NULL;
\r
127 > + int output_format = DUMP_FORMAT_SUP;
\r
129 > notmuch_opt_desc_t options[] = {
\r
130 > + { NOTMUCH_OPT_KEYWORD, &output_format, "format", 'f',
\r
131 > + (notmuch_keyword_t []){ { "sup", DUMP_FORMAT_SUP },
\r
132 > + { "batch-tag", DUMP_FORMAT_BATCH_TAG },
\r
134 > { NOTMUCH_OPT_STRING, &output_file_name, "output", 'o', 0 },
\r
135 > { 0, 0, 0, 0, 0 }
\r
137 > @@ -83,27 +90,50 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
139 > notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED);
\r
141 > + char *buffer = NULL;
\r
142 > + size_t buffer_size = 0;
\r
144 > for (messages = notmuch_query_search_messages (query);
\r
145 > notmuch_messages_valid (messages);
\r
146 > notmuch_messages_move_to_next (messages)) {
\r
148 > + const char *message_id;
\r
150 > message = notmuch_messages_get (messages);
\r
151 > + message_id = notmuch_message_get_message_id (message);
\r
153 > - fprintf (output,
\r
154 > - "%s (", notmuch_message_get_message_id (message));
\r
155 > + if (output_format == DUMP_FORMAT_SUP) {
\r
156 > + fprintf (output, "%s (", message_id);
\r
159 > for (tags = notmuch_message_get_tags (message);
\r
160 > notmuch_tags_valid (tags);
\r
161 > notmuch_tags_move_to_next (tags)) {
\r
163 > - fprintf (output, " ");
\r
164 > + const char *tag_str = notmuch_tags_get (tags);
\r
166 > - fprintf (output, "%s", notmuch_tags_get (tags));
\r
168 > + fputs (" ", output);
\r
172 > + if (output_format == DUMP_FORMAT_SUP) {
\r
173 > + fputs (tag_str, output);
\r
175 > + if (hex_encode (notmuch, tag_str,
\r
176 > + &buffer, &buffer_size) != HEX_SUCCESS)
\r
179 Maybe hex_encode errors would deserve an error message. Ditto below.
\r
186 > + fprintf (output, "+%s", buffer);
\r
190 > - fprintf (output, ")\n");
\r
191 > + if (output_format == DUMP_FORMAT_SUP) {
\r
192 > + fputs (")\n", output);
\r
194 > + if (hex_encode (notmuch, message_id,
\r
195 > + &buffer, &buffer_size) != HEX_SUCCESS)
\r
197 > + fprintf (output, " -- id:%s\n", buffer);
\r
200 > notmuch_message_destroy (message);
\r
205 > _______________________________________________
\r
206 > notmuch mailing list
\r
207 > notmuch@notmuchmail.org
\r
208 > http://notmuchmail.org/mailman/listinfo/notmuch
\r