Patchwork D8608: hg-core: add Operation interface for high-level hg operations

login
register
mail settings
Submitter phabricator
Date June 5, 2020, 2:31 p.m.
Message ID <differential-rev-PHID-DREV-gwg4hxnsdx7evdmsufni-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46470/
State Superseded
Headers show

Comments

phabricator - June 5, 2020, 2:31 p.m.
acezar created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  A distinction is made between operations and commands.
  An operation is a high-level function of mercurial whereas a command is what is exposed by the cli.
  A single command can use several operations to achieve its goal.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8608

AFFECTED FILES
  rust/hg-core/src/lib.rs
  rust/hg-core/src/operations/mod.rs

CHANGE DETAILS




To: acezar, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/operations/mod.rs b/rust/hg-core/src/operations/mod.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-core/src/operations/mod.rs
@@ -0,0 +1,9 @@ 
+/// An interface for high-level hg operations.
+///
+/// A distinction is made between operation and commands.
+/// An operation is what can be done whereas a command is what is exposed by
+/// the cli. A single command can use several operations to achieve its goal.
+pub trait Operation<T> {
+    type Error;
+    fn run(&self) -> Result<T, Self::Error>;
+}
diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -23,6 +23,7 @@ 
 pub mod matchers;
 pub mod revlog;
 pub use revlog::*;
+pub mod operations;
 pub mod utils;
 
 // Remove this to see (potential) non-artificial compile failures. MacOS