mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
for RevlogManifest, ensure public API always has repo set
Summary: Remove the unused `empty()` constructor, and make the `parse` APIs private. Reviewed By: lukaspiatkowski Differential Revision: D5796734 fbshipit-source-id: 84e7b146ca89334fbdfda917d5d8eebf04a3e474
This commit is contained in:
parent
e5b075b8ec
commit
380bd861be
@ -28,6 +28,7 @@ pub struct Details {
|
||||
/// Revlog Manifest v1
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct RevlogManifest {
|
||||
// This is None for testing only -- the public API ensures `repo` always exists.
|
||||
repo: Option<RevlogRepo>,
|
||||
files: BTreeMap<Path, Details>,
|
||||
}
|
||||
@ -82,13 +83,6 @@ pub fn parse_with_prefix(data: &[u8], prefix: &Path) -> Result<BTreeMap<Path, De
|
||||
}
|
||||
|
||||
impl RevlogManifest {
|
||||
pub fn empty() -> RevlogManifest {
|
||||
RevlogManifest {
|
||||
repo: None,
|
||||
files: BTreeMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(repo: RevlogRepo, node: BlobNode) -> Result<RevlogManifest> {
|
||||
node.as_blob()
|
||||
.as_slice()
|
||||
@ -96,15 +90,17 @@ impl RevlogManifest {
|
||||
.and_then(|blob| Self::parse(Some(repo), blob))
|
||||
}
|
||||
|
||||
pub fn parse(repo: Option<RevlogRepo>, data: &[u8]) -> Result<RevlogManifest> {
|
||||
fn parse(repo: Option<RevlogRepo>, data: &[u8]) -> Result<RevlogManifest> {
|
||||
// This is private because it allows one to create a RevlogManifest with repo set to None.
|
||||
parse(data).map(|files| RevlogManifest { repo, files })
|
||||
}
|
||||
|
||||
pub fn parse_with_prefix(
|
||||
fn parse_with_prefix(
|
||||
repo: Option<RevlogRepo>,
|
||||
data: &[u8],
|
||||
prefix: &Path,
|
||||
) -> Result<RevlogManifest> {
|
||||
// This is private because it allows one to create a RevlogManifest with repo set to None.
|
||||
parse_with_prefix(data, prefix).map(|files| RevlogManifest { repo, files })
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user