From 160260ff48c3a418d7f7c244e11782821107819b Mon Sep 17 00:00:00 2001 From: Louis-Claude Canon Date: Tue, 3 Jul 2012 17:33:21 +0200 Subject: [PATCH] Code Cleanup - Remove duplicate modify call to TDB2. - Check if quitting in bulk change only if permission fails. - Correct test logic (the unit for each operation is the second, not the day). - Consistency in test for feature.1013.t - Correctly color deleted tasks. test --- src/commands/CmdAnnotate.cpp | 6 +++--- src/commands/CmdAppend.cpp | 6 +++--- src/commands/CmdDelete.cpp | 6 +++--- src/commands/CmdDenotate.cpp | 6 +++--- src/commands/CmdDone.cpp | 7 +++---- src/commands/CmdDuplicate.cpp | 6 +++--- src/commands/CmdModify.cpp | 6 +++--- src/commands/CmdPrepend.cpp | 6 +++--- src/commands/CmdStart.cpp | 6 +++--- src/commands/CmdStop.cpp | 6 +++--- src/rules.cpp | 2 +- test/date.t.cpp | 4 ++-- test/feature.1013.t | 2 +- 13 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/commands/CmdAnnotate.cpp b/src/commands/CmdAnnotate.cpp index 91a82e735..b333ae158 100644 --- a/src/commands/CmdAnnotate.cpp +++ b/src/commands/CmdAnnotate.cpp @@ -117,10 +117,10 @@ int CmdAnnotate::execute (std::string& output) else { std::cout << STRING_CMD_ANNO_NO << "\n"; - rc = 1; + rc = 1; + if (_permission_quit) + break; } - if (_permission_quit) - break; } // Now list the project changes. diff --git a/src/commands/CmdAppend.cpp b/src/commands/CmdAppend.cpp index 4e9c8c670..6e3fd0fef 100644 --- a/src/commands/CmdAppend.cpp +++ b/src/commands/CmdAppend.cpp @@ -117,10 +117,10 @@ int CmdAppend::execute (std::string& output) else { std::cout << STRING_CMD_APPEND_NO << "\n"; - rc = 1; + rc = 1; + if (_permission_quit) + break; } - if (_permission_quit) - break; } // Now list the project changes. diff --git a/src/commands/CmdDelete.cpp b/src/commands/CmdDelete.cpp index 79405d1b7..4f5ed191a 100644 --- a/src/commands/CmdDelete.cpp +++ b/src/commands/CmdDelete.cpp @@ -141,10 +141,10 @@ int CmdDelete::execute (std::string& output) else { std::cout << STRING_CMD_DELETE_NO << "\n"; - rc = 1; + rc = 1; + if (_permission_quit) + break; } - if (_permission_quit) - break; } else { diff --git a/src/commands/CmdDenotate.cpp b/src/commands/CmdDenotate.cpp index 8e99acdbb..760f8b36b 100644 --- a/src/commands/CmdDenotate.cpp +++ b/src/commands/CmdDenotate.cpp @@ -130,10 +130,10 @@ int CmdDenotate::execute (std::string& output) else { std::cout << STRING_CMD_DENO_NO << "\n"; - rc = 1; + rc = 1; + if (_permission_quit) + break; } - if (_permission_quit) - break; } else { diff --git a/src/commands/CmdDone.cpp b/src/commands/CmdDone.cpp index 965c3a3bf..4a06edf2d 100644 --- a/src/commands/CmdDone.cpp +++ b/src/commands/CmdDone.cpp @@ -99,7 +99,6 @@ int CmdDone::execute (std::string& output) ++count; feedback_affected (STRING_CMD_DONE_TASK, *task); feedback_unblocked (*task); - context.tdb2.modify (*task); if (!nagged) nagged = nag (*task); dependencyChainOnComplete (*task); @@ -109,10 +108,10 @@ int CmdDone::execute (std::string& output) else { std::cout << STRING_CMD_DONE_NO << "\n"; - rc = 1; + rc = 1; + if (_permission_quit) + break; } - if (_permission_quit) - break; } else { diff --git a/src/commands/CmdDuplicate.cpp b/src/commands/CmdDuplicate.cpp index 7be9ddbb2..c40c06741 100644 --- a/src/commands/CmdDuplicate.cpp +++ b/src/commands/CmdDuplicate.cpp @@ -123,10 +123,10 @@ int CmdDuplicate::execute (std::string& output) else { std::cout << STRING_CMD_DUPLICATE_NO << "\n"; - rc = 1; + rc = 1; + if (_permission_quit) + break; } - if (_permission_quit) - break; } // Now list the project changes. diff --git a/src/commands/CmdModify.cpp b/src/commands/CmdModify.cpp index 32c03add5..d17adc956 100644 --- a/src/commands/CmdModify.cpp +++ b/src/commands/CmdModify.cpp @@ -160,10 +160,10 @@ int CmdModify::execute (std::string& output) else { std::cout << STRING_CMD_MODIFY_NO << "\n"; - rc = 1; + rc = 1; + if (_permission_quit) + break; } - if (_permission_quit) - break; } } diff --git a/src/commands/CmdPrepend.cpp b/src/commands/CmdPrepend.cpp index 50eac72da..d63e439f0 100644 --- a/src/commands/CmdPrepend.cpp +++ b/src/commands/CmdPrepend.cpp @@ -117,10 +117,10 @@ int CmdPrepend::execute (std::string& output) else { std::cout << STRING_CMD_PREPEND_NO << "\n"; - rc = 1; + rc = 1; + if (_permission_quit) + break; } - if (_permission_quit) - break; } // Now list the project changes. diff --git a/src/commands/CmdStart.cpp b/src/commands/CmdStart.cpp index 5789b6342..0886282cc 100644 --- a/src/commands/CmdStart.cpp +++ b/src/commands/CmdStart.cpp @@ -102,10 +102,10 @@ int CmdStart::execute (std::string& output) else { std::cout << STRING_CMD_START_NO << "\n"; - rc = 1; + rc = 1; + if (_permission_quit) + break; } - if (_permission_quit) - break; } else { diff --git a/src/commands/CmdStop.cpp b/src/commands/CmdStop.cpp index 857309a0b..e736da72e 100644 --- a/src/commands/CmdStop.cpp +++ b/src/commands/CmdStop.cpp @@ -98,10 +98,10 @@ int CmdStop::execute (std::string& output) else { std::cout << STRING_CMD_STOP_NO << "\n"; - rc = 1; + rc = 1; + if (_permission_quit) + break; } - if (_permission_quit) - break; } else { diff --git a/src/rules.cpp b/src/rules.cpp index 8bcf7e543..59d13f6f2 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -273,7 +273,7 @@ static void colorizeCompleted (Task& task, const Color& base, Color& c) //////////////////////////////////////////////////////////////////////////////// static void colorizeDeleted (Task& task, const Color& base, Color& c) { - if (task.getStatus () == Task::completed) + if (task.getStatus () == Task::deleted) c.blend (base); } diff --git a/test/date.t.cpp b/test/date.t.cpp index 1d1c7228a..a751a856d 100644 --- a/test/date.t.cpp +++ b/test/date.t.cpp @@ -41,7 +41,7 @@ int main (int argc, char** argv) { Date now; Date yesterday; - yesterday -= 1; + yesterday -= 86400; t.ok (yesterday <= now, "yesterday <= now"); t.ok (yesterday < now, "yesterday < now"); @@ -140,7 +140,7 @@ int main (int argc, char** argv) t.is (happyNewYear.day (), 1, "1/1/2008 == 1"); t.is (happyNewYear.year (), 2008, "1/1/2008 == 2008"); - t.is (now - yesterday, 1, "today - yesterday == 1"); + t.is (now - yesterday, 86400, "today - yesterday == 1"); t.is (happyNewYear.toString (), "1/1/2008", "toString 1/1/2008"); diff --git a/test/feature.1013.t b/test/feature.1013.t index 2ed72c24b..c4644afda 100755 --- a/test/feature.1013.t +++ b/test/feature.1013.t @@ -61,7 +61,7 @@ like ($stderr, qr/^Configuration override rc.debug:on$/ms, 'Footnotes are sent t # Check that debugs are sent to standard error $stdout = qx{../src/task rc:outerr.rc rc.debug:on list 2> /dev/null}; -unlike ($stdout, qr/^Perf task /ms, 'Debugs are not sent to stdout'); +unlike ($stdout, qr/^Timer Config::load \(outerr.rc\) /ms, 'Debugs are not sent to stdout'); $stderr = qx{../src/task rc:outerr.rc rc.debug:on list 2>&1 >/dev/null}; like ($stderr, qr/^Timer Config::load \(outerr.rc\) /ms, 'Debugs are sent to stderr');