mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
TDB2 - id <--> uuid mapping
- Migrated TDB mapping over to TDB2 mapping, which occurs at the TF2 level. This should (soon) restore task dependencies.
This commit is contained in:
parent
30034f057b
commit
bfad448f82
3 changed files with 45 additions and 3 deletions
35
src/TDB2.cpp
35
src/TDB2.cpp
|
@ -254,6 +254,15 @@ void TF2::load_tasks ()
|
||||||
// TODO Find a way to number pending tasks, but not others.
|
// TODO Find a way to number pending tasks, but not others.
|
||||||
// task.id = _id++;
|
// task.id = _id++;
|
||||||
_tasks.push_back (task);
|
_tasks.push_back (task);
|
||||||
|
|
||||||
|
// Maintain mapping for ease of link/dependency resolution.
|
||||||
|
// Note that this mapping is not restricted by the filter, and is
|
||||||
|
// therefore a complete set.
|
||||||
|
if (task.id)
|
||||||
|
{
|
||||||
|
_I2U[task.id] = task.get ("uuid");
|
||||||
|
_U2I[task.get ("uuid")] = task.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_loaded_tasks = true;
|
_loaded_tasks = true;
|
||||||
|
@ -306,6 +315,32 @@ void TF2::load_contents ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string TF2::uuid (int id)
|
||||||
|
{
|
||||||
|
if (! _loaded_tasks)
|
||||||
|
load_tasks ();
|
||||||
|
|
||||||
|
std::map <int, std::string>::const_iterator i;
|
||||||
|
if ((i = _I2U.find (id)) != _I2U.end ())
|
||||||
|
return i->second;
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int TF2::id (const std::string& uuid)
|
||||||
|
{
|
||||||
|
if (! _loaded_tasks)
|
||||||
|
load_tasks ();
|
||||||
|
|
||||||
|
std::map <std::string, int>::const_iterator i;
|
||||||
|
if ((i = _U2I.find (uuid)) != _U2I.end ())
|
||||||
|
return i->second;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,9 @@ public:
|
||||||
void load_lines ();
|
void load_lines ();
|
||||||
void load_contents ();
|
void load_contents ();
|
||||||
|
|
||||||
|
std::string uuid (int);
|
||||||
|
int id (const std::string&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool _read_only;
|
bool _read_only;
|
||||||
bool _dirty;
|
bool _dirty;
|
||||||
|
@ -72,6 +75,10 @@ public:
|
||||||
std::vector <std::string> _added_lines;
|
std::vector <std::string> _added_lines;
|
||||||
std::string _contents;
|
std::string _contents;
|
||||||
File _file;
|
File _file;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map <int, std::string> _I2U; // ID -> UUID map
|
||||||
|
std::map <std::string, int> _U2I; // UUID -> ID map
|
||||||
};
|
};
|
||||||
|
|
||||||
// TDB2 Class represents all the files in the task database.
|
// TDB2 Class represents all the files in the task database.
|
||||||
|
|
|
@ -794,7 +794,7 @@ void Task::addDependency (int id)
|
||||||
throw std::string (STRING_TASK_DEPEND_ITSELF);
|
throw std::string (STRING_TASK_DEPEND_ITSELF);
|
||||||
|
|
||||||
// Check for extant dependency.
|
// Check for extant dependency.
|
||||||
std::string uuid = context.tdb.uuid (id);
|
std::string uuid = context.tdb2.pending.uuid (id);
|
||||||
if (uuid == "")
|
if (uuid == "")
|
||||||
throw format (STRING_TASK_DEPEND_MISSING, id);
|
throw format (STRING_TASK_DEPEND_MISSING, id);
|
||||||
|
|
||||||
|
@ -839,7 +839,7 @@ void Task::removeDependency (const std::string& uuid)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Task::removeDependency (int id)
|
void Task::removeDependency (int id)
|
||||||
{
|
{
|
||||||
std::string uuid = context.tdb.uuid (id);
|
std::string uuid = context.tdb2.pending.uuid (id);
|
||||||
if (uuid != "")
|
if (uuid != "")
|
||||||
removeDependency (uuid);
|
removeDependency (uuid);
|
||||||
else
|
else
|
||||||
|
@ -858,7 +858,7 @@ void Task::getDependencies (std::vector <int>& all) const
|
||||||
|
|
||||||
std::vector <std::string>::iterator i;
|
std::vector <std::string>::iterator i;
|
||||||
for (i = deps.begin (); i != deps.end (); ++i)
|
for (i = deps.begin (); i != deps.end (); ++i)
|
||||||
all.push_back (context.tdb.id (*i));
|
all.push_back (context.tdb2.pending.id (*i));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue