- Fixed bug #932, which fixed change propagation for recurring tasks (thanks to
  Jennifer Cormier).
- Added unit tests, corrected some.
This commit is contained in:
Paul Beckingham 2012-02-20 17:25:31 -05:00
parent 259f39f2d2
commit 39998d5cc5
7 changed files with 138 additions and 4 deletions

View file

@ -1500,12 +1500,17 @@ void TDB2::revert ()
// moves them to the completed.data file. Returns a count of tasks moved.
// Now reverts expired waiting tasks to pending.
// Now cleans up dangling dependencies.
//
// Possible scenarios:
// - task in pending that needs to be in completed
// - task in completed that needs to be in pending
// - waiting task in pending that needs to be un-waited
int TDB2::gc ()
{
context.timer_gc.start ();
unsigned long load_start = context.timer_load.total ();
// Allowed as a temporary override.
// Allowed as an override, but not recommended.
if (context.config.getBoolean ("gc"))
{
std::vector <Task> pending_tasks = pending.get_tasks ();
@ -1755,6 +1760,36 @@ const std::vector <Task> TDB2::siblings (Task& task)
return results;
}
////////////////////////////////////////////////////////////////////////////////
const std::vector <Task> TDB2::children (Task& task)
{
std::vector <Task> results;
std::string parent = task.get ("uuid");
// First load and scan pending.
if (! pending._loaded_tasks)
pending.load_tasks ();
std::vector <Task>::iterator i;
for (i = pending._tasks.begin (); i != pending._tasks.end (); ++i)
{
// Do not include self in results.
if (i->id != task.id)
{
// Do not include completed or deleted tasks.
if (i->getStatus () != Task::completed &&
i->getStatus () != Task::deleted)
{
// If task has the same parent, it is a sibling.
if (i->get ("parent") == parent)
results.push_back (*i);
}
}
}
return results;
}
////////////////////////////////////////////////////////////////////////////////
std::string TDB2::uuid (int id)
{

View file

@ -110,6 +110,7 @@ public:
bool get (int, Task&);
bool get (const std::string&, Task&);
const std::vector <Task> siblings (Task&);
const std::vector <Task> children (Task&);
// ID <--> UUID mapping.
std::string uuid (int);

View file

@ -110,7 +110,7 @@ int CmdModify::execute (std::string& output)
dependencyChainOnModify (before, *task);
context.footnote (onProjectChange (before, *task));
// Delete siblings.
// Task potentially has siblings - modify them.
if (task->has ("parent"))
{
std::vector <Task> siblings = context.tdb2.siblings (*task);
@ -131,6 +131,28 @@ int CmdModify::execute (std::string& output)
}
}
}
// Task potentially has child tasks - modify them.
else if (task->get ("status") == "recurring")
{
std::vector <Task> children = context.tdb2.children (*task);
if (children.size () &&
confirm (STRING_CMD_MODIFY_RECUR))
{
std::vector <Task>::iterator child;
for (child = children.begin (); child != children.end (); ++child)
{
Task alternate (*child);
modify_task_description_replace (*child, modifications);
updateRecurrenceMask (*child);
context.tdb2.modify (*child);
dependencyChainOnModify (alternate, *child);
context.footnote (onProjectChange (alternate, *child));
++count;
feedback_affected (STRING_CMD_MODIFY_TASK_R, *child);
}
}
}
}
else
{