Skip to content

Commit

Permalink
tools/admin: implement list-manifest for skeleton-manifests2
Browse files Browse the repository at this point in the history
Summary:
Add `skeleton-manifests2` support to `monad derived-data list-manifest`.

Skeleton Manifests V2 are sharded flat manifests, and as such don't have IDs for trees.  Instead we just print whether a path is a tree or a file.

Reviewed By: RajivTS

Differential Revision: D67408932

fbshipit-source-id: 4828f14c199917c2bdd61b5d5e9f0c1b9a82973b
  • Loading branch information
markbt authored and facebook-github-bot committed Dec 19, 2024
1 parent 2e5037e commit d41e1e1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ Skeleton manifest of main's root directory (recursive)
a/foo.txt exists
script exists
script.sh exists
$ with_stripped_logs mononoke_admin derived-data -R repo list-manifest -B main -t skeleton-manifests2 --derive | sort
A file
B file
C file
a/ tree count=7
script file
script.sh file
$ with_stripped_logs mononoke_admin derived-data -R repo list-manifest -B main -p "a" -t skeleton-manifests2 --derive | sort
a/b/ tree count=5
a/foo.txt file

Fsnodes of main's a directory
$ with_stripped_logs mononoke_admin derived-data -R repo list-manifest -p "a" -B main -t fsnodes --derive | sort
Expand Down
1 change: 1 addition & 0 deletions eden/mononoke/tools/admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ sapling-renderdag = { version = "0.1.0", path = "../../../scm/lib/renderdag" }
serde = { version = "1.0.185", features = ["derive", "rc"] }
serde_json = { version = "1.0.132", features = ["float_roundtrip", "unbounded_depth"] }
skeleton_manifest = { version = "0.1.0", path = "../../derived_data/skeleton_manifest" }
skeleton_manifest_v2 = { version = "0.1.0", path = "../../derived_data/skeleton_manifest_v2" }
slog = { version = "2.7", features = ["max_level_trace", "nested-values"] }
sorted_vector_map = { version = "0.2.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
source_control = { version = "0.1.0", path = "../../scs/if" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use mononoke_types::deleted_manifest_common::DeletedManifestCommon;
use mononoke_types::deleted_manifest_v2::DeletedManifestV2;
use mononoke_types::fsnode::FsnodeFile;
use mononoke_types::path::MPath;
use mononoke_types::skeleton_manifest_v2::SkeletonManifestV2;
use mononoke_types::ChangesetId;
use mononoke_types::ContentManifestId;
use mononoke_types::DeletedManifestV2Id;
Expand All @@ -55,6 +56,7 @@ use repo_blobstore::RepoBlobstore;
use repo_blobstore::RepoBlobstoreRef;
use repo_derived_data::RepoDerivedDataRef;
use skeleton_manifest::RootSkeletonManifestId;
use skeleton_manifest_v2::RootSkeletonManifestV2Id;
use unodes::RootUnodeManifestId;

use super::Repo;
Expand All @@ -63,6 +65,7 @@ use super::Repo;
#[derive(Copy, Clone, Debug, ValueEnum)]
enum ListManifestType {
SkeletonManifests,
SkeletonManifests2,
ContentManifests,
Fsnodes,
Unodes,
Expand Down Expand Up @@ -164,6 +167,15 @@ impl Listable for Entry<SkeletonManifestId, ()> {
}
}

impl Listable for Entry<SkeletonManifestV2, ()> {
fn list_item(self) -> String {
match self {
Entry::Tree(tree) => format!("tree\tcount={}", tree.rollup_count().into_inner()),
Entry::Leaf(()) => String::from("file"),
}
}
}

impl Listable for Entry<FsnodeId, FsnodeFile> {
fn list_item(self) -> String {
match self {
Expand Down Expand Up @@ -404,6 +416,15 @@ pub(super) async fn list_manifest(
.into_skeleton_manifest_id();
list(ctx, repo, root_id, path, args.directory, args.recursive).await?
}
ListManifestType::SkeletonManifests2 => {
let root =
fetch_or_derive_root::<RootSkeletonManifestV2Id>(ctx, repo, cs_id, args.derive)
.await?
.into_inner_id()
.load(ctx, repo.repo_blobstore())
.await?;
list(ctx, repo, root, path, args.directory, args.recursive).await?
}
ListManifestType::ContentManifests => {
let root_id =
fetch_or_derive_root::<RootContentManifestId>(ctx, repo, cs_id, args.derive)
Expand Down

0 comments on commit d41e1e1

Please sign in to comment.