mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-02 03:37:19 +02:00
TDB2
- Converted 'prepend' to TDB2.
This commit is contained in:
parent
40724e120e
commit
ba5daece99
1 changed files with 28 additions and 37 deletions
|
@ -54,14 +54,9 @@ int CmdPrepend::execute (std::string& output)
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
|
||||||
context.tdb.loadPending (tasks);
|
|
||||||
|
|
||||||
// Apply filter.
|
// Apply filter.
|
||||||
std::vector <Task> filtered;
|
std::vector <Task> filtered;
|
||||||
filter (tasks, filtered);
|
filter (filtered);
|
||||||
|
|
||||||
if (filtered.size () == 0)
|
if (filtered.size () == 0)
|
||||||
{
|
{
|
||||||
context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
|
context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
|
||||||
|
@ -77,55 +72,51 @@ int CmdPrepend::execute (std::string& output)
|
||||||
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
||||||
permission.bigSequence ();
|
permission.bigSequence ();
|
||||||
|
|
||||||
|
// A non-zero value forces a file write.
|
||||||
|
int changes = 0;
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
{
|
{
|
||||||
modify_task_description_prepend (*task, modifications);
|
modify_task_description_prepend (*task, modifications);
|
||||||
apply_defaults (*task);
|
apply_defaults (*task);
|
||||||
|
++changes;
|
||||||
|
context.tdb2.modify (*task);
|
||||||
|
|
||||||
std::vector <Task>::iterator other;
|
std::vector <Task> siblings = context.tdb2.siblings (*task);
|
||||||
for (other = tasks.begin (); other != tasks.end (); ++other)
|
std::vector <Task>::iterator sibling;
|
||||||
|
for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling)
|
||||||
{
|
{
|
||||||
if (other->id == task->id || // Self
|
Task before (*sibling);
|
||||||
(task->has ("parent") &&
|
|
||||||
task->get ("parent") == other->get ("parent")) || // Sibling
|
|
||||||
other->get ("uuid") == task->get ("parent")) // Parent
|
|
||||||
{
|
|
||||||
Task before (*other);
|
|
||||||
|
|
||||||
// A non-zero value forces a file write.
|
|
||||||
int changes = 0;
|
|
||||||
|
|
||||||
// Apply other deltas.
|
// Apply other deltas.
|
||||||
modify_task_description_prepend (*other, modifications);
|
modify_task_description_prepend (*sibling, modifications);
|
||||||
apply_defaults (*other);
|
apply_defaults (*sibling);
|
||||||
++changes;
|
++changes;
|
||||||
|
|
||||||
if (taskDiff (before, *other))
|
if (taskDiff (before, *sibling))
|
||||||
{
|
{
|
||||||
// Only allow valid tasks.
|
// Only allow valid tasks.
|
||||||
other->validate ();
|
sibling->validate ();
|
||||||
|
|
||||||
if (changes && permission.confirmed (before, taskDifferences (before, *other) + "Proceed with change?"))
|
if (changes && permission.confirmed (before, taskDifferences (before, *sibling) + "Proceed with change?"))
|
||||||
{
|
{
|
||||||
context.tdb.update (*other);
|
context.tdb2.modify (*sibling);
|
||||||
|
|
||||||
if (context.config.getBoolean ("echo.command"))
|
if (context.config.getBoolean ("echo.command"))
|
||||||
out << format (STRING_CMD_PREPEND_DONE, other->id)
|
out << format (STRING_CMD_PREPEND_DONE, sibling->id)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
if (before.get ("project") != other->get ("project"))
|
if (before.get ("project") != sibling->get ("project"))
|
||||||
context.footnote (onProjectChange (before, *other));
|
context.footnote (onProjectChange (before, *sibling));
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
context.tdb.commit ();
|
context.tdb2.commit ();
|
||||||
context.tdb.unlock ();
|
|
||||||
|
|
||||||
if (context.config.getBoolean ("echo.command"))
|
if (context.config.getBoolean ("echo.command"))
|
||||||
out << format ((count == 1
|
out << format ((count == 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue