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