From f524a7e4402a836c2757a003e3635bdd444c1d24 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 7 Jul 2013 11:21:39 +0100 Subject: [PATCH] Re: [PATCH] emacs: hello: make --batch error gracefully --- 9f/0af7888797e133d467f1aaf0ca95fec21aad8f | 178 ++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 9f/0af7888797e133d467f1aaf0ca95fec21aad8f diff --git a/9f/0af7888797e133d467f1aaf0ca95fec21aad8f b/9f/0af7888797e133d467f1aaf0ca95fec21aad8f new file mode 100644 index 000000000..e109d0811 --- /dev/null +++ b/9f/0af7888797e133d467f1aaf0ca95fec21aad8f @@ -0,0 +1,178 @@ +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 1E712431FAF + for ; Sun, 7 Jul 2013 03:21:57 -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 tKmgjLZmK-Fz for ; + Sun, 7 Jul 2013 03:21:49 -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 03544431FAE + for ; Sun, 7 Jul 2013 03:21:48 -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 1Uvm69-0008Th-43; Sun, 07 Jul 2013 11:21:43 +0100 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1Uvm68-0000k1-PQ; Sun, 07 Jul 2013 11:21:41 +0100 +From: Mark Walters +To: Tomi Ollila , notmuch@notmuchmail.org +Subject: Re: [PATCH] emacs: hello: make --batch error gracefully +In-Reply-To: +References: <1372976299-30389-1-git-send-email-markwalters1009@gmail.com> + +User-Agent: Notmuch/0.15.2+192~g8222af3 (http://notmuchmail.org) Emacs/23.4.1 + (i486-pc-linux-gnu) +Date: Sun, 07 Jul 2013 11:21:39 +0100 +Message-ID: <87wqp2d618.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 93.97.24.31 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 06ab073cf17d9903f4bc03239633d510 (of first 20000 bytes) +X-SpamAssassin-Score: 0.0 +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.0 points. Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * 0.0 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: Sun, 07 Jul 2013 10:21:57 -0000 + + +Hi +Tomi Ollila writes: + +> On Fri, Jul 05 2013, Mark Walters wrote: +> +>> Recently notmuch-hello was converted to use batch count. However, it +>> seems that several people run different versions of notmuch-emacs and +>> notmuch-cli so this batch makes emacs fail with an error message if +>> --batch is not available in the CLI. +>> --- +>> There have been two cases on irc of people getting backtraces when +>> hitting this problem so it might be worth adding an informative error +>> message. +> +> This change takes care of the mismatching version problem now -- for +> a short while in most cases but in the future we might face with new +> incompabilities that would -- again -- need new solution. Some day +> we might have a pile of these who everyone is shy to remove from the +> code base ;/ + +I think we want the unless clause anyway: we do not want to try parsing +something and getting stacktrace errors whatever happens. The error +message will need updating so I should probably add a FIXME to the +code. Perhaps the patch roughly as is could be applied to 0.16 and the +fixed error message together with your ideas from below to master? + +> Although I am not against applying this patch (if there are supporters +> of this) I'd like to concentrate fixing this for example the following +> way: + +This looks good. Some thoughts below. + +> We'll add a global option to notmuch, e.g. +> +> --compatibility-version=x.y +> +> Whenever the caller chooses to use this option, notmuch checks whether +> it can comply with the option -- it it can, execution continues, otherwise +> aborts. + +I think the return value could indicate what the problem was (ie too new +or too old): so frontends could decide to work around it (perhaps 22 and +23 to come after the format-version return values). This would mean that +callers would have an easier way of telling if --compatability-version +is supported at all to ease the transition. + +I wondered whether it overlapped with Austin's format-version stuff but +I think it is sufficiently different but some clear documentation as to +which means what could be helpful. + +Best wishes + +Mark + +> The compatibility is determined so that the major 'x' needs to be same +> and caller may have lower 'y' that notmuch is capable of handling. +> +> For example. if notmuch compatibility version was 2.5 +> +> --compatibility-version=1.9 -- abort +> --compatibility-version=2.3 -- continue +> --compatibility-version=2.5 -- continue +> --compatibility-version=2.8 -- abort +> --compatibility-version=3.1 -- abort +> +> +> I can work on this (or on something similar) if this is generally thought +> as a good idea... +> +>> +>> Best wishes +>> +>> Mark +> +> Tomi +> +> +>> +>> emacs/notmuch-hello.el | 9 +++++++-- +>> 1 files changed, 7 insertions(+), 2 deletions(-) +>> +>> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +>> index 147c08c..fa46b7a 100644 +>> --- a/emacs/notmuch-hello.el +>> +++ b/emacs/notmuch-hello.el +>> @@ -402,8 +402,13 @@ options will be handled as specified for +>> (plist-get options :filter))) +>> "\n"))) +>> +>> - (call-process-region (point-min) (point-max) notmuch-command +>> - t t nil "count" "--batch") +>> + (unless (= (call-process-region (point-min) (point-max) notmuch-command +>> + t t nil "count" "--batch") 0) +>> + (notmuch-logged-error "notmuch CLI version mismatch error (count --batch) +>> +The most likely cause of this error is that the CLI is too old +>> +to support count --batch and needs to be upgraded to the same +>> +version as notmuch-emacs")) +>> + +>> (goto-char (point-min)) +>> +>> (notmuch-remove-if-not +>> -- +>> 1.7.9.1 +>> +>> _______________________________________________ +>> notmuch mailing list +>> notmuch@notmuchmail.org +>> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2