- Implemented "task undelete" for non-GCed deleted tasks.

This commit is contained in:
Paul Beckingham
2008-06-22 00:32:59 -04:00
parent bcae2d2b93
commit 195b5a5e0a
7 changed files with 100 additions and 18 deletions

View File

@@ -11,6 +11,11 @@ represents a feature release, and the Z represents a patch.
- Dependencies - Dependencies
- Recurring tasks - Recurring tasks
1.4.0 ()
+ "task undelete" can now undelete erroneously deleted tasks, provided no
reports have been run (and therefore TDB::gc run)
------ reality -----------------------------------
1.3.1 (6/21/2008) 1.3.1 (6/21/2008)
+ New configuration variable, "defaultwidth" that determines the width + New configuration variable, "defaultwidth" that determines the width
@@ -23,8 +28,6 @@ represents a feature release, and the Z represents a patch.
+ Bug: Task now will recreate a missing ~/.taskrc file, OR a missing + Bug: Task now will recreate a missing ~/.taskrc file, OR a missing
~/.task directory ~/.task directory
------ reality -----------------------------------
1.3.0 (6/18/2008) 1.3.0 (6/18/2008)
+ "task calendar" now displays multiple months per line, adjustable by the + "task calendar" now displays multiple months per line, adjustable by the
"monthsperline" configuration variable. Feature added by Damian Glenny "monthsperline" configuration variable. Feature added by Damian Glenny

View File

@@ -319,6 +319,18 @@ with no arguments will generate a help message that lists all these commands.
% task undelete <id>
--------------------
If a task was inadvertently deleted, it may be undeleted, provided that no
reports have been run since the deletion. Ideally, the undelete command is
run immediately after the erroneous delete command.
If a report is run (such as "task list"), then task performs a garbage
collection that removes deleted tasks, and the task cannot be undeleted.
% task done <id> % task done <id>
---------------- ----------------

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>Task 1.3.1</title> <title>Task 1.4.0</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="task.css" type="text/css" /> <link rel="stylesheet" href="task.css" type="text/css" />
</head> </head>
@@ -38,27 +38,18 @@
<div class="content"> <div class="content">
<p> <p>
Download the Download the
<a href="http://www.beckingham.net/task-1.3.1.tar.gz">latest version</a> <a href="http://www.beckingham.net/task-1.4.0.tar.gz">latest version</a>
of the task source code (1.3.1, 6/21/2008). of the task source code (1.4.0, ????????????????????????????????????????????????).
</p> </p>
<p> <p>
<h4>New in version 1.3.1</h4> <h4>New in version 1.4.0</h4>
Source: <a href="http://www.beckingham.net/task-1.3.1.tar.gz">task-1.3.1.tar.gz</a> Source: <a href="http://www.beckingham.net/task-1.4.0.tar.gz">task-1.4.0.tar.gz</a>
<br />
Debian package: <a href="http://www.beckingham.net/task_1.3.1-1_i386.deb">task_1.3.1-1_i386.deb</a>
(Thanks to <a href="http://blog.rfquerin.org">Richard Querin</a>)
</p> </p>
<ul> <ul>
<li>New configuration variable "defaultwidth" determines the width <li>Added "task undelete" feature to restore a (very) recently deleted
of windows in the absense of ncurses support task
<li>Fixed bug where "showage" configuration variable was not being
oberved by the "task long" report
<li>Fixed bug causing segmentation faults (mostly for Ubuntu users)
when various commands are run
<li>Fixed bug so that task now will recreate a missing ~/.taskrc file,
OR a missing ~/.task directory
</ul> </ul>
<p> <p>
@@ -487,6 +478,18 @@ Car 2 2 wks 25% XXXXXXXXX</code></pre>
delete them. delete them.
</p> </p>
<strong>% task undelete &lt;id&gt;</strong>
<p>
If a task was inadvertently deleted, it may be undeleted, provided that no
reports have been run since the deletion. Ideally, the undelete command is
run immediately after the erroneous delete command.
</p>
<p>
If a report is run (such as "task list"), then task performs a garbage
collection that removes deleted tasks, and the task cannot be undeleted.
</p>
<strong>% task done &lt;id&gt;</strong> <strong>% task done &lt;id&gt;</strong>
<p> <p>
This is how a task is marked as done. This is how a task is marked as done.
@@ -1051,6 +1054,7 @@ on_white on_bright_white</code></pre>
task ID [tags] [attrs] [desc...] task ID [tags] [attrs] [desc...]
task ID /from/to/ task ID /from/to/
task delete ID task delete ID
task undelete ID
task info ID task info ID
task start ID task start ID
task done ID task done ID

View File

@@ -21,6 +21,25 @@
<br /> <br />
<div class="content"> <div class="content">
<p>
<h4>New in version 1.3.1</h4>
Source: <a href="http://www.beckingham.net/task-1.3.1.tar.gz">task-1.3.1.tar.gz</a>
<br />
Debian package: <a href="http://www.beckingham.net/task_1.3.1-1_i386.deb">task_1.3.1-1_i386.deb</a>
(Thanks to <a href="http://blog.rfquerin.org">Richard Querin</a>)
</p>
<ul>
<li>New configuration variable "defaultwidth" determines the width
of windows in the absense of ncurses support
<li>Fixed bug where "showage" configuration variable was not being
oberved by the "task long" report
<li>Fixed bug causing segmentation faults (mostly for Ubuntu users)
when various commands are run
<li>Fixed bug so that task now will recreate a missing ~/.taskrc file,
OR a missing ~/.task directory
</ul>
<p> <p>
<h4>New in version 1.3.0</h4> <h4>New in version 1.3.0</h4>
Source: <a href="http://www.beckingham.net/task-1.3.0.tar.gz">task-1.3.0.tar.gz</a> Source: <a href="http://www.beckingham.net/task-1.3.0.tar.gz">task-1.3.0.tar.gz</a>

View File

@@ -135,6 +135,7 @@ static const char* commands[] =
"stats", "stats",
"summary", "summary",
"tags", "tags",
"undelete",
"usage", "usage",
"version", "version",
"", "",

View File

@@ -108,6 +108,10 @@ void shortUsage (Config& conf)
table.addCell (row, 1, "task delete ID"); table.addCell (row, 1, "task delete ID");
table.addCell (row, 2, "Deletes the specified task"); table.addCell (row, 2, "Deletes the specified task");
row = table.addRow ();
table.addCell (row, 1, "task undelete ID");
table.addCell (row, 2, "Undeletes the specified task, provided a report has not yet been run");
row = table.addRow (); row = table.addRow ();
table.addCell (row, 1, "task info ID"); table.addCell (row, 1, "task info ID");
table.addCell (row, 2, "Shows all data, metadata for specified task"); table.addCell (row, 2, "Shows all data, metadata for specified task");
@@ -266,6 +270,7 @@ int main (int argc, char** argv)
else if (command == "tags") handleTags (tdb, task, conf); else if (command == "tags") handleTags (tdb, task, conf);
else if (command == "list") handleList (tdb, task, conf); else if (command == "list") handleList (tdb, task, conf);
else if (command == "info") handleInfo (tdb, task, conf); else if (command == "info") handleInfo (tdb, task, conf);
else if (command == "undelete") handleUndelete (tdb, task, conf);
else if (command == "long") handleLongList (tdb, task, conf); else if (command == "long") handleLongList (tdb, task, conf);
else if (command == "ls") handleSmallList (tdb, task, conf); else if (command == "ls") handleSmallList (tdb, task, conf);
else if (command == "colors") handleColor ( conf); else if (command == "colors") handleColor ( conf);
@@ -967,6 +972,43 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
std::cout << "No matches." << std::endl; std::cout << "No matches." << std::endl;
} }
////////////////////////////////////////////////////////////////////////////////
// If a task is deleted, but is still in the pending file, then it may be
// undeleted simply by changing it's status.
void handleUndelete (const TDB& tdb, T& task, Config& conf)
{
std::vector <T> all;
tdb.allPendingT (all);
int id = task.getId ();
std::vector <T>::iterator it;
for (it = all.begin (); it != all.end (); ++it)
{
if (it->getId () == id)
{
if (it->getStatus () == T::deleted)
{
T restored (*it);
restored.setStatus (T::pending);
restored.removeAttribute ("end");
tdb.modifyT (restored);
std::cout << "Task " << id << " successfully undeleted." << std::endl;
return;
}
else
{
std::cout << "Task " << id << " is not deleted - therefore cannot undelete." << std::endl;
return;
}
}
}
std::cout << "Task " << id
<< " not found - tasks can only be reliably undeleted if the undelete" << std::endl
<< "command is run immediately after the errant delete command." << std::endl;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Successively apply filters based on the task object built from the command // Successively apply filters based on the task object built from the command
// line. Tasks that match all the specified criteria are listed. // line. Tasks that match all the specified criteria are listed.

View File

@@ -62,6 +62,7 @@ void handleProjects (const TDB&, T&, Config&);
void handleTags (const TDB&, T&, Config&); void handleTags (const TDB&, T&, Config&);
void handleList (const TDB&, T&, Config&); void handleList (const TDB&, T&, Config&);
void handleInfo (const TDB&, T&, Config&); void handleInfo (const TDB&, T&, Config&);
void handleUndelete (const TDB&, T&, Config&);
void handleLongList (const TDB&, T&, Config&); void handleLongList (const TDB&, T&, Config&);
void handleSmallList (const TDB&, T&, Config&); void handleSmallList (const TDB&, T&, Config&);
void handleCompleted (const TDB&, T&, Config&); void handleCompleted (const TDB&, T&, Config&);