mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-19 19:08:08 +00:00
working_copy: delete path()
method from trait
We don't currently use the `path()` method. Not all working copies even have a relevant path. For example, working copies on Google's server don't.
This commit is contained in:
parent
237b41e738
commit
749a284354
4 changed files with 12 additions and 17 deletions
|
@ -94,6 +94,7 @@ fn main() -> std::process::ExitCode {
|
|||
/// file to the working copy.
|
||||
struct ConflictsWorkingCopy {
|
||||
inner: Box<dyn WorkingCopy>,
|
||||
working_copy_path: PathBuf,
|
||||
}
|
||||
|
||||
impl ConflictsWorkingCopy {
|
||||
|
@ -110,20 +111,22 @@ impl ConflictsWorkingCopy {
|
|||
) -> Result<Self, WorkingCopyStateError> {
|
||||
let inner = LocalWorkingCopy::init(
|
||||
store,
|
||||
working_copy_path,
|
||||
working_copy_path.clone(),
|
||||
state_path,
|
||||
operation_id,
|
||||
workspace_id,
|
||||
)?;
|
||||
Ok(ConflictsWorkingCopy {
|
||||
inner: Box::new(inner),
|
||||
working_copy_path,
|
||||
})
|
||||
}
|
||||
|
||||
fn load(store: Arc<Store>, working_copy_path: PathBuf, state_path: PathBuf) -> Self {
|
||||
let inner = LocalWorkingCopy::load(store, working_copy_path, state_path);
|
||||
let inner = LocalWorkingCopy::load(store, working_copy_path.clone(), state_path);
|
||||
ConflictsWorkingCopy {
|
||||
inner: Box::new(inner),
|
||||
working_copy_path,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,10 +140,6 @@ impl WorkingCopy for ConflictsWorkingCopy {
|
|||
Self::name()
|
||||
}
|
||||
|
||||
fn path(&self) -> &Path {
|
||||
self.inner.path()
|
||||
}
|
||||
|
||||
fn workspace_id(&self) -> &WorkspaceId {
|
||||
self.inner.workspace_id()
|
||||
}
|
||||
|
@ -160,7 +159,7 @@ impl WorkingCopy for ConflictsWorkingCopy {
|
|||
fn start_mutation(&self) -> Result<Box<dyn LockedWorkingCopy>, WorkingCopyStateError> {
|
||||
let inner = self.inner.start_mutation()?;
|
||||
Ok(Box::new(LockedConflictsWorkingCopy {
|
||||
wc_path: self.inner.path().to_owned(),
|
||||
wc_path: self.working_copy_path.clone(),
|
||||
inner,
|
||||
}))
|
||||
}
|
||||
|
@ -261,6 +260,9 @@ impl LockedWorkingCopy for LockedConflictsWorkingCopy {
|
|||
operation_id: OperationId,
|
||||
) -> Result<Box<dyn WorkingCopy>, WorkingCopyStateError> {
|
||||
let inner = self.inner.finish(operation_id)?;
|
||||
Ok(Box::new(ConflictsWorkingCopy { inner }))
|
||||
Ok(Box::new(ConflictsWorkingCopy {
|
||||
inner,
|
||||
working_copy_path: self.wc_path,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1543,10 +1543,6 @@ impl WorkingCopy for LocalWorkingCopy {
|
|||
Self::name()
|
||||
}
|
||||
|
||||
fn path(&self) -> &Path {
|
||||
&self.working_copy_path
|
||||
}
|
||||
|
||||
fn workspace_id(&self) -> &WorkspaceId {
|
||||
&self.checkout_state().workspace_id
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
use std::any::Any;
|
||||
use std::ffi::OsString;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use thiserror::Error;
|
||||
|
@ -40,9 +40,6 @@ pub trait WorkingCopy: Send {
|
|||
/// implementation when loading a working copy.
|
||||
fn name(&self) -> &str;
|
||||
|
||||
/// The working copy's root directory.
|
||||
fn path(&self) -> &Path;
|
||||
|
||||
/// The working copy's workspace ID.
|
||||
fn workspace_id(&self) -> &WorkspaceId;
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ fn test_sparse_checkout() {
|
|||
// Reload the state to check that it was persisted
|
||||
let wc = LocalWorkingCopy::load(
|
||||
repo.store().clone(),
|
||||
wc.path().to_path_buf(),
|
||||
ws.workspace_root().to_path_buf(),
|
||||
wc.state_path().to_path_buf(),
|
||||
);
|
||||
assert_eq!(
|
||||
|
|
Loading…
Reference in a new issue