mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Task: Improved method signature
This commit is contained in:
parent
5193f7d03e
commit
245ed39b78
7 changed files with 26 additions and 52 deletions
|
@ -528,10 +528,7 @@ void TF2::dependency_scan ()
|
|||
{
|
||||
if (left.has ("depends"))
|
||||
{
|
||||
std::vector <std::string> deps;
|
||||
left.getDependencies (deps);
|
||||
|
||||
for (auto& dep : deps)
|
||||
for (auto& dep : left.getDependencyUUIDs ())
|
||||
{
|
||||
for (auto& right : _tasks)
|
||||
{
|
||||
|
|
26
src/Task.cpp
26
src/Task.cpp
|
@ -1186,35 +1186,33 @@ void Task::removeDependency (int id)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::getDependencies (std::vector <int>& all) const
|
||||
std::vector <int> Task::getDependencyIDs () const
|
||||
{
|
||||
auto deps = split (get ("depends"), ',');
|
||||
|
||||
all.clear ();
|
||||
|
||||
for (auto& dep : deps)
|
||||
std::vector <int> all;
|
||||
for (auto& dep : split (get ("depends"), ','))
|
||||
all.push_back (context.tdb2.pending.id (dep));
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::getDependencies (std::vector <std::string>& all) const
|
||||
std::vector <std::string> Task::getDependencyUUIDs () const
|
||||
{
|
||||
all = split (get ("depends"), ',');
|
||||
return split (get ("depends"), ',');
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::getDependencies (std::vector <Task>& all) const
|
||||
std::vector <Task> Task::getDependencyTasks () const
|
||||
{
|
||||
std::vector <std::string> deps = split (get ("depends"), ',');
|
||||
|
||||
all.clear ();
|
||||
|
||||
for (auto& dep : deps)
|
||||
std::vector <Task> all;
|
||||
for (auto& dep : split (get ("depends"), ','))
|
||||
{
|
||||
Task task;
|
||||
context.tdb2.get (dep, task);
|
||||
all.push_back (task);
|
||||
}
|
||||
|
||||
return all;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -141,9 +141,9 @@ public:
|
|||
#ifdef PRODUCT_TASKWARRIOR
|
||||
void removeDependency (int);
|
||||
void removeDependency (const std::string&);
|
||||
void getDependencies (std::vector <int>&) const;
|
||||
void getDependencies (std::vector <std::string>&) const;
|
||||
void getDependencies (std::vector <Task>&) const;
|
||||
std::vector <int> getDependencyIDs () const;
|
||||
std::vector <std::string> getDependencyUUIDs () const;
|
||||
std::vector <Task> getDependencyTasks () const;
|
||||
|
||||
std::vector <std::string> getUDAOrphanUUIDs () const;
|
||||
|
||||
|
|
|
@ -456,10 +456,7 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
for (auto& task : all)
|
||||
{
|
||||
// Check dependencies
|
||||
std::vector <std::string> dependencies;
|
||||
task.getDependencies(dependencies);
|
||||
|
||||
for (auto& uuid : dependencies)
|
||||
for (auto& uuid : task.getDependencyUUIDs ())
|
||||
{
|
||||
if (! context.tdb2.has (uuid))
|
||||
{
|
||||
|
|
|
@ -256,8 +256,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat)
|
|||
before << " Annotation: " << now.toString (dateformat) << " -- \n";
|
||||
|
||||
// Add dependencies here.
|
||||
std::vector <std::string> dependencies;
|
||||
task.getDependencies (dependencies);
|
||||
auto dependencies = task.getDependencyUUIDs ();
|
||||
std::stringstream allDeps;
|
||||
for (unsigned int i = 0; i < dependencies.size (); ++i)
|
||||
{
|
||||
|
|
|
@ -82,8 +82,7 @@ bool dependencyIsCircular (const Task& task)
|
|||
while (! s.empty ())
|
||||
{
|
||||
Task& current = s.top ();
|
||||
std::vector <std::string> deps_current;
|
||||
current.getDependencies (deps_current);
|
||||
auto deps_current = current.getDependencyUUIDs ();
|
||||
|
||||
// This is a basic depth first search that always terminates given the
|
||||
// fact that we do not visit any task twice
|
||||
|
|
|
@ -84,8 +84,7 @@ std::string taskDifferences (const Task& before, const Task& after)
|
|||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
std::vector <Task> deps_after;
|
||||
after.getDependencies (deps_after);
|
||||
auto deps_after = after.getDependencyTasks ();
|
||||
|
||||
out << " - "
|
||||
<< format (STRING_FEEDBACK_DEP_SET, taskIdentifiers (deps_after))
|
||||
|
@ -110,12 +109,10 @@ std::string taskDifferences (const Task& before, const Task& after)
|
|||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
std::vector <Task> deps_before;
|
||||
before.getDependencies (deps_before);
|
||||
auto deps_before = before.getDependencyTasks ();
|
||||
std::string from = taskIdentifiers (deps_before);
|
||||
|
||||
std::vector <Task> deps_after;
|
||||
after.getDependencies (deps_after);
|
||||
auto deps_after = after.getDependencyTasks ();
|
||||
std::string to = taskIdentifiers (deps_after);
|
||||
|
||||
out << " - "
|
||||
|
@ -169,11 +166,7 @@ std::string taskInfoDifferences (
|
|||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
std::vector <Task> deps_before;
|
||||
before.getDependencies (deps_before);
|
||||
std::string from = taskIdentifiers (deps_before);
|
||||
|
||||
out << format (STRING_FEEDBACK_DEP_DEL, from)
|
||||
out << format (STRING_FEEDBACK_DEP_DEL, taskIdentifiers (before.getDependencyTasks ()))
|
||||
<< "\n";
|
||||
}
|
||||
else if (name.substr (0, 11) == "annotation_")
|
||||
|
@ -198,11 +191,7 @@ std::string taskInfoDifferences (
|
|||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
std::vector <Task> deps_after;
|
||||
after.getDependencies (deps_after);
|
||||
std::string to = taskIdentifiers (deps_after);
|
||||
|
||||
out << format (STRING_FEEDBACK_DEP_WAS_SET, to)
|
||||
out << format (STRING_FEEDBACK_DEP_WAS_SET, taskIdentifiers (after.getDependencyTasks ()))
|
||||
<< "\n";
|
||||
}
|
||||
else if (name.substr (0, 11) == "annotation_")
|
||||
|
@ -231,13 +220,8 @@ std::string taskInfoDifferences (
|
|||
{
|
||||
if (name == "depends")
|
||||
{
|
||||
std::vector <Task> deps_before;
|
||||
before.getDependencies (deps_before);
|
||||
std::string from = taskIdentifiers (deps_before);
|
||||
|
||||
std::vector <Task> deps_after;
|
||||
after.getDependencies (deps_after);
|
||||
std::string to = taskIdentifiers (deps_after);
|
||||
auto from = taskIdentifiers (before.getDependencyTasks ());
|
||||
auto to = taskIdentifiers (after.getDependencyTasks ());
|
||||
|
||||
out << format (STRING_FEEDBACK_DEP_WAS_MOD, from, to)
|
||||
<< "\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue