[PATCH 3/6] lib: replace deprecated n_q_search_messages with status returning version

David Bremner david at tethera.net
Sun Feb 26 13:21:32 PST 2017


This function was deprecated in notmuch 0.21.  We re-use the name for
a status returning version, and deprecate the _st name.
---
 bindings/python/notmuch/query.py |  6 +++---
 bindings/ruby/query.c            |  2 +-
 lib/database.cc                  |  2 +-
 lib/notmuch.h                    | 22 +++++++++++-----------
 lib/query.cc                     | 20 ++++++++------------
 lib/thread.cc                    |  2 +-
 notmuch-count.c                  |  2 +-
 notmuch-dump.c                   |  2 +-
 notmuch-reply.c                  |  2 +-
 notmuch-search.c                 |  4 ++--
 notmuch-show.c                   |  2 +-
 notmuch-tag.c                    |  2 +-
 test/T560-lib-error.sh           |  2 +-
 test/T640-database-modified.sh   |  2 +-
 14 files changed, 34 insertions(+), 38 deletions(-)

diff --git a/bindings/python/notmuch/query.py b/bindings/python/notmuch/query.py
index 3419f626..9942a2bc 100644
--- a/bindings/python/notmuch/query.py
+++ b/bindings/python/notmuch/query.py
@@ -164,9 +164,9 @@ class Query(object):
         return Threads(threads_p, self)
 
     """notmuch_query_search_messages_st"""
-    _search_messages_st = nmlib.notmuch_query_search_messages_st
-    _search_messages_st.argtypes = [NotmuchQueryP, POINTER(NotmuchMessagesP)]
-    _search_messages_st.restype = c_uint
+    _search_messages = nmlib.notmuch_query_search_messages
+    _search_messages.argtypes = [NotmuchQueryP, POINTER(NotmuchMessagesP)]
+    _search_messages.restype = c_uint
 
     def search_messages(self):
         """Filter messages according to the query and return
diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c
index 4b3f1c4f..2e36df6a 100644
--- a/bindings/ruby/query.c
+++ b/bindings/ruby/query.c
@@ -159,7 +159,7 @@ notmuch_rb_query_search_messages (VALUE self)
 
     Data_Get_Notmuch_Query (self, query);
 
-    status = notmuch_query_search_messages_st (query, &messages);
+    status = notmuch_query_search_messages (query, &messages);
     if (status)
 	notmuch_rb_status_raise (status);
 
diff --git a/lib/database.cc b/lib/database.cc
index ba440d4d..13b9e647 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1501,7 +1501,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
 
 	query = notmuch_query_create (notmuch, "");
 
-	status = notmuch_query_search_messages_st (query, &messages);
+	status = notmuch_query_search_messages (query, &messages);
 	if (status)
 	    goto DONE;
 	for (;
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 601b2e3e..4b01e3ad 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -911,23 +911,23 @@ notmuch_query_search_threads_st (notmuch_query_t *query, notmuch_threads_t **out
  *
  * If a Xapian exception occurs this function will return NULL.
  *
- * @since libnotmuch 4.2 (notmuch 0.20)
+ * @since libnotmuch 5 (notmuch 0.25)
  */
 notmuch_status_t
-notmuch_query_search_messages_st (notmuch_query_t *query,
-				  notmuch_messages_t **out);
+notmuch_query_search_messages (notmuch_query_t *query,
+			       notmuch_messages_t **out);
 /**
- * Like notmuch_query_search_messages, but without a status return.
- *
- * If a Xapian exception occurs this function will return NULL.
+ * Deprecated alias for notmuch_query_search_messages
  *
- * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please use
- * notmuch_query_search_messages_st instead.
+ * @deprecated Deprecated as of libnotmuch 5 (notmuch 0.25). Please use
+ * notmuch_query_search_messages instead.
  *
  */
-NOTMUCH_DEPRECATED(4,3)
-notmuch_messages_t *
-notmuch_query_search_messages (notmuch_query_t *query);
+
+NOTMUCH_DEPRECATED(5,0)
+notmuch_status_t
+notmuch_query_search_messages_st (notmuch_query_t *query,
+				  notmuch_messages_t **out);
 
 /**
  * Destroy a notmuch_query_t along with any associated resources.
diff --git a/lib/query.cc b/lib/query.cc
index d138f09b..60d1db94 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -171,20 +171,16 @@ _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)
     return exclude_query;
 }
 
-notmuch_messages_t *
-notmuch_query_search_messages (notmuch_query_t *query)
+
+notmuch_status_t
+notmuch_query_search_messages_st (notmuch_query_t *query,
+				  notmuch_messages_t **out)
 {
-    notmuch_status_t status;
-    notmuch_messages_t *messages;
-    status = notmuch_query_search_messages_st (query, &messages);
-    if (status)
-	return NULL;
-    else
-	return messages;
+    return notmuch_query_search_messages (query, out);
 }
 
 notmuch_status_t
-notmuch_query_search_messages_st (notmuch_query_t *query,
+notmuch_query_search_messages (notmuch_query_t *query,
 				  notmuch_messages_t **out)
 {
     return _notmuch_query_search_documents (query, "mail", out);
@@ -454,7 +450,7 @@ notmuch_query_search_threads (notmuch_query_t *query,
 
     threads->query = query;
 
-    status = notmuch_query_search_messages_st (query, &messages);
+    status = notmuch_query_search_messages (query, &messages);
     if (status) {
 	talloc_free (threads);
 	return status;
@@ -640,7 +636,7 @@ notmuch_query_count_threads_st (notmuch_query_t *query, unsigned *count)
 
     sort = query->sort;
     query->sort = NOTMUCH_SORT_UNSORTED;
-    ret = notmuch_query_search_messages_st (query, &messages);
+    ret = notmuch_query_search_messages (query, &messages);
     if (ret)
 	return ret;
     query->sort = sort;
diff --git a/lib/thread.cc b/lib/thread.cc
index 84ee5298..561ca5be 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -505,7 +505,7 @@ _notmuch_thread_create (void *ctx,
      * oldest or newest subject is desired. */
     notmuch_query_set_sort (thread_id_query, NOTMUCH_SORT_OLDEST_FIRST);
 
-    status = notmuch_query_search_messages_st (thread_id_query, &messages);
+    status = notmuch_query_search_messages (thread_id_query, &messages);
     if (status)
 	goto DONE;
 
diff --git a/notmuch-count.c b/notmuch-count.c
index 35a2aa70..d3457bbe 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -43,7 +43,7 @@ count_files (notmuch_query_t *query)
     notmuch_status_t status;
     int count = 0;
 
-    status = notmuch_query_search_messages_st (query, &messages);
+    status = notmuch_query_search_messages (query, &messages);
     if (print_status_query ("notmuch count", query, status))
 	return -1;
 
diff --git a/notmuch-dump.c b/notmuch-dump.c
index e7965cea..0cbcdc16 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -240,7 +240,7 @@ database_dump_file (notmuch_database_t *notmuch, gzFile output,
      */
     notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED);
 
-    status = notmuch_query_search_messages_st (query, &messages);
+    status = notmuch_query_search_messages (query, &messages);
     if (print_status_query ("notmuch dump", query, status))
 	return EXIT_FAILURE;
 
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 8c894974..2a3abfbd 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -645,7 +645,7 @@ static int do_reply(notmuch_config_t *config,
 	    sp = sprinter_sexp_create (config, stdout);
     }
 
-    status = notmuch_query_search_messages_st (query, &messages);
+    status = notmuch_query_search_messages (query, &messages);
     if (print_status_query ("notmuch reply", query, status))
 	return 1;
 
diff --git a/notmuch-search.c b/notmuch-search.c
index c6899ffa..1c4d5205 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -538,7 +538,7 @@ do_search_messages (search_context_t *ctx)
 	    ctx->offset = 0;
     }
 
-    status = notmuch_query_search_messages_st (ctx->query, &messages);
+    status = notmuch_query_search_messages (ctx->query, &messages);
     if (print_status_query ("notmuch search", ctx->query, status))
 	return 1;
 
@@ -629,7 +629,7 @@ do_search_tags (const search_context_t *ctx)
 	tags = notmuch_database_get_all_tags (notmuch);
     } else {
 	notmuch_status_t status;
-	status = notmuch_query_search_messages_st (query, &messages);
+	status = notmuch_query_search_messages (query, &messages);
 	if (print_status_query ("notmuch search", query, status))
 	    return 1;
 
diff --git a/notmuch-show.c b/notmuch-show.c
index 3e87bfec..11eb0a6b 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -921,7 +921,7 @@ do_show_single (void *ctx,
 	return 1;
     }
 
-    status = notmuch_query_search_messages_st (query, &messages);
+    status = notmuch_query_search_messages (query, &messages);
     if (print_status_query ("notmuch show", query, status))
 	return 1;
 
diff --git a/notmuch-tag.c b/notmuch-tag.c
index 18d78ddd..9c03754d 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -121,7 +121,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
     /* tagging is not interested in any special sort order */
     notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED);
 
-    status = notmuch_query_search_messages_st (query, &messages);
+    status = notmuch_query_search_messages (query, &messages);
     if (print_status_query ("notmuch tag", query, status))
 	return status;
 
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index 087c6bd7..ccb77b04 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -285,7 +285,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
    {
        notmuch_messages_t *messages = NULL;
        notmuch_query_t *query=notmuch_query_create (db, "*");
-       stat = notmuch_query_search_messages_st (query, &messages);
+       stat = notmuch_query_search_messages (query, &messages);
    }
 EOF
 sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' < OUTPUT > OUTPUT.clean
diff --git a/test/T640-database-modified.sh b/test/T640-database-modified.sh
index 92758e19..e35e35f6 100755
--- a/test/T640-database-modified.sh
+++ b/test/T640-database-modified.sh
@@ -35,7 +35,7 @@ main (int argc, char **argv)
 
     EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &rw_db));
     query = notmuch_query_create(rw_db, "");
-    EXPECT0 (notmuch_query_search_messages_st (query, &messages));
+    EXPECT0 (notmuch_query_search_messages (query, &messages));
 
     for (;
 	 notmuch_messages_valid (messages);
-- 
2.11.0



More information about the notmuch mailing list