Back out "provide path for trees when fetching from the datapack store"

Summary: Original commit changeset: d9631ea37b5f

Reviewed By: kmancini

Differential Revision: D30136950

fbshipit-source-id: b56c8666c0d7b6fbd7801ad8a7d9f5a6160544b1
This commit is contained in:
Zeyi (Rice) Fan 2021-08-05 14:07:26 -07:00 committed by Facebook GitHub Bot
parent c016c76db9
commit a7bd38624d
6 changed files with 15 additions and 34 deletions

View File

@ -230,13 +230,12 @@ std::unique_ptr<Tree> HgDatapackStore::getTree(
// cache miss, and just doing it for root trees is sufficient to detect the
// scenario where Mercurial just wrote a brand new tree.
bool local_only = path.empty();
auto tree =
store_.getTree(path.stringPiece(), manifestId.getBytes(), local_only);
auto tree = store_.getTree(manifestId.getBytes(), local_only);
if (!tree && local_only) {
// Mercurial might have just written the tree to the store. Refresh the
// store and try again, this time allowing remote fetches.
store_.refresh();
tree = store_.getTree(path.stringPiece(), manifestId.getBytes(), false);
tree = store_.getTree(manifestId.getBytes(), false);
}
if (tree) {
return fromRawTree(tree.get(), edenTreeId, path, writeBatch, commitHash);

View File

@ -253,25 +253,17 @@ void HgNativeBackingStore::getTreeBatch(
}
std::shared_ptr<RustTree> HgNativeBackingStore::getTree(
folly::ByteRange name,
folly::ByteRange node,
bool local) {
XLOG(DBG7) << "Importing tree name=" << name.data()
<< " node=" << folly::hexlify(node) << " from hgcache";
XLOG(DBG7) << "Importing tree node=" << folly::hexlify(node)
<< " from hgcache";
RustCFallible<RustTree> manifest(
rust_backingstore_get_tree(
store_.get(),
name.data(),
name.size(),
node.data(),
node.size(),
local),
rust_backingstore_get_tree(store_.get(), node.data(), node.size(), local),
rust_tree_free);
if (manifest.isError()) {
XLOG(DBG5) << "Error while getting tree name=" << name.data()
<< " node=" << folly::hexlify(node)
XLOG(DBG5) << "Error while getting tree node=" << folly::hexlify(node)
<< " from backingstore: " << manifest.getError();
return nullptr;
}

View File

@ -48,8 +48,7 @@ class HgNativeBackingStore {
bool local,
std::function<void(size_t, std::shared_ptr<RustTree>)>&& resolve);
std::shared_ptr<RustTree>
getTree(folly::ByteRange name, folly::ByteRange node, bool local);
std::shared_ptr<RustTree> getTree(folly::ByteRange node, bool local);
void refresh();

View File

@ -7,7 +7,7 @@
* This file is generated with cbindgen. Please run `./tools/cbindgen.sh` to
* update this file.
*
* @generated SignedSource<<eedea1888281a922bfa29b8a1f18cfe2>>
* @generated SignedSource<<d55c0fa3a07268a77cb8b9aee5ec761e>>
*
*/
@ -147,8 +147,6 @@ void rust_backingstore_get_blob_batch(RustBackingStore *store,
void (*resolve)(void*, uintptr_t, RustCFallibleBase));
RustCFallibleBase rust_backingstore_get_tree(RustBackingStore *store,
const uint8_t *name,
uintptr_t name_len,
const uint8_t *node,
uintptr_t node_len,
bool local);

View File

@ -21,7 +21,7 @@ use revisionstore::{
use std::path::Path;
use std::sync::Arc;
use tracing::{event, instrument, Level};
use types::Key;
use types::{Key, Node, RepoPathBuf};
pub struct BackingStore {
blobstore: ContentStore,
@ -165,13 +165,11 @@ impl BackingStore {
manifest.list(&key.path)
}
pub fn get_tree(&self, path: &[u8], node: &[u8], local_only: bool) -> Result<Option<List>> {
let key = key_from_path_node_slice(path, node)?;
self.get_tree_by_key(key, local_only)
}
#[instrument(level = "debug", skip(self))]
fn get_tree_by_key(&self, key: Key, local_only: bool) -> Result<Option<List>> {
pub fn get_tree(&self, node: &[u8], local_only: bool) -> Result<Option<List>> {
let node = Node::from_slice(node)?;
let path = RepoPathBuf::new();
let key = Key::new(path, node);
// check if the blob is present on disk
if local_only
&& !self

View File

@ -112,19 +112,16 @@ pub extern "C" fn rust_backingstore_get_blob_batch(
fn backingstore_get_tree(
store: *mut BackingStore,
name: *const u8,
name_len: usize,
node: *const u8,
node_len: usize,
local: bool,
) -> Result<*mut Tree> {
assert!(!store.is_null());
let store = unsafe { &*store };
let name = stringpiece_to_slice(name, name_len)?;
let node = stringpiece_to_slice(node, node_len)?;
store
.get_tree(name, node, local)
.get_tree(node, local)
.and_then(|opt| opt.ok_or_else(|| Error::msg("no tree found")))
.and_then(|list| list.try_into())
.map(|result| Box::into_raw(Box::new(result)))
@ -133,13 +130,11 @@ fn backingstore_get_tree(
#[no_mangle]
pub extern "C" fn rust_backingstore_get_tree(
store: *mut BackingStore,
name: *const u8,
name_len: usize,
node: *const u8,
node_len: usize,
local: bool,
) -> CFallible<Tree> {
backingstore_get_tree(store, name, name_len, node, node_len, local).into()
backingstore_get_tree(store, node, node_len, local).into()
}
#[no_mangle]