mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
scmstore: add utility method for converting StoreTree to manifest-tree::Entry
Summary: Adds a utility method for converting a `StoreTree` to a `manifest-tree::Entry`, which wraps an hg manifest blob and provides methods for parsing it as a tree manifest (and a `TryFrom` impl used to convert it to a pre-parsed `manifest::List`, which is used by BackingStore in the next change in this stack). Reviewed By: andll Differential Revision: D30859470 fbshipit-source-id: 411e80a14861e0739b0c398290055002b35e59d3
This commit is contained in:
parent
30cb821f95
commit
789fd8c82c
@ -26,6 +26,7 @@ http-client = { path = "../http-client" }
|
||||
indexedlog = { path = "../indexedlog" }
|
||||
lfs_protocol = { path = "../../../mononoke/lfs_protocol" }
|
||||
lz4-pyframe = { path = "../lz4-pyframe" }
|
||||
manifest-tree = { path = "../manifest-tree" }
|
||||
memmap = "0.7"
|
||||
mincode = { path = "../mincode" }
|
||||
minibytes = { path = "../minibytes", features = ["frombytes"] }
|
||||
|
@ -9,7 +9,7 @@ use anyhow::Result;
|
||||
use tracing::instrument;
|
||||
|
||||
use edenapi_types::TreeEntry;
|
||||
|
||||
use manifest_tree::TreeEntry as ManifestTreeEntry;
|
||||
use minibytes::Bytes;
|
||||
use types::{HgId, Key};
|
||||
|
||||
@ -72,4 +72,9 @@ impl LazyTree {
|
||||
ContentStore(_, _) => None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn manifest_tree_entry(&mut self) -> Result<ManifestTreeEntry> {
|
||||
// TODO(meyer): Make manifest-tree crate use minibytes::Bytes
|
||||
Ok(ManifestTreeEntry(self.hg_content()?.into_vec().into()))
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,10 @@
|
||||
|
||||
use std::ops::BitOr;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
|
||||
use manifest_tree::TreeEntry as ManifestTreeEntry;
|
||||
|
||||
use crate::scmstore::{
|
||||
tree::types::{LazyTree, TreeAttributes},
|
||||
value::StoreValue,
|
||||
@ -17,6 +21,15 @@ pub struct StoreTree {
|
||||
pub(crate) content: Option<LazyTree>,
|
||||
}
|
||||
|
||||
impl StoreTree {
|
||||
pub fn manifest_tree_entry(&mut self) -> Result<ManifestTreeEntry> {
|
||||
self.content
|
||||
.as_mut()
|
||||
.ok_or_else(|| anyhow!("no content available"))?
|
||||
.manifest_tree_entry()
|
||||
}
|
||||
}
|
||||
|
||||
impl StoreValue for StoreTree {
|
||||
type Attrs = TreeAttributes;
|
||||
|
||||
@ -50,6 +63,7 @@ impl Default for StoreTree {
|
||||
StoreTree { content: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LazyTree> for StoreTree {
|
||||
fn from(v: LazyTree) -> Self {
|
||||
StoreTree { content: Some(v) }
|
||||
|
Loading…
Reference in New Issue
Block a user