From 1465bcb918b41aecb06e8450f1148d0f2add5f8d Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Tue, 10 Mar 2015 05:50:25 +0100 Subject: [PATCH] Context: Do not apply context for the export command --- src/CLI.cpp | 7 +++++-- src/CLI.h | 2 +- src/Filter.cpp | 8 ++++---- src/Filter.h | 4 ++-- src/commands/CmdExport.cpp | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/CLI.cpp b/src/CLI.cpp index 3b1bc1c43..659a8acc5 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -532,10 +532,13 @@ void CLI::applyOverrides () //////////////////////////////////////////////////////////////////////////////// // Extract all the FILTER-tagged items. -const std::string CLI::getFilter () +const std::string CLI::getFilter (bool applyContext /* = true */) { // Handle context setting - addContextFilter (); + // Commands that don't want to respect current context should leverage + // the applyContext argument + if (applyContext) + addContextFilter (); std::string filter = ""; if (_args.size ()) diff --git a/src/CLI.h b/src/CLI.h index 634e05a91..04ad7aca7 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -81,7 +81,7 @@ public: void addRawFilter (const std::string& arg); void analyze (bool parse = true, bool strict = false); void applyOverrides (); - const std::string getFilter (); + const std::string getFilter (bool applyContext = true); const std::vector getWords (); bool canonicalize (std::string&, const std::string&, const std::string&) const; std::string getBinary () const; diff --git a/src/Filter.cpp b/src/Filter.cpp index 3a672599d..0f3cd265f 100644 --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -67,7 +67,7 @@ Filter::~Filter () //////////////////////////////////////////////////////////////////////////////// // Take an input set of tasks and filter into a subset. -void Filter::subset (const std::vector & input, std::vector & output) +void Filter::subset (const std::vector & input, std::vector & output, bool applyContext /* = true */) { context.timer_filter.start (); _startCount = (int) input.size (); @@ -75,7 +75,7 @@ void Filter::subset (const std::vector & input, std::vector & output if (context.config.getInteger ("debug.parser") >= 1) context.debug (context.cli.dump ("Filter::subset")); - std::string filterExpr = context.cli.getFilter (); + std::string filterExpr = context.cli.getFilter (applyContext); if (filterExpr.length ()) { Eval eval; @@ -111,7 +111,7 @@ void Filter::subset (const std::vector & input, std::vector & output //////////////////////////////////////////////////////////////////////////////// // Take the set of all tasks and filter into a subset. -void Filter::subset (std::vector & output) +void Filter::subset (std::vector & output, bool applyContext /* = true */) { context.timer_filter.start (); @@ -119,7 +119,7 @@ void Filter::subset (std::vector & output) context.debug (context.cli.dump ("Filter::subset")); bool shortcut = false; - std::string filterExpr = context.cli.getFilter (); + std::string filterExpr = context.cli.getFilter (applyContext); if (filterExpr.length ()) { context.timer_filter.stop (); diff --git a/src/Filter.h b/src/Filter.h index 0a40543ac..e2c4c3d44 100644 --- a/src/Filter.h +++ b/src/Filter.h @@ -40,8 +40,8 @@ public: Filter (); ~Filter (); - void subset (const std::vector &, std::vector &); - void subset (std::vector &); + void subset (const std::vector &, std::vector &, bool applyContext = true); + void subset (std::vector &, bool applyContext = true); bool pendingOnly (); void safety (); diff --git a/src/commands/CmdExport.cpp b/src/commands/CmdExport.cpp index 43cb30ecb..750fa556b 100644 --- a/src/commands/CmdExport.cpp +++ b/src/commands/CmdExport.cpp @@ -54,7 +54,7 @@ int CmdExport::execute (std::string& output) // Apply filter. Filter filter; std::vector filtered; - filter.subset (filtered); + filter.subset (filtered, false); // Obey 'limit:N'. int rows = 0;