mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 00:44:33 +00:00
store: make write_commit()
async
This just propagates the async a little bit futher where it's easy to do so.
This commit is contained in:
parent
8eb3d85b1c
commit
3136426dd6
4 changed files with 11 additions and 5 deletions
|
@ -16,6 +16,8 @@
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use pollster::FutureExt;
|
||||
|
||||
use crate::backend;
|
||||
use crate::backend::BackendResult;
|
||||
use crate::backend::ChangeId;
|
||||
|
@ -341,5 +343,7 @@ fn write_to_store(
|
|||
// if we're rewriting a signed commit
|
||||
commit.secure_sig = None;
|
||||
|
||||
store.write_commit(commit, should_sign.then_some(&mut &sign_fn))
|
||||
store
|
||||
.write_commit(commit, should_sign.then_some(&mut &sign_fn))
|
||||
.block_on()
|
||||
}
|
||||
|
|
|
@ -153,14 +153,14 @@ impl Store {
|
|||
Ok(data)
|
||||
}
|
||||
|
||||
pub fn write_commit(
|
||||
pub async fn write_commit(
|
||||
self: &Arc<Self>,
|
||||
commit: backend::Commit,
|
||||
sign_with: Option<&mut SigningFn>,
|
||||
sign_with: Option<&mut SigningFn<'_>>,
|
||||
) -> BackendResult<Commit> {
|
||||
assert!(!commit.parents.is_empty());
|
||||
|
||||
let (commit_id, commit) = self.backend.write_commit(commit, sign_with).block_on()?;
|
||||
let (commit_id, commit) = self.backend.write_commit(commit, sign_with).await?;
|
||||
let data = Arc::new(commit);
|
||||
{
|
||||
let mut locked_cache = self.commit_cache.lock().unwrap();
|
||||
|
|
|
@ -22,5 +22,6 @@ git2 = { workspace = true }
|
|||
hex = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
jj-lib = { workspace = true, features = ["testing"] }
|
||||
pollster = { workspace = true }
|
||||
rand = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
|
|
|
@ -58,6 +58,7 @@ use jj_lib::tree_builder::TreeBuilder;
|
|||
use jj_lib::working_copy::SnapshotError;
|
||||
use jj_lib::working_copy::SnapshotOptions;
|
||||
use jj_lib::workspace::Workspace;
|
||||
use pollster::FutureExt;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::test_backend::TestBackend;
|
||||
|
@ -387,7 +388,7 @@ pub fn commit_with_tree(store: &Arc<Store>, tree_id: MergedTreeId) -> Commit {
|
|||
committer: signature,
|
||||
secure_sig: None,
|
||||
};
|
||||
store.write_commit(commit, None).unwrap()
|
||||
store.write_commit(commit, None).block_on().unwrap()
|
||||
}
|
||||
|
||||
pub fn dump_tree(store: &Arc<Store>, tree_id: &MergedTreeId) -> String {
|
||||
|
|
Loading…
Reference in a new issue