[PATCH 3/5] cli/count: add --output=modifications
Maybe another consistent solution is to add a --format argument to count, with JSON as one option. That way we could even add more information to other count results (if that becomes needed at some point) without breaking code using the JSON interface. Best regards, Daniel
[PATCH 3/5] cli/count: add --output=modifications
Tomi Ollila writes: > $ notmuch metadata uuid > $ notmuch metadata lastmod > $ notmuch metadata uuid lastmod > $ notmuch metadata lastmod uuid > > Now we can bikeshed whether this is good idea -- it seems OK. We will have some set of 'fake' metadata keys that are not actually stored in xapian metadata. Perversely this includes both lastmod and uuid > and what to do (and when) > if unknown key is used in request... Error out, I'd say, but if it's not one of our fake metadata items we can in general just ask xapian for that value of that metadata, and complain if it doesn't exist.
[PATCH 3/5] cli/count: add --output=modifications
On Tue, Aug 11 2015, David Bremner wrote: > Tomi Ollila writes: > >> 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). > > Can you think of any use case for the uuid with the other count outputs? > It feels pretty artificial to me. I don't... I just thought something consistent to be used w/ notmuch count... > Another option is to make a "notmuch metadata" command. I'm not really > sure about the syntax, but perhaps a uuid option makes more sense > there, so e.g. > >notmuch metadata --with-uuid lastmod or notmuch metadata key [key [key]], then (currently) we could have: $ notmuch metadata uuid $ notmuch metadata lastmod $ notmuch metadata uuid lastmod $ notmuch metadata lastmod uuid Now we can bikeshed whether this is good idea -- and what to do (and when) if unknown key is used in request... Tomi > I'm pretty convinced that we need report uuid and lastmod together (at > least optionally). I'm less sure we need a full get/set interface for > metadata, since people with that use case could use xapian-metadata. >
Re: [PATCH 3/5] cli/count: add --output=modifications
Tomi Ollila tomi.oll...@iki.fi writes: $ notmuch metadata uuid $ notmuch metadata lastmod $ notmuch metadata uuid lastmod $ notmuch metadata lastmod uuid Now we can bikeshed whether this is good idea -- it seems OK. We will have some set of 'fake' metadata keys that are not actually stored in xapian metadata. Perversely this includes both lastmod and uuid and what to do (and when) if unknown key is used in request... Error out, I'd say, but if it's not one of our fake metadata items we can in general just ask xapian for that value of that metadata, and complain if it doesn't exist. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 3/5] cli/count: add --output=modifications
Maybe another consistent solution is to add a --format argument to count, with JSON as one option. That way we could even add more information to other count results (if that becomes needed at some point) without breaking code using the JSON interface. Best regards, Daniel ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/5] cli/count: add --output=modifications
Tomi Ollila writes: > 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). Can you think of any use case for the uuid with the other count outputs? It feels pretty artificial to me. Another option is to make a "notmuch metadata" command. I'm not really sure about the syntax, but perhaps a uuid option makes more sense there, so e.g. notmuch metadata --with-uuid lastmod I'm pretty convinced that we need report uuid and lastmod together (at least optionally). I'm less sure we need a full get/set interface for metadata, since people with that use case could use xapian-metadata.
Re: [PATCH 3/5] cli/count: add --output=modifications
Tomi Ollila tomi.oll...@iki.fi writes: 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). Can you think of any use case for the uuid with the other count outputs? It feels pretty artificial to me. Another option is to make a notmuch metadata command. I'm not really sure about the syntax, but perhaps a uuid option makes more sense there, so e.g. notmuch metadata --with-uuid lastmod I'm pretty convinced that we need report uuid and lastmod together (at least optionally). I'm less sure we need a full get/set interface for metadata, since people with that use case could use xapian-metadata. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 3/5] cli/count: add --output=modifications
On Tue, Aug 11 2015, David Bremner da...@tethera.net wrote: Tomi Ollila tomi.oll...@iki.fi writes: 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). Can you think of any use case for the uuid with the other count outputs? It feels pretty artificial to me. I don't... I just thought something consistent to be used w/ notmuch count... Another option is to make a notmuch metadata command. I'm not really sure about the syntax, but perhaps a uuid option makes more sense there, so e.g. notmuch metadata --with-uuid lastmod or notmuch metadata key [key [key]], then (currently) we could have: $ notmuch metadata uuid $ notmuch metadata lastmod $ notmuch metadata uuid lastmod $ notmuch metadata lastmod uuid Now we can bikeshed whether this is good idea -- and what to do (and when) if unknown key is used in request... Tomi I'm pretty convinced that we need report uuid and lastmod together (at least optionally). I'm less sure we need a full get/set interface for metadata, since people with that use case could use xapian-metadata. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/5] cli/count: add --output=modifications
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, ); > + 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", '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 at notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 3/5] cli/count: add --output=modifications
On Sun, Aug 09 2015, David Bremner da...@tethera.net 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 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/5] cli/count: add --output=modifications
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. --- 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; + } + + revision = notmuch_database_get_revision (notmuch, ); + printf ("%s\t%lu\n", uuid, revision); } + 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", '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
[PATCH 3/5] cli/count: add --output=modifications
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. --- 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; + } + + revision = notmuch_database_get_revision (notmuch, uuid); + printf (%s\t%lu\n, uuid, revision); } + 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