Show More
@@ -13,7 +13,6 b' use crate::{' | |||||
13 | dirstate::SIZE_FROM_OTHER_PARENT, |
|
13 | dirstate::SIZE_FROM_OTHER_PARENT, | |
14 | filepatterns::PatternFileWarning, |
|
14 | filepatterns::PatternFileWarning, | |
15 | matchers::{get_ignore_function, Matcher, VisitChildrenSet}, |
|
15 | matchers::{get_ignore_function, Matcher, VisitChildrenSet}, | |
16 | operations::Operation, |
|
|||
17 | utils::{ |
|
16 | utils::{ | |
18 | files::{find_dirs, HgMetadata}, |
|
17 | files::{find_dirs, HgMetadata}, | |
19 | hg_path::{ |
|
18 | hg_path::{ |
@@ -7,7 +7,6 b'' | |||||
7 |
|
7 | |||
8 | use crate::dirstate::status::{build_response, Dispatch, HgPathCow, Status}; |
|
8 | use crate::dirstate::status::{build_response, Dispatch, HgPathCow, Status}; | |
9 | use crate::matchers::Matcher; |
|
9 | use crate::matchers::Matcher; | |
10 | use crate::operations::Operation; |
|
|||
11 | use crate::{DirstateStatus, StatusError}; |
|
10 | use crate::{DirstateStatus, StatusError}; | |
12 |
|
11 | |||
13 | /// A tuple of the paths that need to be checked in the filelog because it's |
|
12 | /// A tuple of the paths that need to be checked in the filelog because it's | |
@@ -15,10 +14,8 b' use crate::{DirstateStatus, StatusError}' | |||||
15 | /// files. |
|
14 | /// files. | |
16 | pub type LookupAndStatus<'a> = (Vec<HgPathCow<'a>>, DirstateStatus<'a>); |
|
15 | pub type LookupAndStatus<'a> = (Vec<HgPathCow<'a>>, DirstateStatus<'a>); | |
17 |
|
16 | |||
18 |
impl<'a, M: Matcher + Sync> |
|
17 | impl<'a, M: Matcher + Sync> Status<'a, M> { | |
19 | type Error = StatusError; |
|
18 | pub(crate) fn run(&self) -> Result<LookupAndStatus<'a>, StatusError> { | |
20 |
|
||||
21 | fn run(&self) -> Result<LookupAndStatus<'a>, Self::Error> { |
|
|||
22 | let (traversed_sender, traversed_receiver) = |
|
19 | let (traversed_sender, traversed_receiver) = | |
23 | crossbeam::channel::unbounded(); |
|
20 | crossbeam::channel::unbounded(); | |
24 |
|
21 |
@@ -1,4 +1,3 b'' | |||||
1 | use super::Operation; |
|
|||
2 |
|
|
1 | use std::fmt; | |
3 | use std::path::{Path, PathBuf}; |
|
2 | use std::path::{Path, PathBuf}; | |
4 |
|
3 | |||
@@ -45,12 +44,8 b" impl<'a> FindRoot<'a> {" | |||||
45 | current_dir: Some(current_dir), |
|
44 | current_dir: Some(current_dir), | |
46 | } |
|
45 | } | |
47 | } |
|
46 | } | |
48 | } |
|
|||
49 |
|
47 | |||
50 | impl<'a> Operation<PathBuf> for FindRoot<'a> { |
|
48 | pub fn run(&self) -> Result<PathBuf, FindRootError> { | |
51 | type Error = FindRootError; |
|
|||
52 |
|
||||
53 | fn run(&self) -> Result<PathBuf, Self::Error> { |
|
|||
54 | let current_dir = match self.current_dir { |
|
49 | let current_dir = match self.current_dir { | |
55 | None => std::env::current_dir().or_else(|e| { |
|
50 | None => std::env::current_dir().or_else(|e| { | |
56 | Err(FindRootError { |
|
51 | Err(FindRootError { |
@@ -1,13 +1,13 b'' | |||||
|
1 | //! A distinction is made between operations and commands. | |||
|
2 | //! An operation is what can be done whereas a command is what is exposed by | |||
|
3 | //! the cli. A single command can use several operations to achieve its goal. | |||
|
4 | ||||
1 | mod dirstate_status; |
|
5 | mod dirstate_status; | |
2 | mod find_root; |
|
6 | mod find_root; | |
3 | pub use find_root::{FindRoot, FindRootError, FindRootErrorKind}; |
|
7 | pub use find_root::{FindRoot, FindRootError, FindRootErrorKind}; | |
4 |
|
8 | |||
5 | /// An interface for high-level hg operations. |
|
9 | // TODO add an `Operation` trait when GAT have landed (rust #44265): | |
6 | /// |
|
10 | // there is no way to currently define a trait which can both return | |
7 | /// A distinction is made between operation and commands. |
|
11 | // references to `self` and to passed data, which is what we would need. | |
8 | /// An operation is what can be done whereas a command is what is exposed by |
|
12 | // Generic Associated Types may fix this and allow us to have a unified | |
9 | /// the cli. A single command can use several operations to achieve its goal. |
|
13 | // interface. | |
10 | pub trait Operation<T> { |
|
|||
11 | type Error; |
|
|||
12 | fn run(&self) -> Result<T, Self::Error>; |
|
|||
13 | } |
|
@@ -1,7 +1,7 b'' | |||||
1 | use crate::commands::Command; |
|
1 | use crate::commands::Command; | |
2 | use crate::error::{CommandError, CommandErrorKind}; |
|
2 | use crate::error::{CommandError, CommandErrorKind}; | |
3 | use crate::ui::Ui; |
|
3 | use crate::ui::Ui; | |
4 |
use hg::operations::{FindRoot, FindRootError, FindRootErrorKind |
|
4 | use hg::operations::{FindRoot, FindRootError, FindRootErrorKind}; | |
5 | use hg::utils::files::get_bytes_from_path; |
|
5 | use hg::utils::files::get_bytes_from_path; | |
6 | use std::path::PathBuf; |
|
6 | use std::path::PathBuf; | |
7 |
|
7 |
General Comments 0
You need to be logged in to leave comments.
Login now