diff --git a/eden/mononoke/mutable_renames/if/mutable_rename.thrift b/eden/mononoke/mutable_renames/if/mutable_rename.thrift index ee5342f5859de..3ddb17ed7600b 100644 --- a/eden/mononoke/mutable_renames/if/mutable_rename.thrift +++ b/eden/mononoke/mutable_renames/if/mutable_rename.thrift @@ -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 { @@ -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 diff --git a/eden/mononoke/mutable_renames/src/caching.rs b/eden/mononoke/mutable_renames/src/caching.rs index cc60a6e13b7d6..bffc1bd3b20ed 100644 --- a/eden/mononoke/mutable_renames/src/caching.rs +++ b/eden/mononoke/mutable_renames/src/caching.rs @@ -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 { @@ -221,6 +221,7 @@ pub struct CachedMutableRenameEntry(pub Option); #[derive(Abomonation, Clone)] pub struct CacheableMutableRenameEntry { dst_cs_id: ChangesetId, + dst_path: Vec, dst_path_hash: PathHash, src_cs_id: ChangesetId, src_path: Vec, @@ -234,6 +235,7 @@ impl TryFrom for MutableRenameEntry { fn try_from(entry: CacheableMutableRenameEntry) -> Result { let CacheableMutableRenameEntry { dst_cs_id, + dst_path, dst_path_hash, src_cs_id, src_path, @@ -241,10 +243,12 @@ impl TryFrom for MutableRenameEntry { 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, @@ -258,6 +262,7 @@ impl From for CacheableMutableRenameEntry { fn from(entry: MutableRenameEntry) -> Self { let MutableRenameEntry { dst_cs_id, + dst_path, dst_path_hash, src_cs_id, src_path, @@ -265,10 +270,12 @@ impl From for CacheableMutableRenameEntry { 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, @@ -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, @@ -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(); @@ -320,6 +329,7 @@ impl MemcacheEntity for CachedMutableRenameEntry { src_path_hash, src_unode, is_tree, + dst_path, }); thrift::CachedMutableRenameEntry { entry } } @@ -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)? { @@ -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, diff --git a/eden/mononoke/mutable_renames/src/lib.rs b/eden/mononoke/mutable_renames/src/lib.rs index c9c23f1488436..a5d0ceeadcdab 100644 --- a/eden/mononoke/mutable_renames/src/lib.rs +++ b/eden/mononoke/mutable_renames/src/lib.rs @@ -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, @@ -93,6 +94,7 @@ impl MutableRenameEntry { Ok(Self { dst_cs_id, + dst_path, dst_path_hash, src_cs_id, src_path, @@ -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 }