feedback: Replace taskDiff method by Task inequality operator
This commit is contained in:
committed by
Paul Beckingham
parent
efab724802
commit
4042cbf964
@@ -124,7 +124,7 @@ int CmdDenotate::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taskDiff (before, task))
|
if (before != task)
|
||||||
{
|
{
|
||||||
std::string question = format (STRING_CMD_DENO_CONFIRM,
|
std::string question = format (STRING_CMD_DENO_CONFIRM,
|
||||||
task.id,
|
task.id,
|
||||||
|
|||||||
@@ -184,10 +184,10 @@ void CmdImport::importSingleTask (json::object* obj)
|
|||||||
{
|
{
|
||||||
// "modified:" is automatically set to the current time when a task is
|
// "modified:" is automatically set to the current time when a task is
|
||||||
// changed. If the imported task has a modification timestamp we need
|
// changed. If the imported task has a modification timestamp we need
|
||||||
// to ignore it in taskDiff() in order to check for meaningful
|
// to ignore it in task comparison in order to check for meaningful
|
||||||
// differences. Setting it to the previous value achieves just that.
|
// differences. Setting it to the previous value achieves just that.
|
||||||
task.set ("modified", before.get ("modified"));
|
task.set ("modified", before.get ("modified"));
|
||||||
if (taskDiff (before, task))
|
if (before != task)
|
||||||
{
|
{
|
||||||
CmdModify modHelper;
|
CmdModify modHelper;
|
||||||
modHelper.checkConsistency (before, task);
|
modHelper.checkConsistency (before, task);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ int CmdModify::execute (std::string& output)
|
|||||||
Task before (task);
|
Task before (task);
|
||||||
task.modify (Task::modReplace);
|
task.modify (Task::modReplace);
|
||||||
|
|
||||||
if (taskDiff (before, task))
|
if (before != task)
|
||||||
{
|
{
|
||||||
// Abort if change introduces inconsistencies.
|
// Abort if change introduces inconsistencies.
|
||||||
checkConsistency(before, task);
|
checkConsistency(before, task);
|
||||||
|
|||||||
@@ -43,35 +43,6 @@ extern Context context;
|
|||||||
|
|
||||||
static void countTasks (const std::vector <Task>&, const std::string&, int&, int&);
|
static void countTasks (const std::vector <Task>&, const std::string&, int&, int&);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool taskDiff (const Task& before, const Task& after)
|
|
||||||
{
|
|
||||||
// Attributes are all there is, so figure the different attribute names
|
|
||||||
// between before and after.
|
|
||||||
std::vector <std::string> beforeAtts;
|
|
||||||
for (auto& att : before)
|
|
||||||
beforeAtts.push_back (att.first);
|
|
||||||
|
|
||||||
std::vector <std::string> afterAtts;
|
|
||||||
for (auto& att : after)
|
|
||||||
afterAtts.push_back (att.first);
|
|
||||||
|
|
||||||
std::vector <std::string> beforeOnly;
|
|
||||||
std::vector <std::string> afterOnly;
|
|
||||||
listDiff (beforeAtts, afterAtts, beforeOnly, afterOnly);
|
|
||||||
|
|
||||||
if (beforeOnly.size () !=
|
|
||||||
afterOnly.size ())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
for (auto& name : beforeAtts)
|
|
||||||
if (name != "uuid" &&
|
|
||||||
before.get (name) != after.get (name))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string taskDifferences (const Task& before, const Task& after)
|
std::string taskDifferences (const Task& before, const Task& after)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ void dependencyChainOnComplete (Task&);
|
|||||||
void dependencyChainOnStart (Task&);
|
void dependencyChainOnStart (Task&);
|
||||||
|
|
||||||
// feedback.cpp
|
// feedback.cpp
|
||||||
bool taskDiff (const Task&, const Task&);
|
|
||||||
std::string taskDifferences (const Task&, const Task&);
|
std::string taskDifferences (const Task&, const Task&);
|
||||||
std::string taskInfoDifferences (const Task&, const Task&, const std::string&, long&, const long);
|
std::string taskInfoDifferences (const Task&, const Task&, const std::string&, long&, const long);
|
||||||
std::string renderAttribute (const std::string&, const std::string&, const std::string& format = "");
|
std::string renderAttribute (const std::string&, const std::string&, const std::string& format = "");
|
||||||
|
|||||||
Reference in New Issue
Block a user