cob: Don't require full `Entry` for update
Instead of taking the full entry type, we only need the id.
This commit is contained in:
parent
c903a958e7
commit
6695074479
|
|
@ -77,7 +77,7 @@ mod change_graph;
|
|||
mod trailers;
|
||||
|
||||
pub mod change;
|
||||
pub use change::store::{Contents, Embed, Manifest, Version};
|
||||
pub use change::store::{Contents, Embed, EntryId, Manifest, Version};
|
||||
pub use change::Entry;
|
||||
|
||||
pub mod history;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ where
|
|||
let object_id = init_change.id().into();
|
||||
|
||||
storage
|
||||
.update(identifier, &type_name, &object_id, &init_change)
|
||||
.update(identifier, &type_name, &object_id, &init_change.id)
|
||||
.map_err(|err| error::Create::Refs { err: Box::new(err) })?;
|
||||
|
||||
let history = History::new_from_root(init_change);
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ where
|
|||
)?;
|
||||
|
||||
storage
|
||||
.update(identifier, typename, &object_id, &change)
|
||||
.update(identifier, typename, &object_id, &change.id)
|
||||
.map_err(|err| error::Update::Refs { err: Box::new(err) })?;
|
||||
|
||||
let parents = change.parents.to_vec();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::{collections::BTreeMap, error::Error};
|
|||
use git_ext::ref_format::RefString;
|
||||
use git_ext::Oid;
|
||||
|
||||
use crate::change::Entry;
|
||||
use crate::change::EntryId;
|
||||
use crate::{ObjectId, TypeName};
|
||||
|
||||
/// The [`Reference`]s that refer to the commits that make up a
|
||||
|
|
@ -78,7 +78,7 @@ pub trait Storage {
|
|||
identifier: &Self::Identifier,
|
||||
typename: &TypeName,
|
||||
object_id: &ObjectId,
|
||||
change: &Entry,
|
||||
entry: &EntryId,
|
||||
) -> Result<(), Self::UpdateError>;
|
||||
|
||||
/// Remove a ref to a particular collaborative object
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ impl object::Storage for Storage {
|
|||
identifier: &Self::Identifier,
|
||||
typename: &crate::TypeName,
|
||||
object_id: &ObjectId,
|
||||
change: &change::Entry,
|
||||
entry: &change::EntryId,
|
||||
) -> Result<(), Self::UpdateError> {
|
||||
let name = format!(
|
||||
"refs/rad/{}/cobs/{}/{}",
|
||||
|
|
@ -162,8 +162,8 @@ impl object::Storage for Storage {
|
|||
typename,
|
||||
object_id
|
||||
);
|
||||
let id = *change.id();
|
||||
self.raw.reference(&name, id.into(), true, "new change")?;
|
||||
self.raw
|
||||
.reference(&name, (*entry).into(), true, "new change")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,17 +139,15 @@ impl cob::object::Storage for Repository {
|
|||
identifier: &Self::Identifier,
|
||||
typename: &cob::TypeName,
|
||||
object_id: &cob::ObjectId,
|
||||
change: &cob::Entry,
|
||||
entry: &cob::EntryId,
|
||||
) -> Result<(), Self::UpdateError> {
|
||||
self.backend.reference(
|
||||
git::refs::storage::cob(identifier, typename, object_id).as_str(),
|
||||
(*change.id()).into(),
|
||||
(*entry).into(),
|
||||
true,
|
||||
&format!(
|
||||
"Updating collaborative object '{}/{}' with new change {}",
|
||||
typename,
|
||||
object_id,
|
||||
change.id()
|
||||
"Updating collaborative object '{}/{}' with new entry {}",
|
||||
typename, object_id, entry,
|
||||
),
|
||||
)?;
|
||||
|
||||
|
|
@ -387,17 +385,15 @@ impl<'a> cob::object::Storage for DraftStore<'a> {
|
|||
identifier: &Self::Identifier,
|
||||
typename: &cob::TypeName,
|
||||
object_id: &cob::ObjectId,
|
||||
change: &cob::Entry,
|
||||
entry: &cob::history::EntryId,
|
||||
) -> Result<(), Self::UpdateError> {
|
||||
self.repo.backend.reference(
|
||||
git::refs::storage::draft::cob(identifier, typename, object_id).as_str(),
|
||||
(*change.id()).into(),
|
||||
(*entry).into(),
|
||||
true,
|
||||
&format!(
|
||||
"Updating draft collaborative object '{}/{}' with new change {}",
|
||||
typename,
|
||||
object_id,
|
||||
change.id()
|
||||
"Updating draft collaborative object '{}/{}' with new entry {}",
|
||||
typename, object_id, entry,
|
||||
),
|
||||
)?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue