This conversion is trivial because the only configuration information accessed by dump is that stored in the database (in order to dump it). We do need to be careful to keep the write lock on the database to ensure dump consistency. --- notmuch-dump.c | 7 +------ notmuch.c | 2 +- test/T240-dump-restore.sh | 30 +++++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/notmuch-dump.c b/notmuch-dump.c index eb629dc9..d7017929 100644 --- a/notmuch-dump.c +++ b/notmuch-dump.c @@ -361,16 +361,11 @@ notmuch_database_dump (notmuch_database_t *notmuch, } int -notmuch_dump_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[]) +notmuch_dump_command (unused(notmuch_config_t *config), notmuch_database_t *notmuch , int argc, char *argv[]) { - notmuch_database_t *notmuch; const char *query_str = NULL; int ret; - if (notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) - return EXIT_FAILURE; - notmuch_exit_if_unmatched_db_uuid (notmuch); const char *output_file_name = NULL; diff --git a/notmuch.c b/notmuch.c index 40527893..b10cc702 100644 --- a/notmuch.c +++ b/notmuch.c @@ -159,7 +159,7 @@ static command_t commands[] = { "Construct a reply template for a set of messages." }, { "tag", notmuch_tag_command, NOTMUCH_COMMAND_CONFIG_OPEN, "Add/remove tags for all messages matching the search terms." }, - { "dump", notmuch_dump_command, NOTMUCH_COMMAND_CONFIG_OPEN, + { "dump", notmuch_dump_command, NOTMUCH_COMMAND_DATABASE_EARLY | NOTMUCH_COMMAND_DATABASE_WRITE, "Create a plain-text dump of the tags for each message." }, { "restore", notmuch_restore_command, NOTMUCH_COMMAND_CONFIG_OPEN, "Restore the tags from the given dump file (see 'dump')." }, diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh index 0870ff92..b3782745 100755 --- a/test/T240-dump-restore.sh +++ b/test/T240-dump-restore.sh @@ -82,6 +82,33 @@ test_begin_subtest "dump --output=outfile --" notmuch dump --output=dump-1-arg-dash.actual -- test_expect_equal_file dump.expected dump-1-arg-dash.actual +# configuration + +test_begin_subtest "dump with saved query from config file" +query_name="test${RANDOM}" +printf "Before:\n" > OUTPUT +notmuch dump --include=tags query:$query_name >> OUTPUT +printf "\nAfter:\n" >> OUTPUT +cp notmuch-config old-config +printf "\n[query]\n${query_name} = tag:signed\n" >> notmuch-config +notmuch dump --include=tags query:$query_name >> OUTPUT +cat <<EOF > EXPECTED +Before: +#notmuch-dump batch-tag:3 tags + +After: +#notmuch-dump batch-tag:3 tags ++inbox +signed +unread -- id:20091118002059.067214ed@hikari ++attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu ++attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu ++inbox +signed +unread -- id:20091118005040.GA25380@dottiness.seas.harvard.edu ++inbox +signed +unread -- id:87iqd9rn3l.fsf@vertex.dottedmag ++inbox +signed +unread -- id:20091117203301.GV3165@dottiness.seas.harvard.edu ++inbox +signed +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu +EOF +cp old-config notmuch-config +test_expect_equal_file EXPECTED OUTPUT + # gzipped output test_begin_subtest "dump --gzip" @@ -322,6 +349,7 @@ EOF test_expect_equal_file EXPECTED OUTPUT +backup_database test_begin_subtest 'roundtripping random message-ids and tags' ${TEST_DIRECTORY}/random-corpus --config-path=${NOTMUCH_CONFIG} \ @@ -338,7 +366,7 @@ test_begin_subtest 'roundtripping random message-ids and tags' sort > OUTPUT.$test_count test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count +restore_database test_done -# Note the database is "poisoned" for sup format at this point. -- 2.29.2 _______________________________________________ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-leave@notmuchmail.org