mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Rename replica.gc to replica.rebuild_working_set
The command-line operation is still `gc`, but we'll break that down into finer pieces in the replica.
This commit is contained in:
parent
da63d77d9d
commit
b62370c150
4 changed files with 9 additions and 8 deletions
|
@ -3,7 +3,8 @@ use taskchampion::Replica;
|
|||
use termcolor::WriteColor;
|
||||
|
||||
pub(crate) fn execute<W: WriteColor>(w: &mut W, replica: &mut Replica) -> Fallible<()> {
|
||||
replica.gc()?;
|
||||
log::debug!("rebuilding working set");
|
||||
replica.rebuild_working_set()?;
|
||||
writeln!(w, "garbage collected.")?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ mod test {
|
|||
let t1 = replica.new_task(Status::Pending, s!("A")).unwrap();
|
||||
let t2 = replica.new_task(Status::Completed, s!("B")).unwrap();
|
||||
let _t = replica.new_task(Status::Pending, s!("C")).unwrap();
|
||||
replica.gc().unwrap();
|
||||
replica.rebuild_working_set().unwrap();
|
||||
|
||||
let t1uuid = *t1.get_uuid();
|
||||
|
||||
|
@ -210,7 +210,7 @@ mod test {
|
|||
let t1 = replica.new_task(Status::Pending, s!("A")).unwrap();
|
||||
let t2 = replica.new_task(Status::Completed, s!("B")).unwrap();
|
||||
let _t = replica.new_task(Status::Pending, s!("C")).unwrap();
|
||||
replica.gc().unwrap();
|
||||
replica.rebuild_working_set().unwrap();
|
||||
|
||||
let t1uuid = *t1.get_uuid();
|
||||
let t2uuid = t2.get_uuid().to_string();
|
||||
|
@ -238,7 +238,7 @@ mod test {
|
|||
replica.new_task(Status::Pending, s!("A")).unwrap();
|
||||
replica.new_task(Status::Completed, s!("B")).unwrap();
|
||||
replica.new_task(Status::Deleted, s!("C")).unwrap();
|
||||
replica.gc().unwrap();
|
||||
replica.rebuild_working_set().unwrap();
|
||||
|
||||
let filter = Filter { conditions: vec![] };
|
||||
let mut filtered: Vec<_> = filtered_tasks(&mut replica, &filter)
|
||||
|
@ -309,7 +309,7 @@ mod test {
|
|||
replica.new_task(Status::Pending, s!("A")).unwrap();
|
||||
replica.new_task(Status::Completed, s!("B")).unwrap();
|
||||
replica.new_task(Status::Deleted, s!("C")).unwrap();
|
||||
replica.gc().unwrap();
|
||||
replica.rebuild_working_set().unwrap();
|
||||
|
||||
let filter = Filter {
|
||||
conditions: vec![Condition::Status(Status::Pending)],
|
||||
|
|
|
@ -163,7 +163,7 @@ mod test {
|
|||
t2.set_status(Status::Completed).unwrap();
|
||||
let t2 = t2.into_immut();
|
||||
|
||||
replica.gc().unwrap();
|
||||
replica.rebuild_working_set().unwrap();
|
||||
|
||||
[*t1.get_uuid(), *t2.get_uuid(), *t3.get_uuid()]
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ impl Replica {
|
|||
|
||||
/// Perform "garbage collection" on this replica. In particular, this renumbers the working
|
||||
/// set to contain only pending tasks.
|
||||
pub fn gc(&mut self) -> Fallible<()> {
|
||||
pub fn rebuild_working_set(&mut self) -> Fallible<()> {
|
||||
let pending = String::from(Status::Pending.to_taskmap());
|
||||
self.taskdb
|
||||
.rebuild_working_set(|t| t.get("status") == Some(&pending))?;
|
||||
|
@ -251,7 +251,7 @@ mod tests {
|
|||
assert_eq!(t.get_status(), Status::Deleted);
|
||||
assert_eq!(t.get_description(), "gone");
|
||||
|
||||
rep.gc().unwrap();
|
||||
rep.rebuild_working_set().unwrap();
|
||||
|
||||
assert!(rep.get_working_set_index(t.get_uuid()).unwrap().is_none());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue