Skip to content

Commit 5d84093

Browse files
committed
Fixed regression: dep id listing with gc off; test added
Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
1 parent 909ebcf commit 5d84093

3 files changed

Lines changed: 27 additions & 30 deletions

File tree

src/Task.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,11 +1049,18 @@ bool Task::hasDependency(const std::string& uuid) const {
10491049
////////////////////////////////////////////////////////////////////////////////
10501050
std::vector<int> Task::getDependencyIDs() const {
10511051
std::vector<int> ids;
1052-
for (auto& attr : all()) {
1053-
if (!isDepAttr(attr)) continue;
1054-
auto dep = attr2Dep(attr);
1055-
ids.push_back(Context::getContext().tdb2.id(dep));
1056-
}
1052+
1053+
const auto& graph = Context::getContext().tdb2.dependency_graph();
1054+
auto found = graph.dependencies.find(get_ref("uuid"));
1055+
if (found == graph.dependencies.end()) return ids;
1056+
1057+
const auto& tasks = Context::getContext().tdb2.pending_tasks();
1058+
ids.reserve(found->second.size());
1059+
for (auto idx : found->second)
1060+
if (tasks[idx].getStatus() != Task::completed && tasks[idx].getStatus() != Task::deleted)
1061+
ids.push_back(tasks[idx].id);
1062+
1063+
std::sort(ids.begin(), ids.end());
10571064

10581065
return ids;
10591066
}

src/columns/ColDepends.cpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,7 @@ void ColumnDepends::measure(const Task& task, unsigned int& minimum, unsigned in
7676
return;
7777
}
7878

79-
// We also don't need to call getDependencyTasks(),
80-
// which would copy the full objects from the cache just to read the ID
81-
// field. Instead, we can use getDependencyUUIDs() and tdb2.id().
82-
83-
auto dep_uuids = task.getDependencyUUIDs();
84-
85-
std::vector<int> blocking_ids;
86-
blocking_ids.reserve(dep_uuids.size());
87-
for (const auto& uuid : dep_uuids) {
88-
int id = Context::getContext().tdb2.id(uuid);
89-
if (id > 0) blocking_ids.push_back(id);
90-
}
91-
92-
std::sort(blocking_ids.begin(), blocking_ids.end());
79+
auto blocking_ids = task.getDependencyIDs();
9380

9481
if (blocking_ids.size() > 0) {
9582
if (_style == "count") {
@@ -121,17 +108,7 @@ void ColumnDepends::render(std::vector<std::string>& lines, const Task& task, in
121108
return;
122109
}
123110

124-
// We use the same approach to look up UUIDs as for measure().
125-
auto dep_uuids = task.getDependencyUUIDs();
126-
127-
std::vector<int> blocking_ids;
128-
blocking_ids.reserve(dep_uuids.size());
129-
for (const auto& uuid : dep_uuids) {
130-
int id = Context::getContext().tdb2.id(uuid);
131-
if (id > 0) blocking_ids.push_back(id);
132-
}
133-
134-
std::sort(blocking_ids.begin(), blocking_ids.end());
111+
auto blocking_ids = task.getDependencyIDs();
135112

136113
if (blocking_ids.size() > 0) {
137114
if (_style == "count") {

test/dependencies.test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ def test_circular_5(self):
8787
code, out, err = self.t.runError("1 modify dep:5")
8888
self.assertIn("Circular dependency detected and disallowed.", err)
8989

90+
def test_completed_dependency_is_not_rendered(self):
91+
"""Completed dependencies should not be listed even if working set is stale"""
92+
self.t("2 modify dep:1")
93+
self.t("1 done rc.gc=off")
94+
95+
self.assertIn("depends", self.t.export_one("rc.gc=off 2"))
96+
code, out, err = self.t(
97+
"2 list rc.gc=off rc.report.list.columns=id,depends "
98+
"rc.report.list.labels=ID,Depends"
99+
)
100+
101+
self.assertIn(["2"], [line.split() for line in out.splitlines()])
102+
90103
def test_dag(self):
91104
"""Check acyclic graph support"""
92105
self.t("add three")

0 commit comments

Comments
 (0)