mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Dependencies
- Code now in final form, but still incomplete.
This commit is contained in:
parent
0388bcf259
commit
dd86c2c875
4 changed files with 91 additions and 39 deletions
|
@ -1266,7 +1266,7 @@ int handleDelete (std::string &outs)
|
||||||
<< "'."
|
<< "'."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
out << dependencyNag (*task);
|
dependencyChainOnComplete (*task);
|
||||||
out << onProjectChange (*task);
|
out << onProjectChange (*task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1289,7 +1289,7 @@ int handleDelete (std::string &outs)
|
||||||
<< "'."
|
<< "'."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
out << dependencyNag (*task);
|
dependencyChainOnComplete (*task);
|
||||||
out << onProjectChange (*task);
|
out << onProjectChange (*task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1356,7 +1356,7 @@ int handleStart (std::string &outs)
|
||||||
if (!nagged)
|
if (!nagged)
|
||||||
nagged = nag (*task);
|
nagged = nag (*task);
|
||||||
|
|
||||||
out << dependencyNag (*task);
|
dependencyChainOnStart (*task);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1503,7 +1503,7 @@ int handleDone (std::string &outs)
|
||||||
<< "'."
|
<< "'."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
out << dependencyNag (*task);
|
dependencyChainOnComplete (*task);
|
||||||
out << onProjectChange (*task, false);
|
out << onProjectChange (*task, false);
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
|
@ -1648,6 +1648,13 @@ int handleModify (std::string &outs)
|
||||||
{
|
{
|
||||||
if (changes && permission.confirmed (before, taskDifferences (before, *other) + "Proceed with change?"))
|
if (changes && permission.confirmed (before, taskDifferences (before, *other) + "Proceed with change?"))
|
||||||
{
|
{
|
||||||
|
// TODO Are dependencies being explicitly removed?
|
||||||
|
// Either we scan context.task for negative IDs "depends:-n"
|
||||||
|
// or we ask deltaAttributes (above) to record dependency
|
||||||
|
// removal.
|
||||||
|
if (1)
|
||||||
|
dependencyChainOnModify (before, *other);
|
||||||
|
|
||||||
context.tdb.update (*other);
|
context.tdb.update (*other);
|
||||||
|
|
||||||
if (before.get ("project") != other->get ("project"))
|
if (before.get ("project") != other->get ("project"))
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
|
@ -183,59 +184,95 @@ static bool followUpstream (
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Determine whether a dependency chain is being broken, assuming that 'task' is
|
// Determine whether a dependency chain is being broken, assuming that 'task' is
|
||||||
// either completed or deleted.
|
// either completed or deleted.
|
||||||
|
//
|
||||||
|
// blocked task blocking action
|
||||||
|
// ------- ---- -------- -----------------------------
|
||||||
|
// [1] 2 Chain broken
|
||||||
|
// Nag message generated
|
||||||
|
// Repair offered: 1 dep:-2
|
||||||
//
|
//
|
||||||
// [1] --> 2 Chain broken
|
// [1] 2 Chain broken
|
||||||
// Nag message generated
|
// 3 Nag message generated
|
||||||
// Repair offered: 1 dep:-2
|
// Repair offered: 1 dep:-2,-3
|
||||||
//
|
//
|
||||||
// [1] --> 2 Chain broken
|
// 1 [2] -
|
||||||
// --> 3 Nag message generated
|
|
||||||
// Repair offered: 1 dep:-2,-3
|
|
||||||
//
|
//
|
||||||
// 1 --> [2] -
|
// 1,3 [2] -
|
||||||
//
|
//
|
||||||
// 1 --> [2] -
|
// 1 [2] 3 Chain broken
|
||||||
// 3 -->
|
// Nag message generated
|
||||||
|
// Repair offered: 2 dep:-3
|
||||||
|
// 1 dep:-2,3
|
||||||
//
|
//
|
||||||
// 1 --> [2] --> 3 Chain broken
|
// 1,4 [2] 3,5 Chain broken
|
||||||
// Nag message generated
|
// Nag message generated
|
||||||
// Repair offered: 2 dep:-3
|
// Repair offered: 2 dep:-3,-5
|
||||||
// 1 dep:-2,3
|
// 1 dep:3,5
|
||||||
|
// 4 dep:3,5
|
||||||
//
|
//
|
||||||
// 1 --> [2] --> 3 Chain broken
|
void dependencyChainOnComplete (Task& task)
|
||||||
// 4 --> --> 5 Nag message generated
|
|
||||||
// Repair offered: 2 dep:-3,-5
|
|
||||||
// 1 dep:3,5
|
|
||||||
// 4 dep:3,5
|
|
||||||
//
|
|
||||||
bool dependencyChainBroken (Task& task)
|
|
||||||
{
|
{
|
||||||
if (task.has ("depends"))
|
std::vector <Task> blocking;
|
||||||
{
|
dependencyGetBlocking (task, blocking);
|
||||||
std::cout << "# chain broken?\n";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
std::cout << "# Task " << task.id << "\n";
|
||||||
|
foreach (t, blocking)
|
||||||
|
std::cout << "# blocking " << t->id << " " << t->get ("uuid") << "\n";
|
||||||
|
|
||||||
|
// If the task is anything but the tail end of a dependency chain.
|
||||||
|
if (blocking.size ())
|
||||||
|
{
|
||||||
|
std::vector <Task> blocked;
|
||||||
|
dependencyGetBlocked (task, blocked);
|
||||||
|
|
||||||
|
foreach (t, blocked)
|
||||||
|
std::cout << "# blocked by " << t->id << " " << t->get ("uuid") << "\n";
|
||||||
|
|
||||||
|
// If there are both blocking and blocked tasks, the chain is broken.
|
||||||
|
if (blocked.size ())
|
||||||
|
{
|
||||||
|
// TODO Nag about broken chain.
|
||||||
|
std::cout << "# Chain broken - offer to repair\n";
|
||||||
|
|
||||||
|
// TODO Confirm that the chain should be repaired.
|
||||||
|
|
||||||
|
// Repair the chain - everything in blocked should now depend on
|
||||||
|
// everything in blocking, instead of task.id.
|
||||||
|
foreach (left, blocked)
|
||||||
|
{
|
||||||
|
left->removeDependency (task.id);
|
||||||
|
|
||||||
|
foreach (right, blocking)
|
||||||
|
left->addDependency (right->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Generate a nag message if a dependency chain is being violated.
|
void dependencyChainOnStart (Task& task)
|
||||||
std::string dependencyNag (Task& task)
|
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
if (context.config.getBoolean ("dependency.reminder") &&
|
if (context.config.getBoolean ("dependency.reminder") /* &&
|
||||||
task.has ("depends"))
|
TODO check that task is actually blocked */)
|
||||||
{
|
{
|
||||||
out << "# dependencyNag "
|
out << "# dependencyChainScan nag! "
|
||||||
<< task.id
|
<< task.id
|
||||||
<< " "
|
<< " "
|
||||||
<< task.get ("uuid")
|
<< task.get ("uuid")
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
|
||||||
|
|
||||||
return out.str ();
|
context.footnote (out.str ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void dependencyChainOnModify (Task& before, Task& after)
|
||||||
|
{
|
||||||
|
// TODO Iff a dependency is being removed, is there anything to do.
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -172,6 +172,8 @@ static std::string formatTask (Task task)
|
||||||
before << " Annotation: " << now.toString (context.config.get ("dateformat.annotation")) << " -- " << std::endl
|
before << " Annotation: " << now.toString (context.config.get ("dateformat.annotation")) << " -- " << std::endl
|
||||||
<< "# End" << std::endl;
|
<< "# End" << std::endl;
|
||||||
|
|
||||||
|
// TODO Add dependencies here.
|
||||||
|
|
||||||
return before.str ();
|
return before.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,6 +520,8 @@ static void parseTask (Task& task, const std::string& after)
|
||||||
}
|
}
|
||||||
|
|
||||||
task.setAnnotations (annotations);
|
task.setAnnotations (annotations);
|
||||||
|
|
||||||
|
// TODO Dependencies
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -628,6 +632,9 @@ int handleEdit (std::string &outs)
|
||||||
editFile (*task);
|
editFile (*task);
|
||||||
context.tdb.update (*task);
|
context.tdb.update (*task);
|
||||||
/*
|
/*
|
||||||
|
TODO Figure out what this is. I can't remember, but don't want to remove
|
||||||
|
it until I do.
|
||||||
|
|
||||||
foreach (other, all)
|
foreach (other, all)
|
||||||
{
|
{
|
||||||
if (other->id != task.id) // Don't edit the same task again.
|
if (other->id != task.id) // Don't edit the same task again.
|
||||||
|
|
|
@ -137,8 +137,9 @@ void dependencyGetBlocked (Task&, std::vector <Task>&);
|
||||||
bool dependencyIsBlocking (Task&);
|
bool dependencyIsBlocking (Task&);
|
||||||
void dependencyGetBlocking (Task&, std::vector <Task>&);
|
void dependencyGetBlocking (Task&, std::vector <Task>&);
|
||||||
bool dependencyIsCircular (Task&);
|
bool dependencyIsCircular (Task&);
|
||||||
bool dependencyChainBroken (Task&);
|
void dependencyChainOnComplete (Task&);
|
||||||
std::string dependencyNag (Task&);
|
void dependencyChainOnStart (Task&);
|
||||||
|
void dependencyChainOnModify (Task&, Task&);
|
||||||
|
|
||||||
// list template
|
// list template
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue