- Fixed bug that caused dependencies to be sorted by UUID, although
  they are shown as IDs.
- Updated unit test to accomodate new comma-less formatting of
  dependencies.
This commit is contained in:
Paul Beckingham
2011-05-13 18:05:26 -04:00
parent 4f8c503a04
commit 1d10370341
3 changed files with 31 additions and 3 deletions

View File

@@ -25,6 +25,7 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream> // TODO Remove
#include <algorithm>
#include <vector>
#include <string>
@@ -99,9 +100,37 @@ static bool sort_compare (int left, int right)
return left_number > right_number;
}
// Depends string.
else if (field == "depends")
{
// Raw data is a comma-separated list of uuids
left_string = (*global_data)[left].get (field);
right_string = (*global_data)[right].get (field);
if (left_string == right_string)
continue;
if (left_string == "" && right_string != "")
return ascending;
if (left_string != "" && right_string == "")
return !ascending;
// Sort on the first dependency.
left_number = context.tdb.id (left_string.substr (0, 36));
right_number = context.tdb.id (right_string.substr (0, 36));
if (left_number == right_number)
continue;
if (ascending)
return left_number < right_number;
return left_number > right_number;
}
// String.
else if (field == "description" ||
field == "depends" ||
field == "project" ||
field == "status" ||
field == "tags" ||