From acdcb578bc5079b2adefd8a9afdf2d43723b4b44 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 22 Aug 2024 21:37:59 -0700 Subject: [PATCH] copies: in unsupported backends, return an empty stream instead of error The native backend currently errors out if you ask it about copies. So does the test backend. I think it's better to return an empty stream of copies so it doesn't prevent other functionality. --- lib/src/local_backend.rs | 3 ++- lib/testutils/src/test_backend.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/local_backend.rs b/lib/src/local_backend.rs index 05164e46e..f541f8e3e 100644 --- a/lib/src/local_backend.rs +++ b/lib/src/local_backend.rs @@ -27,6 +27,7 @@ use std::time::SystemTime; use async_trait::async_trait; use blake2::Blake2b512; use blake2::Digest; +use futures::stream; use futures::stream::BoxStream; use prost::Message; use tempfile::NamedTempFile; @@ -330,7 +331,7 @@ impl Backend for LocalBackend { _root: &CommitId, _head: &CommitId, ) -> BackendResult>> { - Err(BackendError::Unsupported("get_copy_records".into())) + Ok(Box::pin(stream::empty())) } fn gc(&self, _index: &dyn Index, _keep_newer: SystemTime) -> BackendResult<()> { diff --git a/lib/testutils/src/test_backend.rs b/lib/testutils/src/test_backend.rs index 6fc7c49ab..b0282471e 100644 --- a/lib/testutils/src/test_backend.rs +++ b/lib/testutils/src/test_backend.rs @@ -28,6 +28,7 @@ use std::sync::OnceLock; use std::time::SystemTime; use async_trait::async_trait; +use futures::stream; use futures::stream::BoxStream; use jj_lib::backend::make_root_commit; use jj_lib::backend::Backend; @@ -327,7 +328,7 @@ impl Backend for TestBackend { _root: &CommitId, _head: &CommitId, ) -> BackendResult>> { - Err(BackendError::Unsupported("get_copy_records".into())) + Ok(Box::pin(stream::empty())) } fn gc(&self, _index: &dyn Index, _keep_newer: SystemTime) -> BackendResult<()> {