From 805046cebaf44d9a0c0be14a58a42aa3efd967cc Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 10 Jan 2024 19:45:26 +0900 Subject: [PATCH] op_walk: extract function that resolves op expression with preloaded head op I'm going to make "op abandon" not load the repo, and this function will be used there instead of resolve_op_with_repo(). --- lib/src/op_walk.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/src/op_walk.rs b/lib/src/op_walk.rs index 4a6a3f2cd..3241f1163 100644 --- a/lib/src/op_walk.rs +++ b/lib/src/op_walk.rs @@ -89,9 +89,17 @@ pub fn resolve_op_with_repo( repo: &ReadonlyRepo, op_str: &str, ) -> Result { - let op_store = repo.op_store(); - let get_current_op = || Ok(repo.operation().clone()); - let get_head_ops = || Ok(vec![repo.operation().clone()]); + resolve_op_at(repo.op_store(), repo.operation(), op_str) +} + +/// Resolves operation set expression at the given head operation. +pub fn resolve_op_at( + op_store: &Arc, + head_op: &Operation, + op_str: &str, +) -> Result { + let get_current_op = || Ok(head_op.clone()); + let get_head_ops = || Ok(vec![head_op.clone()]); resolve_single_op(op_store, get_current_op, get_head_ops, op_str) }