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.
This commit is contained in:
Martin von Zweigbergk 2024-08-22 21:37:59 -07:00 committed by Martin von Zweigbergk
parent b05593fdf5
commit acdcb578bc
2 changed files with 4 additions and 2 deletions

View file

@ -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<BoxStream<BackendResult<CopyRecord>>> {
Err(BackendError::Unsupported("get_copy_records".into()))
Ok(Box::pin(stream::empty()))
}
fn gc(&self, _index: &dyn Index, _keep_newer: SystemTime) -> BackendResult<()> {

View file

@ -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<BoxStream<BackendResult<CopyRecord>>> {
Err(BackendError::Unsupported("get_copy_records".into()))
Ok(Box::pin(stream::empty()))
}
fn gc(&self, _index: &dyn Index, _keep_newer: SystemTime) -> BackendResult<()> {