mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-01 00:50:57 +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.
|
/// file to the working copy.
|
||||||
struct ConflictsWorkingCopy {
|
struct ConflictsWorkingCopy {
|
||||||
inner: Box<dyn WorkingCopy>,
|
inner: Box<dyn WorkingCopy>,
|
||||||
|
working_copy_path: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConflictsWorkingCopy {
|
impl ConflictsWorkingCopy {
|
||||||
|
@ -110,20 +111,22 @@ impl ConflictsWorkingCopy {
|
||||||
) -> Result<Self, WorkingCopyStateError> {
|
) -> Result<Self, WorkingCopyStateError> {
|
||||||
let inner = LocalWorkingCopy::init(
|
let inner = LocalWorkingCopy::init(
|
||||||
store,
|
store,
|
||||||
working_copy_path,
|
working_copy_path.clone(),
|
||||||
state_path,
|
state_path,
|
||||||
operation_id,
|
operation_id,
|
||||||
workspace_id,
|
workspace_id,
|
||||||
)?;
|
)?;
|
||||||
Ok(ConflictsWorkingCopy {
|
Ok(ConflictsWorkingCopy {
|
||||||
inner: Box::new(inner),
|
inner: Box::new(inner),
|
||||||
|
working_copy_path,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load(store: Arc<Store>, working_copy_path: PathBuf, state_path: PathBuf) -> Self {
|
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 {
|
ConflictsWorkingCopy {
|
||||||
inner: Box::new(inner),
|
inner: Box::new(inner),
|
||||||
|
working_copy_path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,10 +140,6 @@ impl WorkingCopy for ConflictsWorkingCopy {
|
||||||
Self::name()
|
Self::name()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path(&self) -> &Path {
|
|
||||||
self.inner.path()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn workspace_id(&self) -> &WorkspaceId {
|
fn workspace_id(&self) -> &WorkspaceId {
|
||||||
self.inner.workspace_id()
|
self.inner.workspace_id()
|
||||||
}
|
}
|
||||||
|
@ -160,7 +159,7 @@ impl WorkingCopy for ConflictsWorkingCopy {
|
||||||
fn start_mutation(&self) -> Result<Box<dyn LockedWorkingCopy>, WorkingCopyStateError> {
|
fn start_mutation(&self) -> Result<Box<dyn LockedWorkingCopy>, WorkingCopyStateError> {
|
||||||
let inner = self.inner.start_mutation()?;
|
let inner = self.inner.start_mutation()?;
|
||||||
Ok(Box::new(LockedConflictsWorkingCopy {
|
Ok(Box::new(LockedConflictsWorkingCopy {
|
||||||
wc_path: self.inner.path().to_owned(),
|
wc_path: self.working_copy_path.clone(),
|
||||||
inner,
|
inner,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -261,6 +260,9 @@ impl LockedWorkingCopy for LockedConflictsWorkingCopy {
|
||||||
operation_id: OperationId,
|
operation_id: OperationId,
|
||||||
) -> Result<Box<dyn WorkingCopy>, WorkingCopyStateError> {
|
) -> Result<Box<dyn WorkingCopy>, WorkingCopyStateError> {
|
||||||
let inner = self.inner.finish(operation_id)?;
|
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()
|
Self::name()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path(&self) -> &Path {
|
|
||||||
&self.working_copy_path
|
|
||||||
}
|
|
||||||
|
|
||||||
fn workspace_id(&self) -> &WorkspaceId {
|
fn workspace_id(&self) -> &WorkspaceId {
|
||||||
&self.checkout_state().workspace_id
|
&self.checkout_state().workspace_id
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -40,9 +40,6 @@ pub trait WorkingCopy: Send {
|
||||||
/// implementation when loading a working copy.
|
/// implementation when loading a working copy.
|
||||||
fn name(&self) -> &str;
|
fn name(&self) -> &str;
|
||||||
|
|
||||||
/// The working copy's root directory.
|
|
||||||
fn path(&self) -> &Path;
|
|
||||||
|
|
||||||
/// The working copy's workspace ID.
|
/// The working copy's workspace ID.
|
||||||
fn workspace_id(&self) -> &WorkspaceId;
|
fn workspace_id(&self) -> &WorkspaceId;
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ fn test_sparse_checkout() {
|
||||||
// Reload the state to check that it was persisted
|
// Reload the state to check that it was persisted
|
||||||
let wc = LocalWorkingCopy::load(
|
let wc = LocalWorkingCopy::load(
|
||||||
repo.store().clone(),
|
repo.store().clone(),
|
||||||
wc.path().to_path_buf(),
|
ws.workspace_root().to_path_buf(),
|
||||||
wc.state_path().to_path_buf(),
|
wc.state_path().to_path_buf(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
Loading…
Reference in a new issue