mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
revisionstore: expose shared mutable stores to Python
Summary: Treemanifest needs to be able to write to the shared stores from paths other than just prefetch (like when it receives certain trees via a standard pull). To make this possible we need to expose the Rust shared mutable stores. This will also make just general integration with Python cleaner. In the future we can get rid of the non-prefetch download paths and remove this. Reviewed By: quark-zju Differential Revision: D23772385 fbshipit-source-id: c1e67e3d21b354b85895dba8d82a7a9f0ffc5d73
This commit is contained in:
parent
40cfc97379
commit
46d0991cd0
@ -858,8 +858,9 @@ class basetreemanifestlog(object):
|
||||
|
||||
def getmutablesharedpacks(self):
|
||||
if useruststore(self._repo.ui):
|
||||
raise error.ProgrammingError(
|
||||
"getmutablesharedpacks not supported when treemanifest.useruststore is True"
|
||||
return (
|
||||
self.datastore.getsharedmutable(),
|
||||
self.historystore.getsharedmutable(),
|
||||
)
|
||||
|
||||
return self._mutablesharedpacks.getmutablepack()
|
||||
@ -2686,32 +2687,11 @@ class remotetreestore(generatingdatastore):
|
||||
# we'll then route to the Rust store layer, which will then come
|
||||
# back to here.
|
||||
if len(args) == 3:
|
||||
# This is a temporary hack. The Rust python bindings assume the
|
||||
# prefetch function has certain args and that it has complete
|
||||
# ownership of the mutable stores (and therefore passes mutable
|
||||
# stores for you to use). The python code takes a different pattern,
|
||||
# assuming the mutable packs are owned somewhere else and jumps
|
||||
# through several layers:
|
||||
# remotetreestore._generatedtrees -> repo._prefetchtrees ->
|
||||
# _gettrees -> bundle2 treeparthandler2 (gets the mutable packs here) ->
|
||||
# wirepack (calls add on the packs).
|
||||
# Once we're fully migrated to the Rust store we can remove the
|
||||
# local notions of getmutablesharedpacks and maybe simplify this.
|
||||
datastore, historystore, keys = args
|
||||
mfl = self._repo.manifestlog
|
||||
oldfunc = mfl.getmutablesharedpacks
|
||||
try:
|
||||
|
||||
def getstores():
|
||||
return datastore, historystore
|
||||
|
||||
mfl.getmutablesharedpacks = getstores
|
||||
if self._repo.ui.configbool("treemanifest", "ondemandfetch"):
|
||||
self._repo.getdesignatednodes(keys)
|
||||
else:
|
||||
self._prefetchtrees(keys)
|
||||
finally:
|
||||
mfl.getmutablesharedpacks = oldfunc
|
||||
keys = args[2]
|
||||
if self._repo.ui.configbool("treemanifest", "ondemandfetch"):
|
||||
self._repo.getdesignatednodes(args[2])
|
||||
else:
|
||||
self._prefetchtrees(keys)
|
||||
else:
|
||||
keys = args[0]
|
||||
self.datastore.prefetch(keys)
|
||||
|
@ -975,6 +975,11 @@ py_class!(pub class contentstore |py| {
|
||||
let store = self.store(py);
|
||||
Ok(store.get_logged_fetches().into_iter().map(|p| p.into()).collect::<Vec<PyPathBuf>>())
|
||||
}
|
||||
|
||||
def getsharedmutable(&self) -> PyResult<mutabledeltastore> {
|
||||
let store = self.store(py);
|
||||
mutabledeltastore::create_instance(py, store.get_shared_mutable())
|
||||
}
|
||||
});
|
||||
|
||||
impl ExtractInnerRef for contentstore {
|
||||
@ -1056,6 +1061,11 @@ py_class!(class metadatastore |py| {
|
||||
let store = self.store(py);
|
||||
store.refresh_py(py)
|
||||
}
|
||||
|
||||
def getsharedmutable(&self) -> PyResult<mutablehistorystore> {
|
||||
let store = self.store(py);
|
||||
mutablehistorystore::create_instance(py, store.get_shared_mutable())
|
||||
}
|
||||
});
|
||||
|
||||
impl ExtractInnerRef for metadatastore {
|
||||
|
@ -87,6 +87,10 @@ impl ContentStore {
|
||||
HashSet::new()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_shared_mutable(&self) -> Arc<dyn HgIdMutableDeltaStore> {
|
||||
self.shared_mutabledatastore.clone()
|
||||
}
|
||||
}
|
||||
|
||||
// Repack specific methods, not to be used directly but by the repack code.
|
||||
|
@ -74,6 +74,10 @@ impl MetadataStore {
|
||||
RepackLocation::Shared => self.shared_mutablehistorystore.flush(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_shared_mutable(&self) -> Arc<dyn HgIdMutableHistoryStore> {
|
||||
self.shared_mutablehistorystore.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl HgIdHistoryStore for MetadataStore {
|
||||
|
Loading…
Reference in New Issue
Block a user