mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
TW-1688: task fails to import
- Thanks to Rainer Müller.
This commit is contained in:
parent
f55afe33d7
commit
cd736a0d70
4 changed files with 30 additions and 9 deletions
|
@ -150,6 +150,7 @@
|
|||
Patrick).
|
||||
- TW-1687 task add due:som appears to be interpreted as 'someday' (thanks to
|
||||
Alan Young).
|
||||
- TW-1688 task fails to import (thanks to Rainer Müller).
|
||||
- Prevent potential task duplication during import for non-pending tasks.
|
||||
- Show the active context in "context list", if any is active.
|
||||
- Fix "task edit" dropping annotation text after newlines.
|
||||
|
|
|
@ -67,15 +67,14 @@ void dependencyGetBlocking (const Task& task, std::vector <Task>& blocking)
|
|||
// Returns true if the supplied task adds a cycle to the dependency chain.
|
||||
bool dependencyIsCircular (const Task& task)
|
||||
{
|
||||
std::stack <Task> s;
|
||||
std::vector <std::string> deps_current;
|
||||
|
||||
std::string task_uuid = task.get ("uuid");
|
||||
|
||||
std::stack <Task> s;
|
||||
s.push (task);
|
||||
while (!s.empty ())
|
||||
while (! s.empty ())
|
||||
{
|
||||
Task& current = s.top ();
|
||||
std::vector <std::string> deps_current;
|
||||
current.getDependencies (deps_current);
|
||||
|
||||
// This is a basic depth first search that always terminates given the
|
||||
|
@ -85,16 +84,18 @@ bool dependencyIsCircular (const Task& task)
|
|||
// function, this is a reasonable assumption.
|
||||
for (unsigned int i = 0; i < deps_current.size (); i++)
|
||||
{
|
||||
context.tdb2.get (deps_current[i], current);
|
||||
|
||||
if (task_uuid == current.get ("uuid"))
|
||||
if (context.tdb2.get (deps_current[i], current))
|
||||
{
|
||||
if (task_uuid == current.get ("uuid"))
|
||||
{
|
||||
// Cycle found, initial task reached for the second time!
|
||||
return true;
|
||||
}
|
||||
|
||||
s.push (current);
|
||||
s.push (current);
|
||||
}
|
||||
}
|
||||
|
||||
s.pop ();
|
||||
}
|
||||
|
||||
|
|
20
test/tw-1688.t
Executable file
20
test/tw-1688.t
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
. bash_tap_tw.sh
|
||||
|
||||
# TW-1688 task fails to import
|
||||
# The problem is when a completed task, with a dependency is exported, then
|
||||
# imported after the data is removed. On import, the circular dependency
|
||||
# check didn't notice that a UUID failed to exist, and generated a JSON error.
|
||||
#
|
||||
# Although an unusual circumstance, people do delete data from their
|
||||
# completed.data file.
|
||||
|
||||
task add one
|
||||
task log two depends:1
|
||||
|
||||
JSON=$(mktemp /tmp/tw-1688.XXXXXXXXXX)
|
||||
task /two/ export > $JSON
|
||||
|
||||
rm $TASKDATA/pending.data $TASKDATA/completed.data
|
||||
task import $JSON
|
||||
|
|
@ -42,7 +42,6 @@ class TestBug46(TestCase):
|
|||
self.t("add two")
|
||||
self.t("add three")
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_bug46(self):
|
||||
"""Circular dependency detection broken by deletion of completed.data"""
|
||||
self.t("1 mod dep:2")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue