mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-05 14:07:21 +02:00
Bug #837
- Fixed bug #837, which caused incorrect urgency calculations for tasks that have completed dependencies, and problems when editing those tasks (thanks to Matt Kraai). - Added Task::addDependency (const std::string&) method for reconstructing dependencies on tasks with no ID. - Modfified Task::urgency_blocked so that it considers the blocking task's status. This is an expensive test, and so it is wrapped by a cheaper test to see if there are/were any dependencies at all. This means that urgency calculations are not slowed for tasks without dependencies, and is slower but more accurate for tasks that do have dependencies. - Modified edit command so that dependencies are shown as IDs or UUIDs depending on whether the task is pending or not. - Modified edit command so that dependencies are parsed as IDs or UUIDs depending on whether the task is pending or not. - Modified wording in the template of the edit command to reflect the above. - Added unit tests bug.837.t.
This commit is contained in:
parent
1582fb1f88
commit
77200d7eb4
6 changed files with 142 additions and 7 deletions
43
src/Task.cpp
43
src/Task.cpp
|
@ -743,6 +743,32 @@ void Task::addDependency (int id)
|
|||
recalc_urgency = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::addDependency (const std::string& uuid)
|
||||
{
|
||||
if (uuid == get ("uuid"))
|
||||
throw std::string (STRING_TASK_DEPEND_ITSELF);
|
||||
|
||||
// Store the dependency.
|
||||
std::string depends = get ("depends");
|
||||
if (depends != "")
|
||||
{
|
||||
// Check for extant dependency.
|
||||
if (depends.find (uuid) == std::string::npos)
|
||||
set ("depends", depends + "," + uuid);
|
||||
else
|
||||
throw format (STRING_TASK_DEPEND_DUP, this->get ("uuid"), uuid);
|
||||
}
|
||||
else
|
||||
set ("depends", uuid);
|
||||
|
||||
// Prevent circular dependencies.
|
||||
if (dependencyIsCircular (*this))
|
||||
throw std::string (STRING_TASK_DEPEND_CIRCULAR);
|
||||
|
||||
recalc_urgency = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::removeDependency (const std::string& uuid)
|
||||
{
|
||||
|
@ -1333,10 +1359,25 @@ float Task::urgency_waiting () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// A task is blocked only if the task it depends upon is pending/waiting.
|
||||
float Task::urgency_blocked () const
|
||||
{
|
||||
if (has ("depends"))
|
||||
return 1.0;
|
||||
{
|
||||
std::vector <std::string> deps;
|
||||
getDependencies (deps);
|
||||
|
||||
std::vector <std::string>::iterator d;
|
||||
for (d = deps.begin (); d != deps.end (); ++d)
|
||||
{
|
||||
Task t;
|
||||
if (context.tdb2.get (*d, t) &&
|
||||
(t.getStatus () == Task::pending || t.getStatus () == Task::waiting))
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue