From: Mark Walters Date: Tue, 21 Oct 2014 23:32:03 +0000 (+0100) Subject: Re: [PATCH 00/12] Add ghost messages and fix thread linking X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=30c860306451e06647ffab64ac8c1b10b60e47ac;p=notmuch-archives.git Re: [PATCH 00/12] Add ghost messages and fix thread linking --- diff --git a/2c/07a1b325a657c95e64e612720d1d94ffde82fb b/2c/07a1b325a657c95e64e612720d1d94ffde82fb new file mode 100644 index 000000000..9e6dfa8f2 --- /dev/null +++ b/2c/07a1b325a657c95e64e612720d1d94ffde82fb @@ -0,0 +1,199 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 144B0431FB6 + for ; Tue, 21 Oct 2014 16:32:36 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id orDRXjNKJbOW for ; + Tue, 21 Oct 2014 16:32:28 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 1F57D431FAE + for ; Tue, 21 Oct 2014 16:32:28 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1XgiuL-0002un-SR; Wed, 22 Oct 2014 00:32:26 +0100 +Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1XgiuL-0006Lw-AQ; Wed, 22 Oct 2014 00:32:05 +0100 +From: Mark Walters +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH 00/12] Add ghost messages and fix thread linking +In-Reply-To: <1412637438-4821-1-git-send-email-aclements@csail.mit.edu> +References: <1412637438-4821-1-git-send-email-aclements@csail.mit.edu> +User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Wed, 22 Oct 2014 00:32:03 +0100 +Message-ID: <8761fdrocs.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 87.81.223.162 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: e0f4863151f97d6debbe100bbbb22c5d (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.1 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 21 Oct 2014 23:32:36 -0000 + + +On Tue, 07 Oct 2014, Austin Clements wrote: +> This is v2 of the +> id:1412345958-8278-1-git-send-email-aclements@csail.mit.edu. This +> adds some comments and clarifies some code as suggested by David. +> Patch 6 is new in v2 and adds some bit-twiddling macros for clarity +> and robustness in later patches. + +Ok I have now been through the whole series and am basically happy with +it (I sent some trivial comments separately). The tests pass, and my +database still seems to work. + +So +1 from me but it is code I am not very familiar with so it's a +slightly more cautious +1 than usual. + +Best wishes + +Mark + + +> +> The diff from v1 is below. +> +> diff --git a/lib/database.cc b/lib/database.cc +> index 4655f59..6e51a72 100644 +> --- a/lib/database.cc +> +++ b/lib/database.cc +> @@ -1277,6 +1277,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, +> ++total; +> } +> if (new_features & NOTMUCH_FEATURE_GHOSTS) { +> + /* The ghost message upgrade converts all thread_id_* +> + * metadata values into ghost message documents. */ +> t_end = db->metadata_keys_end ("thread_id_"); +> for (t = db->metadata_keys_begin ("thread_id_"); t != t_end; ++t) +> ++total; +> diff --git a/lib/message.cc b/lib/message.cc +> index ad832cf..a7a13cc 100644 +> --- a/lib/message.cc +> +++ b/lib/message.cc +> @@ -344,15 +344,17 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message) +> +> /* Get document type */ +> assert (strcmp (id_prefix, type_prefix) < 0); +> - if (! (message->lazy_flags & (1 << NOTMUCH_MESSAGE_FLAG_GHOST))) { +> + if (! NOTMUCH_TEST_BIT (message->lazy_flags, NOTMUCH_MESSAGE_FLAG_GHOST)) { +> i.skip_to (type_prefix); +> + /* "T" is the prefix "type" fields. See +> + * BOOLEAN_PREFIX_INTERNAL. */ +> if (*i == "Tmail") +> - message->flags &= ~(1 << NOTMUCH_MESSAGE_FLAG_GHOST); +> + NOTMUCH_CLEAR_BIT (&message->flags, NOTMUCH_MESSAGE_FLAG_GHOST); +> else if (*i == "Tghost") +> - message->flags |= (1 << NOTMUCH_MESSAGE_FLAG_GHOST); +> + NOTMUCH_SET_BIT (&message->flags, NOTMUCH_MESSAGE_FLAG_GHOST); +> else +> INTERNAL_ERROR ("Message without type term"); +> - message->lazy_flags |= (1 << NOTMUCH_MESSAGE_FLAG_GHOST); +> + NOTMUCH_SET_BIT (&message->lazy_flags, NOTMUCH_MESSAGE_FLAG_GHOST); +> } +> +> /* Get filename list. Here we get only the terms. We lazily +> @@ -390,8 +392,8 @@ _notmuch_message_invalidate_metadata (notmuch_message_t *message, +> } +> +> if (strcmp ("type", prefix_name) == 0) { +> - message->flags &= ~(1 << NOTMUCH_MESSAGE_FLAG_GHOST); +> - message->lazy_flags &= ~(1 << NOTMUCH_MESSAGE_FLAG_GHOST); +> + NOTMUCH_CLEAR_BIT (&message->flags, NOTMUCH_MESSAGE_FLAG_GHOST); +> + NOTMUCH_CLEAR_BIT (&message->lazy_flags, NOTMUCH_MESSAGE_FLAG_GHOST); +> } +> +> if (strcmp ("file-direntry", prefix_name) == 0) { +> @@ -893,10 +895,10 @@ notmuch_message_get_flag (notmuch_message_t *message, +> notmuch_message_flag_t flag) +> { +> if (flag == NOTMUCH_MESSAGE_FLAG_GHOST && +> - ! (message->lazy_flags & (1 << flag))) +> + ! NOTMUCH_TEST_BIT (message->lazy_flags, flag)) +> _notmuch_message_ensure_metadata (message); +> +> - return message->flags & (1 << flag); +> + return NOTMUCH_TEST_BIT (message->flags, flag); +> } +> +> void +> @@ -904,10 +906,10 @@ notmuch_message_set_flag (notmuch_message_t *message, +> notmuch_message_flag_t flag, notmuch_bool_t enable) +> { +> if (enable) +> - message->flags |= (1 << flag); +> + NOTMUCH_SET_BIT (&message->flags, flag); +> else +> - message->flags &= ~(1 << flag); +> - message->lazy_flags |= (1 << flag); +> + NOTMUCH_CLEAR_BIT (&message->flags, flag); +> + NOTMUCH_SET_BIT (&message->lazy_flags, flag); +> } +> +> time_t +> diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h +> index 2fbd38e..2f43c1d 100644 +> --- a/lib/notmuch-private.h +> +++ b/lib/notmuch-private.h +> @@ -63,6 +63,17 @@ NOTMUCH_BEGIN_DECLS +> #define STRNCMP_LITERAL(var, literal) \ +> strncmp ((var), (literal), sizeof (literal) - 1) +> +> +/* Robust bit test/set/reset macros */ +> +#define NOTMUCH_TEST_BIT(val, bit) \ +> + ((bit < 0 || bit >= CHAR_BIT * sizeof (unsigned long long)) ? 0 \ +> + : !!((val) & (1ull << bit))) +> +#define NOTMUCH_SET_BIT(valp, bit) \ +> + ((bit < 0 || bit >= CHAR_BIT * sizeof (unsigned long long)) ? *(valp) \ +> + : (*(valp) |= (1ull << bit))) +> +#define NOTMUCH_CLEAR_BIT(valp, bit) \ +> + ((bit < 0 || bit >= CHAR_BIT * sizeof (unsigned long long)) ? *(valp) \ +> + : (*(valp) &= ~(1ull << bit))) +> + +> #define unused(x) x __attribute__ ((unused)) +> +> #ifdef __cplusplus +> +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch