diff --git a/eden/scm/lib/revisionstore/src/indexedlogdatastore.rs b/eden/scm/lib/revisionstore/src/indexedlogdatastore.rs
index 678734fa2d..98fc7330e9 100644
--- a/eden/scm/lib/revisionstore/src/indexedlogdatastore.rs
+++ b/eden/scm/lib/revisionstore/src/indexedlogdatastore.rs
@@ -15,7 +15,7 @@ use anyhow::{bail, ensure, Result};
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use futures::{FutureExt, StreamExt};
use minibytes::Bytes;
-use parking_lot::RwLock;
+use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
use tokio::task::spawn_blocking;
use configparser::{config::ConfigSet, convert::ByteCount};
@@ -52,6 +52,12 @@ pub struct IndexedLogHgIdDataStore {
extstored_policy: ExtStoredPolicy,
}
+pub struct IndexedLogHgIdDataStoreReadGuard<'a>(RwLockReadGuard<'a, IndexedLogHgIdDataStoreInner>);
+
+pub struct IndexedLogHgIdDataStoreWriteGuard<'a>(
+ RwLockWriteGuard<'a, IndexedLogHgIdDataStoreInner>,
+);
+
#[derive(Clone, Debug)]
pub struct Entry {
key: Key,
@@ -286,6 +292,61 @@ impl IndexedLogHgIdDataStore {
self.inner.write().log.flush()?;
Ok(())
}
+
+ pub fn read_lock<'a>(&'a self) -> IndexedLogHgIdDataStoreReadGuard<'a> {
+ IndexedLogHgIdDataStoreReadGuard(self.inner.read())
+ }
+
+ pub fn write_lock<'a>(&'a self) -> IndexedLogHgIdDataStoreWriteGuard<'a> {
+ IndexedLogHgIdDataStoreWriteGuard(self.inner.write())
+ }
+}
+
+impl<'a> IndexedLogHgIdDataStoreReadGuard<'a> {
+ /// Write an entry to the IndexedLog
+ ///
+ /// Like IndexedLogHgIdDataStore::get_entry, but uses the already-acquired read lock.
+ pub fn get_entry(&self, key: Key) -> Result