From 195b5a5e0ac631af296fba73fe644f66b97a9927 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 22 Jun 2008 00:32:59 -0400 Subject: [PATCH] - Implemented "task undelete" for non-GCed deleted tasks. --- ChangeLog | 7 +++++-- TUTORIAL | 12 ++++++++++++ html/task.html | 36 ++++++++++++++++++++---------------- html/versions.html | 19 +++++++++++++++++++ src/parse.cpp | 1 + src/task.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ src/task.h | 1 + 7 files changed, 100 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4914190e0..91999bc7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,11 @@ represents a feature release, and the Z represents a patch. - Dependencies - 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) + 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 ~/.task directory ------- reality ----------------------------------- - 1.3.0 (6/18/2008) + "task calendar" now displays multiple months per line, adjustable by the "monthsperline" configuration variable. Feature added by Damian Glenny diff --git a/TUTORIAL b/TUTORIAL index 075b0a654..6bfe53abe 100644 --- a/TUTORIAL +++ b/TUTORIAL @@ -319,6 +319,18 @@ with no arguments will generate a help message that lists all these commands. +% task undelete +-------------------- + + 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 ---------------- diff --git a/html/task.html b/html/task.html index 3d2cb77c8..6273c3df4 100644 --- a/html/task.html +++ b/html/task.html @@ -1,7 +1,7 @@ - Task 1.3.1 + Task 1.4.0 @@ -38,27 +38,18 @@

Download the - latest version - of the task source code (1.3.1, 6/21/2008). + latest version + of the task source code (1.4.0, ????????????????????????????????????????????????).

-

New in version 1.3.1

- Source: task-1.3.1.tar.gz -
- Debian package: task_1.3.1-1_i386.deb - (Thanks to Richard Querin) +

New in version 1.4.0

+ Source: task-1.4.0.tar.gz

    -
  • New configuration variable "defaultwidth" determines the width - of windows in the absense of ncurses support -
  • Fixed bug where "showage" configuration variable was not being - oberved by the "task long" report -
  • Fixed bug causing segmentation faults (mostly for Ubuntu users) - when various commands are run -
  • Fixed bug so that task now will recreate a missing ~/.taskrc file, - OR a missing ~/.task directory +
  • Added "task undelete" feature to restore a (very) recently deleted + task

@@ -487,6 +478,18 @@ Car 2 2 wks 25% XXXXXXXXX delete them.

+ % 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>

This is how a task is marked as done. @@ -1051,6 +1054,7 @@ on_white on_bright_white task ID [tags] [attrs] [desc...] task ID /from/to/ task delete ID + task undelete ID task info ID task start ID task done ID diff --git a/html/versions.html b/html/versions.html index f29d1f039..630e0331f 100644 --- a/html/versions.html +++ b/html/versions.html @@ -21,6 +21,25 @@

+

+

New in version 1.3.1

+ Source: task-1.3.1.tar.gz +
+ Debian package: task_1.3.1-1_i386.deb + (Thanks to Richard Querin) +

+ +
    +
  • New configuration variable "defaultwidth" determines the width + of windows in the absense of ncurses support +
  • Fixed bug where "showage" configuration variable was not being + oberved by the "task long" report +
  • Fixed bug causing segmentation faults (mostly for Ubuntu users) + when various commands are run +
  • Fixed bug so that task now will recreate a missing ~/.taskrc file, + OR a missing ~/.task directory +
+

New in version 1.3.0

Source: task-1.3.0.tar.gz diff --git a/src/parse.cpp b/src/parse.cpp index 14ca932e1..111921b35 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -135,6 +135,7 @@ static const char* commands[] = "stats", "summary", "tags", + "undelete", "usage", "version", "", diff --git a/src/task.cpp b/src/task.cpp index da33b5858..cfbad7379 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -108,6 +108,10 @@ void shortUsage (Config& conf) table.addCell (row, 1, "task delete ID"); 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 (); table.addCell (row, 1, "task info ID"); 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 == "list") handleList (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 == "ls") handleSmallList (tdb, task, 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; } +//////////////////////////////////////////////////////////////////////////////// +// 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 all; + tdb.allPendingT (all); + + int id = task.getId (); + std::vector ::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 // line. Tasks that match all the specified criteria are listed. diff --git a/src/task.h b/src/task.h index 543279837..a400e0ed7 100644 --- a/src/task.h +++ b/src/task.h @@ -62,6 +62,7 @@ void handleProjects (const TDB&, T&, Config&); void handleTags (const TDB&, T&, Config&); void handleList (const TDB&, T&, Config&); void handleInfo (const TDB&, T&, Config&); +void handleUndelete (const TDB&, T&, Config&); void handleLongList (const TDB&, T&, Config&); void handleSmallList (const TDB&, T&, Config&); void handleCompleted (const TDB&, T&, Config&);