diff --git a/src/command.cpp b/src/command.cpp index da2277450..76af86638 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -532,7 +532,8 @@ std::string handleDelete () std::vector tasks; context.tdb.lock (context.config.get ("locking", true)); handleRecurrence (); - context.tdb.loadPending (tasks, context.filter); + Filter filter; + context.tdb.loadPending (tasks, filter); // Filter sequence. std::vector all = tasks; @@ -631,7 +632,8 @@ std::string handleStart () std::vector tasks; context.tdb.lock (context.config.get ("locking", true)); handleRecurrence (); - context.tdb.loadPending (tasks, context.filter); + Filter filter; + context.tdb.loadPending (tasks, filter); // Filter sequence. context.filter.applySequence (tasks, context.sequence); @@ -682,7 +684,8 @@ std::string handleStop () std::vector tasks; context.tdb.lock (context.config.get ("locking", true)); handleRecurrence (); - context.tdb.loadPending (tasks, context.filter); + Filter filter; + context.tdb.loadPending (tasks, filter); // Filter sequence. context.filter.applySequence (tasks, context.sequence); @@ -728,7 +731,8 @@ std::string handleDone () std::vector tasks; context.tdb.lock (context.config.get ("locking", true)); handleRecurrence (); - context.tdb.loadPending (tasks, context.filter); + Filter filter; + context.tdb.loadPending (tasks, filter); // Filter sequence. std::vector all = tasks; @@ -858,7 +862,8 @@ std::string handleModify () std::vector tasks; context.tdb.lock (context.config.get ("locking", true)); handleRecurrence (); - context.tdb.loadPending (tasks, context.filter); + Filter filter; + context.tdb.loadPending (tasks, filter); // Filter sequence. std::vector all = tasks; @@ -907,7 +912,7 @@ std::string handleModify () if (taskDiff (before, *other)) { - if (changes && permission.confirmed (before, taskDifferences (before, *task) + "Are you sure?")) + if (changes && permission.confirmed (before, taskDifferences (before, *other) + "Are you sure?")) { context.tdb.update (*other); ++count; @@ -935,7 +940,8 @@ std::string handleAppend () std::vector tasks; context.tdb.lock (context.config.get ("locking", true)); handleRecurrence (); - context.tdb.loadPending (tasks, context.filter); + Filter filter; + context.tdb.loadPending (tasks, filter); // Filter sequence. std::vector all = tasks; @@ -966,7 +972,7 @@ std::string handleAppend () if (taskDiff (before, *other)) { - if (changes && permission.confirmed (before, taskDifferences (before, *task) + "Are you sure?")) + if (changes && permission.confirmed (before, taskDifferences (before, *other) + "Are you sure?")) { context.tdb.update (*other); @@ -1001,7 +1007,8 @@ std::string handleDuplicate () std::vector tasks; context.tdb.lock (context.config.get ("locking", true)); - context.tdb.loadPending (tasks, context.filter); + Filter filter; + context.tdb.loadPending (tasks, filter); // Filter sequence. context.filter.applySequence (tasks, context.sequence); @@ -1235,7 +1242,8 @@ std::string handleAnnotate () std::vector tasks; context.tdb.lock (context.config.get ("locking", true)); - context.tdb.loadPending (tasks, context.filter); + Filter filter; + context.tdb.loadPending (tasks, filter); // Filter sequence. context.filter.applySequence (tasks, context.sequence); diff --git a/src/tests/bug.bulk.t b/src/tests/bug.bulk.t new file mode 100755 index 000000000..2016abc13 --- /dev/null +++ b/src/tests/bug.bulk.t @@ -0,0 +1,86 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 14; + +# Create the rc file. +if (open my $fh, '>', 'bulk.rc') +{ + print $fh "data.location=.\n", + "confirmation=yes\n", + "bulk=2\n"; + close $fh; + ok (-r 'bulk.rc', 'Created bulk.rc'); +} + +# Add some tasks with project, prioriy and due date, some with only due date. +# Bulk add a project and priority to the tasks that were without. +qx{../task rc:bulk.rc add t1 pro:p1 pri:H due:monday}; +qx{../task rc:bulk.rc add t2 pro:p1 pri:M due:tuesday}; +qx{../task rc:bulk.rc add t3 pro:p1 pri:L due:wednesday}; +qx{../task rc:bulk.rc add t4 due:thursday}; +qx{../task rc:bulk.rc add t5 due:friday}; +qx{../task rc:bulk.rc add t6 due:saturday}; + +my $output = qx{yes|../task rc:bulk.rc pro:p1 pri:M 4 5 6}; +unlike ($output, qr/Task 4 "t4"\n - No changes were made/, 'Task 4 modified'); +unlike ($output, qr/Task 5 "t5"\n - No changes were made/, 'Task 5 modified'); +unlike ($output, qr/Task 6 "t6"\n - No changes were made/, 'Task 6 modified'); +#diag ("---"); +#diag ($output); +#diag ("---"); + +$output = qx{../task rc:bulk.rc info 4}; +like ($output, qr/Project\s+p1/, 'project applied to 4'); +like ($output, qr/Priority\s+M/, 'priority applied to 4'); + +$output = qx{../task rc:bulk.rc info 5}; +like ($output, qr/Project\s+p1/, 'project applied to 5'); +like ($output, qr/Priority\s+M/, 'priority applied to 5'); + +$output = qx{../task rc:bulk.rc info 6}; +like ($output, qr/Project\s+p1/, 'project applied to 6'); +like ($output, qr/Priority\s+M/, 'priority applied to 6'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'completed.data'; +ok (!-r 'completed.data', 'Removed completed.data'); + +unlink 'undo.data'; +ok (!-r 'undo.data', 'Removed undo.data'); + +unlink 'bulk.rc'; +ok (!-r 'bulk.rc', 'Removed bulk.rc'); + +exit 0; +