aboutsummaryrefslogtreecommitdiff
path: root/notmuch-dump.c
AgeCommit message (Collapse)Author
2021-09-04CLI/{count, dump, reindex, reply, show}: enable sexp queriesDavid Bremner
The change in each case is to call notmuch_query_create_with_syntax, relying on the already inherited shared options. As a bonus we get improved error handling from the new query creation API. The remaining subcommand is 'tag', which is a bit trickier.
2021-09-04CLI: make variable n_requested_db_uuid file scope.David Bremner
It turns out that now that we pass an open database into the subcommands, it is easy to check any requested uuid against the database at the same time as we process the other shared arguments. This results in overall less boilerplate code, as well as making a CLI scope function and variable file scope in notmuch.c.
2021-04-06CLI: drop notmuch_config_t from subcommand interface.David Bremner
At this point it is unused in all subcommands.
2021-03-13cli: run uncrustifyuncrustify
This is the result of running $ uncrustify --replace --config devel/uncrustify.cfg *.c *.h in the top level source directory Line breaks were then adjusted manually to keep argc and argv together.
2021-02-06cli/dump: convert to new config frameworkDavid Bremner
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.
2021-02-06CLI: add (unused) database argument to subcommands.David Bremner
This will allow transitioning individual subcommands to the new configuration framework. Eventually when they are all converted we can remove the notmuch_config_t * argument. For now, live with the parameter shadowing in some some subcommands; it will go away when they are converted.
2020-04-13cli/dump: replace use of gzprintf with gzputs for config valuesDavid Bremner
These can be large, and hit buffer limitations of gzprintf.
2020-04-13cli/dump: define GZPUTS and use it in notmuch-dumpDavid Bremner
Similarly to GZPRINTF, this is a drop in replacement that can be improved where needd.
2020-04-13cli/dump: define GZPRINTF macro and use it in place of gzprintfDavid Bremner
This will at least catch errors, and can be replaced with more sophisticated error handling where appropriate.
2020-04-13don't pass NULL as second parameter to gzerrorDavid Bremner
Although (as of 1.2.11) zlib checks this parameter before writing to it, the docs don't promise to keep doing so, so be safe.
2019-07-23notmuch-dump.c: Fix output file being closed twiceRalph Seichter
Fixed: If the output file for a dump was non-writeable, gzclose_w() was called twice on the output file handle, resulting in SIGABRT.
2019-06-14cli: run uncrustifyuncrustify
This is the result of running $ uncrustify --replace --config devel/uncrustify.cfg *.c *.h in the top level source directory
2017-10-09cli: convert notmuch_bool_t to stdboolJani Nikula
C99 stdbool turned 18 this year. There really is no reason to use our own, except in the library interface for backward compatibility. Convert the cli and test binaries to stdbool.
2017-10-04cli: use designated initializers for opt descJani Nikula
Several changes at once, just to not have to change the same lines several times over: - Use designated initializers to initialize opt desc arrays. - Only initialize the needed fields. - Remove arg_id (short options) as unused. - Replace opt_type and output_var with several type safe output variables, where the output variable being non-NULL determines the type. Introduce checks to ensure only one is set. The downside is some waste of const space per argument; this could be saved by retaining opt_type and using a union, but that's still pretty verbose. - Fix some variables due to the type safety. Mostly a good thing, but leads to some enums being changed to ints. This is pedantically correct, but somewhat annoying. We could also cast, but that defeats the purpose a bit. - Terminate the opt desc arrays using {}. The output variable type safety and the ability to add new fields for just some output types or arguments are the big wins. For example, if we wanted to add a variable to set when the argument is present, we could do so for just the arguments that need it. Beauty is in the eye of the beholder, but I think this looks nice when defining the arguments, and reduces some of the verbosity we have there.
2017-06-01Merge branch 'release'David Bremner
2017-06-01cli/dump: don't include tags when not asked forDavid Bremner
Add in the analogous test for tags that is given for properties a few lines below.
2017-04-01Merge branch 'release'David Bremner
Final 0.24.1 release
2017-04-01cli/dump: fix bug in dump headerDavid Bremner
Fix copy paste error.
2017-03-22lib: replace deprecated n_q_search_messages with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We re-use the name for a status returning version, and deprecate the _st name.
2016-09-21CLI: add properties to dump outputDavid Bremner
Part of providing extensibility via properties is to make sure that user data is not lost. Thus we need to be able to dump and restore properties.
2016-09-21CLI: refactor dumping of tags.David Bremner
This is mainly code movement, to make room in the loop over messages for dumping properties.
2016-06-05Use https instead of http where possibleDaniel Kahn Gillmor
Many of the external links found in the notmuch source can be resolved using https instead of http. This changeset addresses as many as i could find, without touching the e-mail corpus or expected outputs found in tests.
2016-05-25CLI: add optional config data to dump output.David Bremner
Note that it changes the default dump output format, but doesn't break existing notmuch-restore. It might break user scripts though.
2015-09-23cli: convert remainder of CLI to n_q_search_{messages,threads}_stDavid Bremner
I think it would be no real problem to cut and paste the gdb based error message test from count to the other clients modified here, but I'm not currently convinced it's worth the trouble since the code path being tested is almost the the same, and the tests are relatively heavyweight.
2015-08-14cli: add global option "--uuid"David Bremner
The function notmuch_exit_if_unmatched_db_uuid is split from notmuch_process_shared_options because it needs an open notmuch database. There are two exceptional cases in uuid handling. 1) notmuch config and notmuch setup don't currently open the database, so it doesn't make sense to check the UUID. 2) notmuch compact opens the database inside the library, so we either need to open the database just to check uuid, or change the API.
2015-06-01cli: define shared options, use for --help and --versionDavid Bremner
Unfortunately it seems trickier to support --config globally The non-trivial changes are in notmuch.c; most of the other changes consists of blindly inserting two lines into every subcommand.
2014-07-16dump: make dump take Xapian write lockMark Walters
Dump currently only takes the read lock. Xapian can cope with some changes while maintaining a read snapshot but with more changes it fails. Currently notmuch just gives a xapian error. To avoid this we take the write lock when dumping. This prevents other notmuch processes from modifying the xapian database preventing this error. Discussion with Olly on irc indicates that this is currently the best solution: in xapian trunk there may be better possibilities using snapshots but they need to make it to a release and propogate out to users before we can switch approach. Finally, this breaks one use case: pipelines of the form notmuch dump | ... | notmuch restore According to Olly this is already very fragile: it will only work on small databases. One of the tests relies on this behaviour so fix that to store the dump rather than use a pipe.
2014-05-18notmuch-dump: use fsync instead of fdatasyncDavid Bremner
Since the file size will have changed, there is no performance benefit to calling fdatasync. Somewhat surprisingly, using fdatasync apparently causes portability problems on FreeBSD.
2014-04-12dump: support gzipped and atomic outputDavid Bremner
The main goal is to support gzipped output for future internal calls (e.g. from notmuch-new) to notmuch_database_dump. The additional dependency is not very heavy since xapian already pulls in zlib. We want the dump to be "atomic", in the sense that after running the dump file is either present and complete, or not present. This avoids certain classes of mishaps involving overwriting a good backup with a bad or partial one.
2014-03-30cli: abstract dump file open from the dump commandJani Nikula
Also expose the dump function to the rest of notmuch. No functional changes, except for slight improvement in error handling.
2014-03-30cli: abstract database dumping from the dump commandJani Nikula
No functional changes, except for slight improvement in error handling.
2014-01-24notmuch dump: default to batch-tag format.David Bremner
Although we didn't formally deprecate the old format, the new one has been available for a year.
2014-01-18cli: clean up exit status code returned by the cli commandsJani Nikula
Apart from the status codes for format mismatches, the non-zero exit status codes have been arbitrary. Make the cli consistently return either EXIT_SUCCESS or EXIT_FAILURE.
2013-03-08cli: move config open/close to main() from subcommandsJani Nikula
This allows specifying config file as a top level argument to notmuch, and generally makes it possible to override config file options in main(), without having to touch the subcommands. If the config file does not exist, one will be created for the notmuch main command and setup and help subcommands. Help is special in this regard; the config is created just to avoid errors about missing config, but it will not be saved. This also makes notmuch config the talloc context for subcommands.
2013-03-07cli: config: make notmuch_config_open() "is new" parameter input onlyJani Nikula
We now have a notmuch_config_is_new() function to query whether a config was created or not. Change the notmuch_config_open() is_new parameter into boolean create_new to determine whether the function should create a new config if one doesn't exist. This reduces the complexity of the API.
2013-01-06dump/restore: Use Xapian queries for batch-tag formatAustin Clements
This switches the new batch-tag format away from using a home-grown hex-encoding scheme for message IDs in the dump to simply using Xapian queries with Xapian quoting syntax. This has a variety of advantages beyond presenting a cleaner and more consistent interface. Foremost is that it will dramatically simplify the quoting for batch tagging, which shares the same input format. While the hex-encoding is no better or worse for the simple ID queries used by dump/restore, it becomes onerous for general-purpose queries used in batch tagging. It also better handles strange cases like "id:foo and bar", since this is no longer syntactically valid.
2013-01-06dump: Disallow \n in message IDsAustin Clements
When we switch to using regular Xapian queries in the dump format, \n will cause problems, so we disallow it. Specially, while Xapian can quote and parse queries containing \n without difficultly, quoted queries containing \n still span multiple lines, which breaks the line-orientedness of the dump format. Strictly speaking, we could still round-trip these, but it would significantly complicate restore as well as scripts that deal with tag dumps. This complexity would come at absolutely no benefit: because of the RFC 2822 unfolding rules, no amount of standards negligence can produce a message with a message ID containing a line break (not even Outlook can do it!). Hence, we simply disallow it.
2012-12-08notmuch-dump: add --format=(batch-tag|sup)David Bremner
sup is the old format, and remains the default, at least until restore is converted to parse this format. Each line of the batch-tag format is modelled on the syntax of notmuch tag: - "notmuch tag" is omitted from the front of the line - The dump format only uses query strings of a single message-id. - Each space seperated tag/message-id is 'hex-encoded' to remove trouble-making characters. - It is permitted (and will be useful) for there to be no tags before the query. In particular this format won't have the same problem with e.g. spaces in message-ids or tags; they will be round-trip-able.
2012-11-16notmuch-dump: tidy formattingDavid Bremner
More uncrustify at work.
2012-08-06notmuch-dump: remove deprecated positional argument for output fileDavid Bremner
The syntax --output=filename is a smaller change than deleting the output argument completely, and conceivably useful e.g. when running notmuch under a debugger.
2012-05-05lib/cli: Make notmuch_database_open return a status codeAustin Clements
It has been a long-standing issue that notmuch_database_open doesn't return any indication of why it failed. This patch changes its prototype to return a notmuch_status_t and set an out-argument to the database itself, like other functions that return both a status and an object. In the interest of atomicity, this also updates every use in the CLI so that notmuch still compiles. Since this patch does not update the bindings, the Python bindings test fails.
2012-04-28Use notmuch_database_destroy instead of notmuch_database_closeJustus Winter
Adapt the notmuch binaries source to the notmuch_database_close split. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-12-08notmuch-dump: convert to command-line-argumentsDavid Bremner
The output file is handled via positional arguments. There are currently no "normal" options.
2011-12-04notmuch-dump.c: whitespace cleanupDavid Bremner
2011-11-28dump: Don't sort the output by message id.Thomas Schwinge
Asking xapian to sort the messages for us causes suboptimal IO patterns. This would be useful, if we only wanted the first few results, but since we want everything anyway, this is pessimization. On 2011-10-29, a measurement on a 372981 messages instance showed that wall time can be reduced from 28 minutes (sorted by Message-ID) to 15 minutes (unsorted). Timings on 189605 messages: $ time notmuch.old dump 19.48user 5.83system 12:10.42elapsed 3%CPU (0avgtext+0avgdata 110656maxresident)k 3629584inputs+22720outputs (33major+7073minor)pagefaults 0swaps $ echo 3 > /proc/sys/vm/drop_caches $ time notmuch.new 14.89user 1.20system 3:23.58elapsed 7%CPU (0avgtext+0avgdata 46032maxresident)k 1256264inputs+22464outputs (43major+1990minor)pagefaults 0swaps
2011-10-22cli: change argument parsing convention for subcommandsDavid Bremner
previously we deleted the subcommand name from argv before passing to the subcommand. In this version, the deletion is done in the actual subcommands. Although this causes some duplication of code, it allows us to be more flexible about how we parse command line arguments in the subcommand, including possibly using off-the-shelf routines like getopt_long that expect the name of the command in argv[0].
2011-10-16notmuch-dump: deprecate use of output file argument.David Bremner
We print an intentionally non-specific message on stderr, since it isn't clear if there will be some global output file argument to replace. We update the test suite atomically, since it relies on having the same text in two files.
2011-10-16notmuch-dump: treat any remaining arguments after the filename as search termsDavid Bremner
The main motivation here is allow the fast dumping of tag data for messages having certain tags. In practice it seems too slow to pipe dump to grep. All dump-restore tests should be working now, so we update test/dump-restore accordingly
2011-10-16notmuch-dump: update handling of file name argumentDavid Bremner
We permit -- as an "option processing terminator". Currently this does not do anything useful, but we plan to add search terms after the --.
2010-03-09lib: Rename iterator functions to prepare for reverse iteration.Carl Worth
We rename 'has_more' to 'valid' so that it can function whether iterating in a forward or reverse direction. We also rename 'advance' to 'move_to_next' to setup parallel naming with the proposed functions 'move_to_first', 'move_to_last', and 'move_to_previous'.