lib: replace deprecated n_q_count_messages with status returning version
authorDavid Bremner <david@tethera.net>
Sun, 26 Feb 2017 21:21:34 +0000 (17:21 -0400)
committerDavid Bremner <david@tethera.net>
Wed, 22 Mar 2017 11:35:07 +0000 (08:35 -0300)
This function was deprecated in notmuch 0.21.  We re-use the name for
a status returning version, and deprecate the _st name. One or two
remaining uses of the (removed) non-status returning version fixed at
the same time

bindings/python/notmuch/query.py
bindings/ruby/query.c
lib/database.cc
lib/message.cc
lib/notmuch.h
lib/query.cc
notmuch-count.c
notmuch-reply.c
notmuch-search.c
notmuch-show.c
test/T560-lib-error.sh

index a91bb74091c3392e3fe8f92f7641cf770f521bc9..10fb6dcce4d3b6450386c8008a46d882b243cbd9 100644 (file)
@@ -185,7 +185,7 @@ class Query(object):
             raise NullPointerError
         return Messages(msgs_p, self)
 
-    _count_messages = nmlib.notmuch_query_count_messages_st
+    _count_messages = nmlib.notmuch_query_count_messages
     _count_messages.argtypes = [NotmuchQueryP, POINTER(c_uint)]
     _count_messages.restype = c_uint
 
index 2e36df6a05814a7feb18baef5f2e025fa021c1c8..b6edaef32b208b1aea4ed809476fb403169ff8f1 100644 (file)
@@ -180,7 +180,7 @@ notmuch_rb_query_count_messages (VALUE self)
 
     Data_Get_Notmuch_Query (self, query);
 
-    status = notmuch_query_count_messages_st (query, &count);
+    status = notmuch_query_count_messages (query, &count);
     if (status)
        notmuch_rb_status_raise (status);
 
index 125c4b92baab446e3c7faff5a01fc10232f4fe84..5bc131a35d44a8621d836ab3c2e86ad33c6f793d 100644 (file)
@@ -1493,7 +1493,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
        query = notmuch_query_create (notmuch, "");
        unsigned msg_count;
 
-       status = notmuch_query_count_messages_st (query, &msg_count);
+       status = notmuch_query_count_messages (query, &msg_count);
        if (status)
            goto DONE;
 
index cb313326270e6bc3b0ba5813a5491269e5a62ebb..f8215a49f7dc93b482fb1d309b5ce8c68d6ba2f3 100644 (file)
@@ -1129,7 +1129,7 @@ _notmuch_message_delete (notmuch_message_t *message)
     query = notmuch_query_create (notmuch, query_string);
     if (query == NULL)
        return NOTMUCH_STATUS_OUT_OF_MEMORY;
-    status = notmuch_query_count_messages_st (query, &count);
+    status = notmuch_query_count_messages (query, &count);
     if (status) {
        notmuch_query_destroy (query);
        return status;
index 4b01e3ad88cf0dfacc71023c22fb60816c534081..b79618f6127e78040104dbc9e8a754ba1329c849 100644 (file)
@@ -1008,22 +1008,21 @@ notmuch_threads_destroy (notmuch_threads_t *threads);
  * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The
  *      value of *count is not defined.
  *
- * @since libnotmuch 4.3 (notmuch 0.21)
+ * @since libnotmuch 5 (notmuch 0.25)
  */
 notmuch_status_t
-notmuch_query_count_messages_st (notmuch_query_t *query, unsigned int *count);
+notmuch_query_count_messages (notmuch_query_t *query, unsigned int *count);
 
 /**
- * like notmuch_query_count_messages_st, but without a status return.
+ * Deprecated alias for notmuch_query_count_messages
  *
- * May return 0 in the case of errors.
  *
- * @deprecated Deprecated since libnotmuch 4.3 (notmuch 0.21). Please
- * use notmuch_query_count_messages_st instead.
+ * @deprecated Deprecated since libnotmuch 5.0 (notmuch 0.25). Please
+ * use notmuch_query_count_messages instead.
  */
-NOTMUCH_DEPRECATED(4,3)
-unsigned int
-notmuch_query_count_messages (notmuch_query_t *query);
+NOTMUCH_DEPRECATED(5,0)
+notmuch_status_t
+notmuch_query_count_messages_st (notmuch_query_t *query, unsigned int *count);
 
 /**
  * Return the number of threads matching a search.
index 7192e7f049ddbb678d55ab07219aefa491ea74e3..754ccfccee6d5f48097b51ef14a0d853cc32052a 100644 (file)
@@ -598,18 +598,14 @@ notmuch_threads_destroy (notmuch_threads_t *threads)
     talloc_free (threads);
 }
 
-unsigned int
-notmuch_query_count_messages (notmuch_query_t *query)
+notmuch_status_t
+notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)
 {
-    notmuch_status_t status;
-    unsigned int count;
-
-    status = notmuch_query_count_messages_st (query, &count);
-    return status ? 0 : count;
+    return notmuch_query_count_messages (query, count_out);
 }
 
 notmuch_status_t
-notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)
+notmuch_query_count_messages (notmuch_query_t *query, unsigned *count_out)
 {
     return _notmuch_query_count_documents (query, "mail", count_out);
 }
index d3457bbe91bd07747ddee2c86e3fe1392cac80d3..493be30f07bb2d93d0beae2af01d7cee3b956c62 100644 (file)
@@ -92,7 +92,7 @@ print_count (notmuch_database_t *notmuch, const char *query_str,
 
     switch (output) {
     case OUTPUT_MESSAGES:
-       status = notmuch_query_count_messages_st (query, &ucount);
+       status = notmuch_query_count_messages (query, &ucount);
        if (print_status_query ("notmuch count", query, status))
            return -1;
        printf ("%u", ucount);
index 85efc70243e2b12c6cfc919c935f5566df434b11..2fa6e5a369595379c0fc7defe47a17294f36dc8f 100644 (file)
@@ -630,7 +630,7 @@ static int do_reply(notmuch_config_t *config,
     if (format == FORMAT_JSON || format == FORMAT_SEXP) {
        unsigned count;
 
-       status = notmuch_query_count_messages_st (query, &count);
+       status = notmuch_query_count_messages (query, &count);
        if (print_status_query ("notmuch reply", query, status))
            return 1;
 
index 1c4d52053a73cd42092b6e7a1470ab71aca00e69..71218fdd41af11c711bd197854d80fbd01e8840a 100644 (file)
@@ -529,7 +529,7 @@ do_search_messages (search_context_t *ctx)
     if (ctx->offset < 0) {
        unsigned count;
        notmuch_status_t status;
-       status = notmuch_query_count_messages_st (ctx->query, &count);
+       status = notmuch_query_count_messages (ctx->query, &count);
        if (print_status_query ("notmuch search", ctx->query, status))
            return 1;
 
index ff8228fed1ef220a2e54e251f65849ce2615e0a8..6400594898718ac606364f894fabeee693133f68 100644 (file)
@@ -908,7 +908,7 @@ do_show_single (void *ctx,
     notmuch_status_t status;
     unsigned int count;
 
-    status = notmuch_query_count_messages_st (query, &count);
+    status = notmuch_query_count_messages (query, &count);
     if (print_status_query ("notmuch show", query, status))
        return 1;
 
index f18c88132252c87a4f2e92fd2340018fc8c264d1..34d15698d9b69c80139c1bc54c3eef95b54d3c73 100755 (executable)
@@ -303,9 +303,9 @@ backup_database
 test_begin_subtest "Xapian exception counting messages"
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
    {
+       int count;
        notmuch_query_t *query=notmuch_query_create (db, "id:87ocn0qh6d.fsf@yoom.home.cworth.org");
-       int count = notmuch_query_count_messages (query);
-       stat = (count == 0);
+       stat = notmuch_query_count_messages (query, &count);
    }
 EOF
 sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' < OUTPUT > OUTPUT.clean