- Simplified dependency modification hnadling.
This commit is contained in:
Paul Beckingham 2014-06-26 23:55:50 -04:00
parent e688176310
commit 9dd7acac0b
2 changed files with 19 additions and 35 deletions

View file

@ -1979,30 +1979,20 @@ void Task::modify (modType type, bool text_required /* = false */)
std::vector <std::string>::iterator i;
for (i = deps.begin (); i != deps.end (); i++)
{
bool removal = false;
std::string& dep = *i;
if (dep[0] == '-')
if ((*i)[0] == '-')
{
removal = true;
dep = i->substr(1, std::string::npos);
}
// Crude UUID check
// TODO Support partial UUIDs.
// TODO Do not assume that <36 characaters implies integer.
std::vector <int> ids;
if (dep.length () == 36)
ids.push_back (context.tdb2.pending.id (dep));
else
ids.push_back (strtol ((*i).c_str (), NULL, 10));
std::vector <int>::iterator id;
for (id = ids.begin (); id != ids.end(); id++)
if (removal)
removeDependency (*id);
if ((*i).length () == 37)
removeDependency (context.tdb2.pending.id ((*i).substr (1)));
else
addDependency (*id);
removeDependency (strtol ((*i).substr (1).c_str (), NULL, 10));
}
else
{
if ((*i).length () == 36)
addDependency (context.tdb2.pending.id ((*i)));
else
addDependency (strtol ((*i).c_str (), NULL, 10));
}
}
++modCount;

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 47;
use Test::More tests => 41;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -94,7 +94,6 @@ like ($output, qr/Modified 1 task\./, 'dependencie
# [16]
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data for a fresh start');
qx{../src/task rc:dep.rc add One 2>&1};
qx{../src/task rc:dep.rc add Two 2>&1};
@ -111,7 +110,6 @@ unlike ($output, qr/Modified 1 task\./, 'dependencie
# [19]
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data for a fresh start');
qx{../src/task rc:dep.rc add One 2>&1};
qx{../src/task rc:dep.rc add Two 2>&1};
@ -144,7 +142,6 @@ like ($output, qr/\s1\s+One\s+/, 'dependencies - depends report column reflects
# [26]
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data for a fresh start');
qx{../src/task rc:dep.rc add One 2>&1};
qx{../src/task rc:dep.rc add Two 2>&1};
@ -165,7 +162,6 @@ like ($output, qr/\s1\s+2\s+One\s+/, 'dependencies - depends report column refle
# [29]
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data for a fresh start');
qx{../src/task rc:dep.rc add One 2>&1};
qx{../src/task rc:dep.rc add Two 2>&1};
@ -189,7 +185,6 @@ unlike ($output, qr/fixed/, 'dependencies - user not prompted to fix broken chai
# [34]
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data for a fresh start');
qx{../src/task rc:dep.rc add One 2>&1};
qx{../src/task rc:dep.rc add Two 2>&1};
@ -219,7 +214,6 @@ like ($output, qr/\s1\s+One\s*\n\s2\s+Four\s*\n\s3\s+2\s+Five/, 'dependencies -
# [38]
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data for a fresh start');
# Bug when adding a range of dependencies - 'task 3 mod dep:1-2' interprets the
# range 1-2 as the id 1
@ -229,11 +223,11 @@ qx{../src/task rc:dep.rc add test2 2>&1};
qx{../src/task rc:dep.rc add test3 2>&1};
qx{../src/task rc:dep.rc add test4 2>&1};
qx{../src/task rc:dep.rc add test5 2>&1};
$output = qx{../src/task rc:dep.rc 5 info 2>&1};
my ($uuid) = $output =~ /UUID\s+(\S+)/;
my $uuid = qx{../src/task rc:dep.rc _get 5.uuid};
chomp $uuid;
# [39-43] test a comma-separated list of IDs, UUIDs, and ID ranges for creation
qx{../src/task rc:dep.rc add test6 dep:1-3,4,$uuid 2>&1};
# [38-42] test a comma-separated list of IDs, UUIDs, and ID ranges for creation
qx{../src/task rc:dep.rc add test6 dep:1,2,3,4,$uuid 2>&1};
$output = qx{../src/task rc:dep.rc 6 info 2>&1};
like ($output, qr/test1/ms, 'Dependency appearing for task1');
like ($output, qr/test2/ms, 'Dependency appearing for task2');
@ -241,8 +235,8 @@ like ($output, qr/test3/ms, 'Dependency appearing for task3');
like ($output, qr/test4/ms, 'Dependency appearing for task4');
like ($output, qr/test5/ms, 'Dependency appearing for task5');
# [44-48] test a comma-separated list of IDs, UUIDs, and ID ranges for deletion
qx{../src/task rc:dep.rc 6 mod dep:-1-3,-4,-$uuid 2>&1};
# [43-47] test a comma-separated list of IDs, UUIDs, and ID ranges for deletion
qx{../src/task rc:dep.rc 6 mod dep:-1,-2,-3,-4,-$uuid 2>&1};
$output = qx{../src/task rc:dep.rc 6 info 2>&1};
unlike ($output, qr/test1/ms, 'Dependency not appearing for task1');
unlike ($output, qr/test2/ms, 'Dependency not appearing for task2');