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 57163431FAF
\r
6 for <notmuch@notmuchmail.org>; Fri, 7 Dec 2012 14:21:12 -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 VjEnDJeUL7qT for <notmuch@notmuchmail.org>;
\r
16 Fri, 7 Dec 2012 14:21:11 -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 713C9431FAE
\r
21 for <notmuch@notmuchmail.org>; Fri, 7 Dec 2012 14:21:11 -0800 (PST)
\r
22 Received: by mail-lb0-f181.google.com with SMTP id ge1so803644lbb.26
\r
23 for <notmuch@notmuchmail.org>; Fri, 07 Dec 2012 14:21:09 -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=TmR61HfWCaUUGzHCyQax1XCknNQepPqVyDMufpCFIz0=;
\r
29 b=k5IZcrMMCEJv83fcH96NChi4t1auzit3/HVJ7pHPVfUIyYdknSX1D0cgdC3k+B3qEC
\r
30 FjFInKn8iMRbESXtjfQbjX+qsbL+A/ntZxy/NGtS7eMQmD2+iYtFzLVn8kUeA7cdsnlU
\r
31 ja5StRX0JP/v9r8bbYVW+WgfeMs5fUH7/BTJv250hNb3oAmu6B/P96vpSEti0FwSfpxU
\r
32 KPIRpRASBo2ddT7IhD9ItMd0t0R6DSzl1sHgjoSwFO1/qU/2LaOD+61HcR0sud4o31Ab
\r
33 muAF/g6B2Uy9NVyPL9CQhuGV/363UrYGopEZDSUGgP11/ULKHIc41CCjfP9DihvtrKvR
\r
35 Received: by 10.112.11.68 with SMTP id o4mr3096487lbb.128.1354918869767;
\r
36 Fri, 07 Dec 2012 14:21:09 -0800 (PST)
\r
37 Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.
\r
39 by mx.google.com with ESMTPS id oj5sm5081024lab.8.2012.12.07.14.21.07
\r
40 (version=SSLv3 cipher=OTHER); Fri, 07 Dec 2012 14:21:08 -0800 (PST)
\r
41 From: Jani Nikula <jani@nikula.org>
\r
42 To: david@tethera.net, notmuch@notmuchmail.org
\r
43 Subject: Re: [Patch v3b 1/9] notmuch-dump: add --format=(batch-tag|sup)
\r
44 In-Reply-To: <1354843607-17980-2-git-send-email-david@tethera.net>
\r
45 References: <1354843607-17980-1-git-send-email-david@tethera.net>
\r
46 <1354843607-17980-2-git-send-email-david@tethera.net>
\r
47 User-Agent: Notmuch/0.14+138~g7041c56 (http://notmuchmail.org) Emacs/23.4.1
\r
49 Date: Sat, 08 Dec 2012 00:21:06 +0200
\r
50 Message-ID: <8738zhzep9.fsf@nikula.org>
\r
52 Content-Type: text/plain; charset=us-ascii
\r
54 ALoCoQldKxD3TeDpGdMB77FlSXb7xnCq0ujcjIB3xYCPn+afTHp3ftyGUBKQ3gilR+jRW9btyd28
\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, 07 Dec 2012 22:21:12 -0000
\r
73 On Fri, 07 Dec 2012, david@tethera.net wrote:
\r
74 > From: David Bremner <bremner@debian.org>
\r
76 > sup is the old format, and remains the default, at least until
\r
77 > restore is converted to parse this format.
\r
79 > Each line of the batch-tag format is modelled on the syntax of notmuch tag:
\r
80 > - "notmuch tag" is omitted from the front of the line
\r
81 > - The dump format only uses query strings of a single message-id.
\r
82 > - Each space seperated tag/message-id is 'hex-encoded' to remove
\r
83 > trouble-making characters.
\r
84 > - It is permitted (and will be useful) for there to be no tags before
\r
87 > In particular this format won't have the same problem with e.g. spaces
\r
88 > in message-ids or tags; they will be round-trip-able.
\r
90 > dump-restore-private.h | 13 +++++++++++++
\r
91 > notmuch-dump.c | 48 ++++++++++++++++++++++++++++++++++++++++++------
\r
92 > 2 files changed, 55 insertions(+), 6 deletions(-)
\r
93 > create mode 100644 dump-restore-private.h
\r
95 > diff --git a/dump-restore-private.h b/dump-restore-private.h
\r
96 > new file mode 100644
\r
97 > index 0000000..896a004
\r
99 > +++ b/dump-restore-private.h
\r
101 > +#ifndef DUMP_RESTORE_PRIVATE_H
\r
102 > +#define DUMP_RESTORE_PRIVATE_H
\r
104 > +#include "hex-escape.h"
\r
105 > +#include "command-line-arguments.h"
\r
107 > +typedef enum dump_formats {
\r
108 > + DUMP_FORMAT_AUTO,
\r
109 > + DUMP_FORMAT_BATCH_TAG,
\r
110 > + DUMP_FORMAT_SUP
\r
111 > +} dump_format_t;
\r
114 > diff --git a/notmuch-dump.c b/notmuch-dump.c
\r
115 > index 88f598a..d2dad40 100644
\r
116 > --- a/notmuch-dump.c
\r
117 > +++ b/notmuch-dump.c
\r
118 > @@ -19,6 +19,7 @@
\r
121 > #include "notmuch-client.h"
\r
122 > +#include "dump-restore-private.h"
\r
125 > notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
126 > @@ -43,7 +44,13 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
127 > char *output_file_name = NULL;
\r
130 > + int output_format = DUMP_FORMAT_SUP;
\r
132 > notmuch_opt_desc_t options[] = {
\r
133 > + { NOTMUCH_OPT_KEYWORD, &output_format, "format", 'f',
\r
134 > + (notmuch_keyword_t []){ { "sup", DUMP_FORMAT_SUP },
\r
135 > + { "batch-tag", DUMP_FORMAT_BATCH_TAG },
\r
137 > { NOTMUCH_OPT_STRING, &output_file_name, "output", 'o', 0 },
\r
138 > { 0, 0, 0, 0, 0 }
\r
140 > @@ -83,27 +90,56 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
142 > notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED);
\r
144 > + char *buffer = NULL;
\r
145 > + size_t buffer_size = 0;
\r
147 > for (messages = notmuch_query_search_messages (query);
\r
148 > notmuch_messages_valid (messages);
\r
149 > notmuch_messages_move_to_next (messages)) {
\r
151 > + const char *message_id;
\r
153 > message = notmuch_messages_get (messages);
\r
154 > + message_id = notmuch_message_get_message_id (message);
\r
156 > - fprintf (output,
\r
157 > - "%s (", notmuch_message_get_message_id (message));
\r
158 > + if (output_format == DUMP_FORMAT_SUP) {
\r
159 > + fprintf (output, "%s (", message_id);
\r
162 > for (tags = notmuch_message_get_tags (message);
\r
163 > notmuch_tags_valid (tags);
\r
164 > notmuch_tags_move_to_next (tags)) {
\r
166 > - fprintf (output, " ");
\r
167 > + const char *tag_str = notmuch_tags_get (tags);
\r
169 > - fprintf (output, "%s", notmuch_tags_get (tags));
\r
171 > + fputs (" ", output);
\r
175 > + if (output_format == DUMP_FORMAT_SUP) {
\r
176 > + fputs (tag_str, output);
\r
178 > + if (hex_encode (notmuch, tag_str,
\r
179 > + &buffer, &buffer_size) != HEX_SUCCESS) {
\r
180 > + fprintf (stderr, "Error: failed to hex-encode tag %s\n",
\r
184 > + fprintf (output, "+%s", buffer);
\r
188 > - fprintf (output, ")\n");
\r
189 > + if (output_format == DUMP_FORMAT_SUP) {
\r
190 > + fputs (")\n", output);
\r
192 > + if (hex_encode (notmuch, message_id,
\r
193 > + &buffer, &buffer_size) != HEX_SUCCESS) {
\r
194 > + fprintf (stderr, "Error: failed to hex-encode msg-id %s\n",
\r
198 > + fprintf (output, " -- id:%s\n", buffer);
\r
201 > notmuch_message_destroy (message);
\r
206 > _______________________________________________
\r
207 > notmuch mailing list
\r
208 > notmuch@notmuchmail.org
\r
209 > http://notmuchmail.org/mailman/listinfo/notmuch
\r