From: Tomi Ollila Date: Mon, 10 Aug 2015 19:28:05 +0000 (+0300) Subject: Re: [PATCH 3/5] cli/count: add --output=modifications X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ea8408ffd956fdafd5ad1285d2b751dd88ee53ea;p=notmuch-archives.git Re: [PATCH 3/5] cli/count: add --output=modifications --- diff --git a/bc/d67f00967eb21a714f3cf193679b0d9410976d b/bc/d67f00967eb21a714f3cf193679b0d9410976d new file mode 100644 index 000000000..780927d24 --- /dev/null +++ b/bc/d67f00967eb21a714f3cf193679b0d9410976d @@ -0,0 +1,173 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 51A726DE1579 + for ; Mon, 10 Aug 2015 12:28:24 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 1.246 +X-Spam-Level: * +X-Spam-Status: No, score=1.246 tagged_above=-999 required=5 tests=[AWL=-0.150, + SPF_NEUTRAL=0.652, URIBL_SBL=0.644, URIBL_SBL_A=0.1] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id TULiCnjWko46 for ; + Mon, 10 Aug 2015 12:28:21 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 355AC6DE0244 + for ; Mon, 10 Aug 2015 12:28:20 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id E1FEB1000CE; + Mon, 10 Aug 2015 22:28:05 +0300 (EEST) +From: Tomi Ollila +To: David Bremner , notmuch@notmuchmail.org +Subject: Re: [PATCH 3/5] cli/count: add --output=modifications +In-Reply-To: <1439112285-6681-4-git-send-email-david@tethera.net> +References: <1439112285-6681-1-git-send-email-david@tethera.net> + <1439112285-6681-4-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.20.2+58~ge9cd033 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +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: Mon, 10 Aug 2015 19:28:24 -0000 + +On Sun, Aug 09 2015, David Bremner wrote: + +> We need some way to extract the uuid/revision of the database, and +> count seems like the least bad choice of current commands. +> The (perhaps weak) argument for count over search is that count +> already reports statistics about the entire database. + +The '(perhaps weak)' part could be discussed outside of the commit message ;) +... but read below for (IMO) "real" issues... + +> --- +> notmuch-count.c | 18 +++++++++++++++++- +> test/T570-revision-tracking.sh | 12 ++++++++++++ +> 2 files changed, 29 insertions(+), 1 deletion(-) +> +> diff --git a/notmuch-count.c b/notmuch-count.c +> index 57a88a8..7c61ccb 100644 +> --- a/notmuch-count.c +> +++ b/notmuch-count.c +> @@ -25,6 +25,7 @@ enum { +> OUTPUT_THREADS, +> OUTPUT_MESSAGES, +> OUTPUT_FILES, +> + OUTPUT_LASTMOD, +> }; +> +> /* The following is to allow future options to be added more easily */ +> @@ -71,6 +72,9 @@ print_count (notmuch_database_t *notmuch, const char *query_str, +> { +> notmuch_query_t *query; +> size_t i; +> + unsigned long revision; +> + const char *uuid; +> + int ret = 0; +> +> query = notmuch_query_create (notmuch, query_str); +> if (query == NULL) { +> @@ -91,11 +95,22 @@ print_count (notmuch_database_t *notmuch, const char *query_str, +> case OUTPUT_FILES: +> printf ("%u\n", count_files (query)); +> break; +> + case OUTPUT_LASTMOD: +> + if (strcmp (notmuch_query_get_query_string (query), "*") != 0) { +> + fprintf (stderr, "Error: Only '*' is currently supported " +> + " with output=modifications\n"); +> + ret = 1; +> + goto DONE; +> + } + +I have three comments on this series, the first one is hardest, second +trivial and one could be either way. + +> + +> + revision = notmuch_database_get_revision (notmuch, &uuid); +> + printf ("%s\t%lu\n", uuid, revision); + +Currently, `notmuch count` outputs lines that contain just one integer; +this changes this by introducing output with uuid ([0-9a-f-]) and integer +delimited by tab character. + +To put it lightly, this looks "inconsistent" and don't please my aesthetic +eye. + +One option (being it worse or better) could be that by default only +lastmod value is printed and with separate option it is prefixed with +database UUID (in every --output option). + +BTW: I did not see notmuch-count.rst updated. good for now as it reduces +the amount of work during this bikeshed period ;D + +continuing in next email... + +Tomi + + + +> } +> +> + DONE: +> notmuch_query_destroy (query); +> +> - return 0; +> + return ret; +> } +> +> static int +> @@ -139,6 +154,7 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[]) +> (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS }, +> { "messages", OUTPUT_MESSAGES }, +> { "files", OUTPUT_FILES }, +> + { "modifications", OUTPUT_LASTMOD }, +> { 0, 0 } } }, +> { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x', +> (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE }, +> diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh +> index e0a5703..008c5d0 100755 +> --- a/test/T570-revision-tracking.sh +> +++ b/test/T570-revision-tracking.sh +> @@ -34,4 +34,16 @@ UUID 53 +> EOF +> test_expect_equal_file EXPECTED CLEAN +> +> +grep '^[0-9a-f]' OUTPUT > INITIAL_OUTPUT +> + +> +test_begin_subtest "output of count matches test code" +> +notmuch count --output=modifications '*' > OUTPUT +> +test_expect_equal_file INITIAL_OUTPUT OUTPUT +> + +> +test_begin_subtest "modification count increases" +> +before=$(notmuch count --output=modifications '*' | cut -f2) +> +notmuch tag +a-random-tag-8743632 '*' +> +after=$(notmuch count --output=modifications '*' | cut -f2) +> +result=$(($before < $after)) +> +test_expect_equal 1 ${result} +> test_done +> -- +> 2.1.4 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch