Skip to content

Commit

Permalink
Add dst_path to MutableRenameEntry thrift struct
Browse files Browse the repository at this point in the history
Summary: Mostly a mechanical change. I need this in the next diff.

Reviewed By: markbt

Differential Revision: D69529812

fbshipit-source-id: 6859b24ced237563378840d0324905820b780d5b
  • Loading branch information
Liu Yang authored and facebook-github-bot committed Feb 13, 2025
1 parent 8faf0ef commit 54ff777
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion eden/mononoke/mutable_renames/if/mutable_rename.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
include "eden/mononoke/mononoke_types/serialization/id.thrift"
include "thrift/annotation/rust.thrift"

# If you change this, you need to bump CODEVAR in caching.rs
# If you change this, you need to bump CODEVER in caching.rs

@rust.Exhaustive
struct PathHash {
Expand All @@ -25,6 +25,7 @@ struct MutableRenameEntry {
5: PathHash src_path_hash;
6: id.Blake2 src_unode;
7: byte is_tree;
8: binary dst_path;
}

@rust.Exhaustive
Expand Down
14 changes: 13 additions & 1 deletion eden/mononoke/mutable_renames/src/caching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use crate::MutableRenames;
/// the layout of memcache entries is changed in an incompatible way.
/// The corresponding sitever, which can be used to flush memcache, is
/// in the JustKnob scm/mononoke_memcache_sitevers:mutable_renames.
pub const MC_CODEVER: u32 = 0;
pub const MC_CODEVER: u32 = 1;

#[derive(Clone)]
pub struct CacheHandlers {
Expand Down Expand Up @@ -221,6 +221,7 @@ pub struct CachedMutableRenameEntry(pub Option<CacheableMutableRenameEntry>);
#[derive(Abomonation, Clone)]
pub struct CacheableMutableRenameEntry {
dst_cs_id: ChangesetId,
dst_path: Vec<u8>,
dst_path_hash: PathHash,
src_cs_id: ChangesetId,
src_path: Vec<u8>,
Expand All @@ -234,17 +235,20 @@ impl TryFrom<CacheableMutableRenameEntry> for MutableRenameEntry {
fn try_from(entry: CacheableMutableRenameEntry) -> Result<Self, Error> {
let CacheableMutableRenameEntry {
dst_cs_id,
dst_path,
dst_path_hash,
src_cs_id,
src_path,
src_path_hash,
src_unode,
is_tree,
} = entry;
let dst_path = MPath::new(dst_path)?;
let src_path = MPath::new(src_path)?;

Ok(Self {
dst_cs_id,
dst_path,
dst_path_hash,
src_cs_id,
src_path,
Expand All @@ -258,17 +262,20 @@ impl From<MutableRenameEntry> for CacheableMutableRenameEntry {
fn from(entry: MutableRenameEntry) -> Self {
let MutableRenameEntry {
dst_cs_id,
dst_path,
dst_path_hash,
src_cs_id,
src_path,
src_path_hash,
src_unode,
is_tree,
} = entry;
let dst_path = dst_path.to_vec();
let src_path = src_path.to_vec();

Self {
dst_cs_id,
dst_path,
dst_path_hash,
src_cs_id,
src_path,
Expand Down Expand Up @@ -298,6 +305,7 @@ impl MemcacheEntity for CachedMutableRenameEntry {
None => thrift::CachedMutableRenameEntry { entry: None },
Some(CacheableMutableRenameEntry {
dst_cs_id,
dst_path,
dst_path_hash,
src_cs_id,
src_path,
Expand All @@ -306,6 +314,7 @@ impl MemcacheEntity for CachedMutableRenameEntry {
is_tree,
}) => {
let dst_cs_id = dst_cs_id.into_thrift();
let dst_path = dst_path.clone();
let dst_path_hash = path_hash_to_thrift(dst_path_hash);
let src_cs_id = src_cs_id.into_thrift();
let src_path = src_path.clone();
Expand All @@ -320,6 +329,7 @@ impl MemcacheEntity for CachedMutableRenameEntry {
src_path_hash,
src_unode,
is_tree,
dst_path,
});
thrift::CachedMutableRenameEntry { entry }
}
Expand All @@ -337,6 +347,7 @@ impl MemcacheEntity for CachedMutableRenameEntry {
src_path_hash,
src_unode,
is_tree,
dst_path,
}),
} = compact_protocol::deserialize(bytes).map_err(|_| McErrorKind::Deserialization)?
{
Expand All @@ -352,6 +363,7 @@ impl MemcacheEntity for CachedMutableRenameEntry {
Blake2::from_thrift(src_unode).map_err(|_| McErrorKind::Deserialization)?;
let entry = CacheableMutableRenameEntry {
dst_cs_id,
dst_path,
dst_path_hash,
src_cs_id,
src_path,
Expand Down
8 changes: 8 additions & 0 deletions eden/mononoke/mutable_renames/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl SqlConstructFromMetadataDatabaseConfig for SqlMutableRenamesStore {}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MutableRenameEntry {
dst_cs_id: ChangesetId,
dst_path: MPath,
dst_path_hash: PathHash,
src_cs_id: ChangesetId,
src_path: MPath,
Expand Down Expand Up @@ -93,6 +94,7 @@ impl MutableRenameEntry {

Ok(Self {
dst_cs_id,
dst_path,
dst_path_hash,
src_cs_id,
src_path,
Expand All @@ -102,6 +104,12 @@ impl MutableRenameEntry {
})
}

/// Get the destination path for this entry, or None if the destination
/// is the repo root
pub fn dst_path(&self) -> &MPath {
&self.dst_path
}

fn dst_path_hash(&self) -> &PathHash {
&self.dst_path_hash
}
Expand Down

0 comments on commit 54ff777

Please sign in to comment.