From: David Bremner Date: Sun, 19 Mar 2017 00:02:42 +0000 (-0300) Subject: Merge branch 'release' X-Git-Tag: 0.25_rc0~100 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=a8a270522231b186493ecd97d56a1343382d51d8;hp=06adc276682d1d5f73d78df2e898ad4191eb4499 Merge branch 'release' Merge in memory fixes --- diff --git a/Makefile b/Makefile index 0ef57fa9..d2010fe4 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,35 @@ include Makefile.config global_deps = Makefile Makefile.config Makefile.local \ $(subdirs:%=%/Makefile) $(subdirs:%=%/Makefile.local) +INCLUDE_MORE := yes +ifneq ($(filter clean distclean dataclean, $(word 1, $(MAKECMDGOALS))),) +CLEAN_GOAL := $(word 1, $(MAKECMDGOALS)) + +# If there are more goals following CLEAN_GOAL, run $(MAKE)s in parts. +ifneq ($(word 2, $(MAKECMDGOALS)),) +INCLUDE_MORE := no +FOLLOWING_GOALS := $(wordlist 2, 99, $(MAKECMDGOALS)) + +.PHONY: $(FOLLOWING_GOALS) make_in_parts +$(FOLLOWING_GOALS): + @true +$(CLEAN_GOAL): make_in_parts +make_in_parts: + $(MAKE) $(CLEAN_GOAL) + $(MAKE) $(FOLLOWING_GOALS) configure_options="$(configure_options)" +endif + +else +CLEAN_GOAL := +endif + +# Potentially speedup make clean, distclean and dataclean ; avoid +# re-creating Makefile.config if it exists but configure is newer. +ifneq ($(CLEAN_GOAL),) +Makefile.config: | $(srcdir)/configure +else Makefile.config: $(srcdir)/configure +endif ifeq ($(configure_options),) @echo "" @echo "Note: Calling ./configure with no command-line arguments. This is often fine," @@ -33,9 +61,11 @@ ifeq ($(configure_options),) endif $(srcdir)/configure $(configure_options) +ifeq ($(INCLUDE_MORE),yes) # runtime variable definitions available in all subdirs include $(srcdir)/Makefile.global # Finally, include all of the Makefile.local fragments where all the # real work is done. include $(subdirs:%=%/Makefile.local) Makefile.local +endif diff --git a/bindings/Makefile.local b/bindings/Makefile.local index 11d11d4b..17b561ca 100644 --- a/bindings/Makefile.local +++ b/bindings/Makefile.local @@ -8,6 +8,7 @@ ifeq ($(HAVE_RUBY_DEV),1) cd $(dir)/ruby && \ EXTRA_LDFLAGS="$(NO_UNDEFINED_LDFLAGS)" \ LIBNOTMUCH="../../lib/$(LINKER_NAME)" \ + NOTMUCH_SRCDIR='$(NOTMUCH_SRCDIR)' \ ruby extconf.rb --vendor $(MAKE) -C $(dir)/ruby endif diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py index 67fb1c41..8f918069 100644 --- a/bindings/python/notmuch/database.py +++ b/bindings/python/notmuch/database.py @@ -86,6 +86,11 @@ class Database(object): _get_version.argtypes = [NotmuchDatabaseP] _get_version.restype = c_uint + """notmuch_database_get_revision""" + _get_revision = nmlib.notmuch_database_get_revision + _get_revision.argtypes = [NotmuchDatabaseP, POINTER(c_char_p)] + _get_revision.restype = c_uint + """notmuch_database_open""" _open = nmlib.notmuch_database_open _open.argtypes = [c_char_p, c_uint, POINTER(NotmuchDatabaseP)] @@ -261,6 +266,17 @@ class Database(object): self._assert_db_is_initialized() return Database._get_version(self._db) + def get_revision (self): + """Returns the committed database revison and UUID + + :returns: (revison, uuid) The database revision as a positive integer + and the UUID of the database. + """ + self._assert_db_is_initialized() + uuid = c_char_p () + revision = Database._get_revision(self._db, byref (uuid)) + return (revision, uuid.value.decode ('utf-8')) + _needs_upgrade = nmlib.notmuch_database_needs_upgrade _needs_upgrade.argtypes = [NotmuchDatabaseP] _needs_upgrade.restype = bool diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb index ddaa6841..161de5a2 100644 --- a/bindings/ruby/extconf.rb +++ b/bindings/ruby/extconf.rb @@ -5,7 +5,7 @@ require 'mkmf' -dir = File.join('..', '..', 'lib') +dir = File.join(ENV['NOTMUCH_SRCDIR'], 'lib') # includes $INCFLAGS = "-I#{dir} #{$INCFLAGS}" diff --git a/configure b/configure index fa77eb8f..6c782e16 100755 --- a/configure +++ b/configure @@ -19,7 +19,12 @@ To work around this problem you may try to execute: # Store original IFS value so it can be changed (and restored) in many places. readonly DEFAULT_IFS="$IFS" +# The top-level directory for the source. This ./configure and all Makefiles +# are good with ${srcdir} usually being relative. Some components (e.g. tests) +# are executed in subdirectories and for those it is simpler to use +# ${NOTMUCH_SRCDIR} which holds absolute path to the source. srcdir=$(dirname "$0") +NOTMUCH_SRCDIR=$(cd "$srcdir" && pwd) subdirs="util compat lib parse-time-string completion doc emacs" subdirs="${subdirs} performance-test test test/test-databases" @@ -42,6 +47,12 @@ if [ "$srcdir" != "." ]; then # Emacs only likes to generate compiled files next to the .el files # by default so copy these as well (which is not ideal). cp -a "$srcdir"/emacs/*.el emacs + + # We were not able to create fully working Makefile using ruby mkmf.rb + # so ruby bindings source files are copied as well (ditto -- not ideal). + mkdir bindings/ruby + cp -a "$srcdir"/bindings/ruby/*.[ch] bindings/ruby + cp -a "$srcdir"/bindings/ruby/extconf.rb bindings/ruby fi # Set several defaults (optionally specified by the user in @@ -352,8 +363,8 @@ int main(void) { return 0; } EOF -if ${CC} ${CFLAGS} _libversion.c -o _libversion > /dev/null 2>&1 && \ - ./_libversion > _libversion.sh && . ./_libversion.sh +if ${CC} ${CFLAGS} -I"$srcdir" _libversion.c -o _libversion > /dev/null 2>&1 \ + && ./_libversion > _libversion.sh && . ./_libversion.sh then printf "OK.\n" else @@ -493,8 +504,7 @@ else fi if ! pkg-config --exists zlib; then - ${CC} ${zlib_cflags} -o compat/gen_zlib_pc \ - "$srcdir"/compat/gen_zlib_pc.c ${zlib_ldflags} > /dev/null 2>&1 && + ${CC} -o compat/gen_zlib_pc "$srcdir"/compat/gen_zlib_pc.c >/dev/null 2>&1 && compat/gen_zlib_pc > compat/zlib.pc && PKG_CONFIG_PATH="$PKG_CONFIG_PATH":compat && export PKG_CONFIG_PATH @@ -914,6 +924,7 @@ cat > Makefile.config < sh.config <doc.add_value (NOTMUCH_VALUE_TIMESTAMP, Xapian::sortable_serialise (time_value)); diff --git a/mime-node.c b/mime-node.c index c9b82330..f719422e 100644 --- a/mime-node.c +++ b/mime-node.c @@ -322,20 +322,21 @@ mime_node_child (mime_node_t *parent, int child) static mime_node_t * _mime_node_seek_dfs_walk (mime_node_t *node, int *n) { - mime_node_t *ret = NULL; int i; if (*n == 0) return node; *n -= 1; - for (i = 0; i < node->nchildren && !ret; i++) { + for (i = 0; i < node->nchildren; i++) { mime_node_t *child = mime_node_child (node, i); - ret = _mime_node_seek_dfs_walk (child, n); - if (!ret) - talloc_free (child); + mime_node_t *ret = _mime_node_seek_dfs_walk (child, n); + if (ret) + return ret; + + talloc_free (child); } - return ret; + return NULL; } mime_node_t * diff --git a/notmuch-client.h b/notmuch-client.h index 10991224..7a674873 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -83,7 +83,6 @@ typedef struct notmuch_show_params { notmuch_bool_t entire_thread; notmuch_bool_t omit_excluded; notmuch_bool_t output_body; - notmuch_bool_t raw; int part; notmuch_crypto_t crypto; notmuch_bool_t include_html; diff --git a/notmuch-new.c b/notmuch-new.c index 13212639..e2822e23 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -905,10 +905,9 @@ print_results (const add_files_state_t *state) state->processed_files == 1 ? "file" : "total files"); notmuch_time_print_formatted_seconds (elapsed); if (elapsed > 1) - printf (" (%d files/sec.).\033[K\n", + printf (" (%d files/sec.)", (int) (state->processed_files / elapsed)); - else - printf (".\033[K\n"); + printf (".%s\n", (state->output_is_a_tty) ? "\033[K" : ""); } if (state->added_messages) diff --git a/notmuch-reply.c b/notmuch-reply.c index 8c894974..166a5946 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -701,11 +701,6 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) int opt_index; notmuch_show_params_t params = { .part = -1, - .crypto = { - .verify = FALSE, - .decrypt = FALSE, - .gpgpath = NULL - } }; int format = FORMAT_DEFAULT; int reply_all = TRUE; diff --git a/notmuch-show.c b/notmuch-show.c index 1954096d..7451d5ab 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -22,48 +22,6 @@ #include "gmime-filter-reply.h" #include "sprinter.h" -static notmuch_status_t -format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, - int indent, const notmuch_show_params_t *params); - -static const notmuch_show_format_t format_text = { - .new_sprinter = sprinter_text_create, - .part = format_part_text, -}; - -static notmuch_status_t -format_part_sprinter_entry (const void *ctx, sprinter_t *sp, mime_node_t *node, - int indent, const notmuch_show_params_t *params); - -static const notmuch_show_format_t format_json = { - .new_sprinter = sprinter_json_create, - .part = format_part_sprinter_entry, -}; - -static const notmuch_show_format_t format_sexp = { - .new_sprinter = sprinter_sexp_create, - .part = format_part_sprinter_entry, -}; - -static notmuch_status_t -format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node, - int indent, const notmuch_show_params_t *params); - -static const notmuch_show_format_t format_mbox = { - .new_sprinter = sprinter_text_create, - .part = format_part_mbox, -}; - -static notmuch_status_t -format_part_raw (unused (const void *ctx), sprinter_t *sp, mime_node_t *node, - unused (int indent), - unused (const notmuch_show_params_t *params)); - -static const notmuch_show_format_t format_raw = { - .new_sprinter = sprinter_text_create, - .part = format_part_raw, -}; - static const char * _get_tags_as_string (const void *ctx, notmuch_message_t *message) { @@ -1029,10 +987,43 @@ enum { NOTMUCH_FORMAT_RAW }; +static const notmuch_show_format_t format_json = { + .new_sprinter = sprinter_json_create, + .part = format_part_sprinter_entry, +}; + +static const notmuch_show_format_t format_sexp = { + .new_sprinter = sprinter_sexp_create, + .part = format_part_sprinter_entry, +}; + +static const notmuch_show_format_t format_text = { + .new_sprinter = sprinter_text_create, + .part = format_part_text, +}; + +static const notmuch_show_format_t format_mbox = { + .new_sprinter = sprinter_text_create, + .part = format_part_mbox, +}; + +static const notmuch_show_format_t format_raw = { + .new_sprinter = sprinter_text_create, + .part = format_part_raw, +}; + +static const notmuch_show_format_t *formatters[] = { + [NOTMUCH_FORMAT_JSON] = &format_json, + [NOTMUCH_FORMAT_SEXP] = &format_sexp, + [NOTMUCH_FORMAT_TEXT] = &format_text, + [NOTMUCH_FORMAT_MBOX] = &format_mbox, + [NOTMUCH_FORMAT_RAW] = &format_raw, +}; + enum { - ENTIRE_THREAD_DEFAULT, - ENTIRE_THREAD_TRUE, - ENTIRE_THREAD_FALSE, + ENTIRE_THREAD_DEFAULT = -1, + ENTIRE_THREAD_FALSE = FALSE, + ENTIRE_THREAD_TRUE = TRUE, }; /* The following is to allow future options to be added more easily */ @@ -1048,25 +1039,20 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_query_t *query; char *query_string; int opt_index, ret; - const notmuch_show_format_t *format = &format_text; + const notmuch_show_format_t *formatter; sprinter_t *sprinter; notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE, .output_body = TRUE, - .crypto = { - .verify = FALSE, - .decrypt = FALSE, - .gpgpath = NULL - }, - .include_html = FALSE }; - int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED; + int format = NOTMUCH_FORMAT_NOT_SPECIFIED; int exclude = EXCLUDE_TRUE; int entire_thread = ENTIRE_THREAD_DEFAULT; + notmuch_bool_t single_message; notmuch_opt_desc_t options[] = { - { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f', + { NOTMUCH_OPT_KEYWORD, &format, "format", 'f', (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON }, { "text", NOTMUCH_FORMAT_TEXT }, { "sexp", NOTMUCH_FORMAT_SEXP }, @@ -1102,40 +1088,25 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) if (params.crypto.decrypt) params.crypto.verify = TRUE; - if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) { + /* specifying a part implies single message display */ + single_message = params.part >= 0; + + if (format == NOTMUCH_FORMAT_NOT_SPECIFIED) { /* if part was requested and format was not specified, use format=raw */ if (params.part >= 0) - format_sel = NOTMUCH_FORMAT_RAW; + format = NOTMUCH_FORMAT_RAW; else - format_sel = NOTMUCH_FORMAT_TEXT; + format = NOTMUCH_FORMAT_TEXT; } - switch (format_sel) { - case NOTMUCH_FORMAT_JSON: - format = &format_json; - break; - case NOTMUCH_FORMAT_TEXT: - format = &format_text; - break; - case NOTMUCH_FORMAT_SEXP: - format = &format_sexp; - break; - case NOTMUCH_FORMAT_MBOX: + if (format == NOTMUCH_FORMAT_MBOX) { if (params.part > 0) { fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n"); return EXIT_FAILURE; } - - format = &format_mbox; - break; - case NOTMUCH_FORMAT_RAW: - format = &format_raw; - /* If --format=raw specified without specifying part, we can only - * output single message, so set part=0 */ - if (params.part < 0) - params.part = 0; - params.raw = TRUE; - break; + } else if (format == NOTMUCH_FORMAT_RAW) { + /* raw format only supports single message display */ + single_message = TRUE; } notmuch_exit_if_unsupported_format (); @@ -1143,10 +1114,12 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) /* Default is entire-thread = FALSE except for format=json and * format=sexp. */ if (entire_thread == ENTIRE_THREAD_DEFAULT) { - if (format == &format_json || format == &format_sexp) - entire_thread = ENTIRE_THREAD_TRUE; + if (format == NOTMUCH_FORMAT_JSON || format == NOTMUCH_FORMAT_SEXP) + params.entire_thread = TRUE; else - entire_thread = ENTIRE_THREAD_FALSE; + params.entire_thread = FALSE; + } else { + params.entire_thread = entire_thread; } if (!params.output_body) { @@ -1154,22 +1127,17 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n"); params.output_body = TRUE; } else { - if (format != &format_json && format != &format_sexp) + if (format != NOTMUCH_FORMAT_JSON && format != NOTMUCH_FORMAT_SEXP) fprintf (stderr, "Warning: --body=false only implemented for format=json and format=sexp\n"); } } if (params.include_html && - (format_sel != NOTMUCH_FORMAT_JSON && format_sel != NOTMUCH_FORMAT_SEXP)) { + (format != NOTMUCH_FORMAT_JSON && format != NOTMUCH_FORMAT_SEXP)) { fprintf (stderr, "Warning: --include-html only implemented for format=json and format=sexp\n"); } - if (entire_thread == ENTIRE_THREAD_TRUE) - params.entire_thread = TRUE; - else - params.entire_thread = FALSE; - query_string = query_string_from_args (config, argc-opt_index, argv+opt_index); if (query_string == NULL) { fprintf (stderr, "Out of memory\n"); @@ -1196,12 +1164,13 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) } /* Create structure printer. */ - sprinter = format->new_sprinter(config, stdout); + formatter = formatters[format]; + sprinter = formatter->new_sprinter(config, stdout); /* If a single message is requested we do not use search_excludes. */ - if (params.part >= 0) - ret = do_show_single (config, query, format, sprinter, ¶ms); - else { + if (single_message) { + ret = do_show_single (config, query, formatter, sprinter, ¶ms); + } else { /* We always apply set the exclude flag. The * exclude=true|false option controls whether or not we return * threads that only match in an excluded message */ @@ -1219,7 +1188,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) params.omit_excluded = FALSE; } - ret = do_show (config, query, format, sprinter, ¶ms); + ret = do_show (config, query, formatter, sprinter, ¶ms); } notmuch_crypto_cleanup (¶ms.crypto); diff --git a/performance-test/M02-show.sh b/performance-test/M02-show.sh new file mode 100755 index 00000000..d73035ea --- /dev/null +++ b/performance-test/M02-show.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +test_description='show' + +. ./perf-test-lib.sh || exit 1 + +memory_start + +memory_run 'show *' "notmuch show '*' 1>/dev/null" +memory_run 'show --format=json *' "notmuch show --format=json '*' 1>/dev/null" +memory_run 'show --format=sexp *' "notmuch show --format=sexp '*' 1>/dev/null" + +memory_done diff --git a/performance-test/M03-search.sh b/performance-test/M03-search.sh new file mode 100755 index 00000000..8d026eee --- /dev/null +++ b/performance-test/M03-search.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +test_description='search' + +. ./perf-test-lib.sh || exit 1 + +memory_start + +memory_run 'search *' "notmuch search '*' 1>/dev/null" +memory_run 'search --format=json *' "notmuch search --format=json '*' 1>/dev/null" +memory_run 'search --format=sexp *' "notmuch search --format=sexp '*' 1>/dev/null" + +memory_done diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh index 00d2f1c6..c89d5aab 100644 --- a/performance-test/perf-test-lib.sh +++ b/performance-test/perf-test-lib.sh @@ -149,7 +149,7 @@ memory_run () printf "[ %d ]\t%s\n" $test_count "$1" - NOTMUCH_TALLOC_REPORT="$talloc_log" valgrind --leak-check=full --log-file="$log_file" $2 + NOTMUCH_TALLOC_REPORT="$talloc_log" eval "valgrind --leak-check=full --log-file='$log_file' $2" awk '/LEAK SUMMARY/,/suppressed/ { sub(/^==[0-9]*==/," "); print }' "$log_file" echo diff --git a/test/Makefile.local b/test/Makefile.local index f8cf90d0..46805972 100644 --- a/test/Makefile.local +++ b/test/Makefile.local @@ -61,7 +61,7 @@ test-binaries: $(TEST_BINARIES) test: all test-binaries ifeq ($V,) - @echo 'Use "$(MAKE) V=1" to print test headings and PASSing results.' + @echo 'Use "$(MAKE) V=1" to see the details for passing and known broken tests.' @env NOTMUCH_TEST_QUIET=1 ${test_src_dir}/notmuch-test $(OPTIONS) else # The user has explicitly enabled quiet execution. diff --git a/test/README b/test/README index 104a120e..dcd05237 100644 --- a/test/README +++ b/test/README @@ -189,16 +189,21 @@ Test harness library There are a handful helper functions defined in the test harness library for your script to use. - test_expect_success