From db36c2d2a9bed840c12fe866f69b089bd5f88429 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Tue, 13 Apr 2021 16:35:05 -0700 Subject: [PATCH] pydag: add api to open lazy commit hash backends Summary: Expose the lazy hash Rust logic to Python. Reviewed By: sfilipco Differential Revision: D27547578 fbshipit-source-id: a01116caab6aa83d60b79e4d3a1f4482ddb4edb1 --- .../bindings/modules/pydag/src/commits.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/eden/scm/edenscmnative/bindings/modules/pydag/src/commits.rs b/eden/scm/edenscmnative/bindings/modules/pydag/src/commits.rs index 86b417a203..99bcc86321 100644 --- a/eden/scm/edenscmnative/bindings/modules/pydag/src/commits.rs +++ b/eden/scm/edenscmnative/bindings/modules/pydag/src/commits.rs @@ -210,18 +210,29 @@ py_class!(pub class commits |py| { /// /// This is similar to doublewrite backend, except that commit text fallback is edenapi, /// not revlog, despite the revlog might have the data. + /// + /// If lazyhash is True, enable lazy commit hashes or EdenAPI. + /// + /// If lazyhashdir is set, enable lazy commit hashes backed by the given segments dir + /// (for testing). @staticmethod def openhybrid( - revlogdir: Option<&PyPath>, segmentsdir: &PyPath, commitsdir: &PyPath, edenapi: PyClient, reponame: String + revlogdir: Option<&PyPath>, segmentsdir: &PyPath, commitsdir: &PyPath, edenapi: PyClient, reponame: String, + lazyhash: bool = false, lazyhashdir: Option<&PyPath> = None ) -> PyResult { let client = edenapi.extract_inner(py); - let inner = HybridCommits::new( + let mut inner = HybridCommits::new( revlogdir.map(|d| d.as_path()), segmentsdir.as_path(), commitsdir.as_path(), client, reponame, ).map_pyerr(py)?; + if let Some(dir) = lazyhashdir { + inner.enable_lazy_commit_hashes_from_local_segments( dir.as_path()).map_pyerr(py)?; + } else if lazyhash { + inner.enable_lazy_commit_hashes(); + } Self::from_commits(py, inner) }