forked from mirrors/jj
working_copy: propagate error source for SourceNotFound
errors
Might as well while I'm here.
This commit is contained in:
parent
e299963fae
commit
9f8d78c57d
1 changed files with 17 additions and 7 deletions
|
@ -295,8 +295,10 @@ pub enum SnapshotError {
|
||||||
pub enum CheckoutError {
|
pub enum CheckoutError {
|
||||||
// The current checkout was deleted, maybe by an overly aggressive GC that happened while
|
// The current checkout was deleted, maybe by an overly aggressive GC that happened while
|
||||||
// the current process was running.
|
// the current process was running.
|
||||||
#[error("Current checkout not found")]
|
#[error("Current checkout not found: {source}")]
|
||||||
SourceNotFound,
|
SourceNotFound {
|
||||||
|
source: Box<dyn std::error::Error + Send + Sync>,
|
||||||
|
},
|
||||||
// Another process checked out a commit while the current process was running (after the
|
// Another process checked out a commit while the current process was running (after the
|
||||||
// working copy was read by the current process).
|
// working copy was read by the current process).
|
||||||
#[error("Concurrent checkout")]
|
#[error("Concurrent checkout")]
|
||||||
|
@ -333,8 +335,10 @@ fn suppress_file_exists_error(orig_err: CheckoutError) -> Result<(), CheckoutErr
|
||||||
pub enum ResetError {
|
pub enum ResetError {
|
||||||
// The current checkout was deleted, maybe by an overly aggressive GC that happened while
|
// The current checkout was deleted, maybe by an overly aggressive GC that happened while
|
||||||
// the current process was running.
|
// the current process was running.
|
||||||
#[error("Current checkout not found")]
|
#[error("Current checkout not found: {source}")]
|
||||||
SourceNotFound,
|
SourceNotFound {
|
||||||
|
source: Box<dyn std::error::Error + Send + Sync>,
|
||||||
|
},
|
||||||
#[error("Internal error: {0}")]
|
#[error("Internal error: {0}")]
|
||||||
InternalBackendError(#[from] BackendError),
|
InternalBackendError(#[from] BackendError),
|
||||||
}
|
}
|
||||||
|
@ -813,7 +817,9 @@ impl TreeState {
|
||||||
.store
|
.store
|
||||||
.get_tree(&RepoPath::root(), &self.tree_id)
|
.get_tree(&RepoPath::root(), &self.tree_id)
|
||||||
.map_err(|err| match err {
|
.map_err(|err| match err {
|
||||||
BackendError::NotFound => CheckoutError::SourceNotFound,
|
err @ BackendError::NotFound => CheckoutError::SourceNotFound {
|
||||||
|
source: Box::new(err),
|
||||||
|
},
|
||||||
other => CheckoutError::InternalBackendError(other),
|
other => CheckoutError::InternalBackendError(other),
|
||||||
})?;
|
})?;
|
||||||
let stats = self.update(&old_tree, new_tree, self.sparse_matcher().as_ref(), Err)?;
|
let stats = self.update(&old_tree, new_tree, self.sparse_matcher().as_ref(), Err)?;
|
||||||
|
@ -829,7 +835,9 @@ impl TreeState {
|
||||||
.store
|
.store
|
||||||
.get_tree(&RepoPath::root(), &self.tree_id)
|
.get_tree(&RepoPath::root(), &self.tree_id)
|
||||||
.map_err(|err| match err {
|
.map_err(|err| match err {
|
||||||
BackendError::NotFound => CheckoutError::SourceNotFound,
|
err @ BackendError::NotFound => CheckoutError::SourceNotFound {
|
||||||
|
source: Box::new(err),
|
||||||
|
},
|
||||||
other => CheckoutError::InternalBackendError(other),
|
other => CheckoutError::InternalBackendError(other),
|
||||||
})?;
|
})?;
|
||||||
let old_matcher = PrefixMatcher::new(&self.sparse_patterns);
|
let old_matcher = PrefixMatcher::new(&self.sparse_patterns);
|
||||||
|
@ -956,7 +964,9 @@ impl TreeState {
|
||||||
.store
|
.store
|
||||||
.get_tree(&RepoPath::root(), &self.tree_id)
|
.get_tree(&RepoPath::root(), &self.tree_id)
|
||||||
.map_err(|err| match err {
|
.map_err(|err| match err {
|
||||||
BackendError::NotFound => ResetError::SourceNotFound,
|
err @ BackendError::NotFound => ResetError::SourceNotFound {
|
||||||
|
source: Box::new(err),
|
||||||
|
},
|
||||||
other => ResetError::InternalBackendError(other),
|
other => ResetError::InternalBackendError(other),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue