mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Logic Bug
- Fixed logic bug dealing wiht bulk updates and recurring tasks.
This commit is contained in:
parent
9a7d631873
commit
988ab7ada0
1 changed files with 51 additions and 26 deletions
|
@ -25,15 +25,15 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#define L10N // Localization complete.
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Permission.h>
|
#include <Permission.h>
|
||||||
#include <main.h>
|
#include <util.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
#include <main.h>
|
||||||
#include <CmdAppend.h>
|
#include <CmdAppend.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
@ -64,7 +64,7 @@ int CmdAppend::execute (std::string& output)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the command line modifications to the started task.
|
// Apply the command line modifications to the new task.
|
||||||
A3 modifications = context.a3.extract_modifications ();
|
A3 modifications = context.a3.extract_modifications ();
|
||||||
if (!modifications.size ())
|
if (!modifications.size ())
|
||||||
throw std::string (STRING_CMD_XPEND_NEED_TEXT);
|
throw std::string (STRING_CMD_XPEND_NEED_TEXT);
|
||||||
|
@ -73,44 +73,69 @@ int CmdAppend::execute (std::string& output)
|
||||||
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
||||||
permission.bigSequence ();
|
permission.bigSequence ();
|
||||||
|
|
||||||
// A non-zero value forces a file write.
|
|
||||||
int changes = 0;
|
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
{
|
{
|
||||||
|
Task before (*task);
|
||||||
|
|
||||||
|
// Append to the specified task.
|
||||||
|
std::string question = format (STRING_CMD_APPEND_QUESTION,
|
||||||
|
task->id,
|
||||||
|
task->get ("description"));
|
||||||
|
|
||||||
modify_task_description_append (*task, modifications);
|
modify_task_description_append (*task, modifications);
|
||||||
++changes;
|
|
||||||
|
if (permission.confirmed (*task, taskDifferences (before, *task) + question))
|
||||||
|
{
|
||||||
context.tdb2.modify (*task);
|
context.tdb2.modify (*task);
|
||||||
|
++count;
|
||||||
std::vector <Task> siblings = context.tdb2.siblings (*task);
|
|
||||||
std::vector <Task>::iterator sibling;
|
|
||||||
for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling)
|
|
||||||
{
|
|
||||||
Task before (*sibling);
|
|
||||||
|
|
||||||
// Apply other deltas.
|
|
||||||
modify_task_description_append (*sibling, modifications);
|
|
||||||
++changes;
|
|
||||||
|
|
||||||
if (taskDiff (before, *sibling))
|
|
||||||
{
|
|
||||||
if (changes && permission.confirmed (before, taskDifferences (before, *sibling) + "Proceed with change?"))
|
|
||||||
{
|
|
||||||
context.tdb2.modify (*sibling);
|
|
||||||
|
|
||||||
if (context.verbose ("affected") ||
|
if (context.verbose ("affected") ||
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||||
out << format (STRING_CMD_APPEND_DONE, sibling->id)
|
out << format (task->has ("parent")
|
||||||
|
? STRING_CMD_APPEND_RECURRING
|
||||||
|
: STRING_CMD_APPEND_DELETING,
|
||||||
|
task->id,
|
||||||
|
task->get ("description"))
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
if (before.get ("project") != sibling->get ("project"))
|
context.footnote (onProjectChange (*task, true));
|
||||||
context.footnote (onProjectChange (before, *sibling));
|
|
||||||
|
|
||||||
|
// Append to siblings.
|
||||||
|
if (task->has ("parent"))
|
||||||
|
{
|
||||||
|
std::vector <Task> siblings = context.tdb2.siblings (*task);
|
||||||
|
if (siblings.size () &&
|
||||||
|
confirm (STRING_CMD_APPEND_CONF_RECUR))
|
||||||
|
{
|
||||||
|
std::vector <Task>::iterator sibling;
|
||||||
|
for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling)
|
||||||
|
{
|
||||||
|
modify_task_description_append (*sibling, modifications);
|
||||||
|
context.tdb2.modify (*sibling);
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
|
if (context.verbose ("affected") ||
|
||||||
|
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||||
|
out << format (STRING_CMD_APPEND_RECURRING,
|
||||||
|
sibling->id,
|
||||||
|
sibling->get ("description"))
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append to the parent
|
||||||
|
Task parent;
|
||||||
|
context.tdb2.get (task->get ("parent"), parent);
|
||||||
|
modify_task_description_append (parent, modifications);
|
||||||
|
context.tdb2.modify (parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out << STRING_CMD_DELETE_NOT << "\n";
|
||||||
|
rc = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.tdb2.commit ();
|
context.tdb2.commit ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue