check all subdependencies when listing for no dependencies
This commit is contained in:
parent
bc861c52f2
commit
5bb20e6166
15
src/graph.rs
15
src/graph.rs
@ -105,6 +105,21 @@ impl Graph {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Traverses a notes dependencies to get the set of all dependencies, direct and indirect.
|
||||||
|
pub fn get_nested_deps(&self, id : Id) -> HashSet<Id> {
|
||||||
|
fn helper(graph : &Graph, curr : &Id, output : &mut HashSet<Id>) {
|
||||||
|
for dep in graph.edges.get(curr).unwrap() {
|
||||||
|
output.insert(*dep);
|
||||||
|
helper(graph, dep, output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut output = HashSet::new();
|
||||||
|
helper(self, &id, &mut output);
|
||||||
|
|
||||||
|
output
|
||||||
|
}
|
||||||
|
|
||||||
fn find_cycle_local(&self, start : Id, unvisited : &mut BTreeSet<Id>, current_path_visited : &mut HashSet<Id>) -> Option<Vec<Id>> {
|
fn find_cycle_local(&self, start : Id, unvisited : &mut BTreeSet<Id>, current_path_visited : &mut HashSet<Id>) -> Option<Vec<Id>> {
|
||||||
|
|
||||||
// If already visited in the current path, then there is a cycle
|
// If already visited in the current path, then there is a cycle
|
||||||
|
@ -7,7 +7,7 @@ use crate::tasks::Id;
|
|||||||
|
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::path;
|
use std::path;
|
||||||
use std::collections::{HashSet, HashMap};
|
use std::collections::HashSet;
|
||||||
use chrono::SubsecRound;
|
use chrono::SubsecRound;
|
||||||
|
|
||||||
impl args::ListOptions {
|
impl args::ListOptions {
|
||||||
@ -128,10 +128,13 @@ pub fn list(mut options : args::ListOptions, vault_folder : &path::Path, state :
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks that a task has no incomplete dependencies (these dependencies are direct only).
|
// Checks that a task has no incomplete dependencies.
|
||||||
if options.no_dependencies {
|
if options.no_dependencies {
|
||||||
tasks = Box::new(tasks.filter(move |t| {
|
tasks = Box::new(tasks.filter(move |t| {
|
||||||
t.data.dependencies.iter().all(|d| completed_ids.contains(&d))
|
// Get all dependencies (including indirect ones).
|
||||||
|
let all_dependencies = state.data.deps.get_nested_deps(t.data.id);
|
||||||
|
// Check that all of those dependencies are completed.
|
||||||
|
all_dependencies.iter().all(|d| completed_ids.contains(&d))
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user