mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug #1022
- Fixed bug #1022, where dependencies were note released when a blocking task was completed (thanks to Arkady Grudzinsky). - The Task object now caches ::is_blocked and ::is_blocking Booleans that are determined on pending.data load. - Simplified and sped up color rule processing using cached values, reducing the number of map lookups, and removed loop invariants when the rules are not defined. - Simplified urgency calculations given the cached values for blocked/blocking. - On load, pending.data is scanned for accurate blocked/blocking status determination. - Obsoleted and removed complex single-task dependency calculations. - Sped up 'nag' processing by using cached values.. - Modified the 'show' command to consider color.blocking to be valid. - Added default config value for color.blocking, and included it in the precedence list ahead of blocked, as it is more important. - Updated taskrc.5 man page to include the new color.blocking rule, and its place in the rule precedence.
This commit is contained in:
parent
02053f7300
commit
79e2c591f1
14 changed files with 182 additions and 178 deletions
60
src/TDB2.cpp
60
src/TDB2.cpp
|
@ -67,6 +67,7 @@ TF2::TF2 ()
|
|||
, _loaded_tasks (false)
|
||||
, _loaded_lines (false)
|
||||
, _has_ids (false)
|
||||
, _auto_dep_scan (false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -311,6 +312,9 @@ void TF2::load_tasks ()
|
|||
_U2I[task.get ("uuid")] = task.id;
|
||||
}
|
||||
}
|
||||
|
||||
if (_auto_dep_scan)
|
||||
dependency_scan ();
|
||||
|
||||
_loaded_tasks = true;
|
||||
}
|
||||
|
@ -382,6 +386,12 @@ void TF2::has_ids ()
|
|||
_has_ids = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TF2::auto_dep_scan ()
|
||||
{
|
||||
_auto_dep_scan = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Completely wipe it all clean.
|
||||
void TF2::clear ()
|
||||
|
@ -391,9 +401,10 @@ void TF2::clear ()
|
|||
_loaded_tasks = false;
|
||||
_loaded_lines = false;
|
||||
|
||||
// Note that the actual file name, and _has_ids are deliberately not cleared.
|
||||
// Note that these are deliberately not cleared.
|
||||
//_file._data = "";
|
||||
//_has_ids = false;
|
||||
//_auto_dep_scan = false;
|
||||
|
||||
_tasks.clear ();
|
||||
_added_tasks.clear ();
|
||||
|
@ -404,6 +415,49 @@ void TF2::clear ()
|
|||
_U2I.clear ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// For any task that has depenencies, follow the chain of dependencies until the
|
||||
// end. Along the way, update the Task::is_blocked and Task::is_blocking data
|
||||
// cache.
|
||||
void TF2::dependency_scan ()
|
||||
{
|
||||
// Iterate and modify TDB2 in-place. Don't do this at home.
|
||||
std::vector <Task>::iterator left;
|
||||
for (left = _tasks.begin ();
|
||||
left != _tasks.end ();
|
||||
++left)
|
||||
{
|
||||
if (left->has ("depends"))
|
||||
{
|
||||
std::vector <std::string> deps;
|
||||
left->getDependencies (deps);
|
||||
|
||||
std::vector <std::string>::iterator d;
|
||||
for (d = deps.begin (); d != deps.end (); ++d)
|
||||
{
|
||||
std::vector <Task>::iterator right;
|
||||
for (right = _tasks.begin ();
|
||||
right != _tasks.end ();
|
||||
++right)
|
||||
{
|
||||
if (right->get ("uuid") == *d)
|
||||
{
|
||||
Task::status status = right->getStatus ();
|
||||
if (status != Task::completed &&
|
||||
status != Task::deleted)
|
||||
{
|
||||
left->is_blocked = true;
|
||||
right->is_blocking = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string TF2::dump ()
|
||||
{
|
||||
|
@ -454,6 +508,10 @@ TDB2::TDB2 ()
|
|||
{
|
||||
// Mark the pending file as the only one that has ID numbers.
|
||||
pending.has_ids ();
|
||||
|
||||
// Indicate that dependencies should be automatically scanned on startup,
|
||||
// setting Task::is_blocked and Task::is_blocking accordingly.
|
||||
pending.auto_dep_scan ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue