Skip to content

Commit 2f7b15b

Browse files
committed
Add documentation comments for operation, transaction, and view types
1 parent a335321 commit 2f7b15b

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

cli/src/cli_util.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ impl ReadonlyUserRepo {
359359
}
360360
}
361361

362-
// Provides utilities for writing a command that works on a workspace (like most
363-
// commands do).
362+
/// Provides utilities for writing a command that works on a [`Workspace`]
363+
/// (which most commands do).
364364
pub struct WorkspaceCommandHelper {
365365
cwd: PathBuf,
366366
string_args: Vec<String>,
@@ -1286,6 +1286,12 @@ Then run `jj squash` to move the resolution into the conflicted commit."#,
12861286
}
12871287
}
12881288

1289+
/// A [`Transaction`] tied to a particular workspace.
1290+
/// `WorkspaceCommandTransaction`s are created with
1291+
/// [`WorkspaceCommandHelper::start_transaction`] and committed with
1292+
/// [`WorkspaceCommandTransaction::finish`]. The inner `Transaction` can also be
1293+
/// extracted using [`WorkspaceCommandTransaction::into_inner`] in situations
1294+
/// where finer-grained control over the `Transaction` is necessary.
12891295
#[must_use]
12901296
pub struct WorkspaceCommandTransaction<'a> {
12911297
helper: &'a mut WorkspaceCommandHelper,
@@ -1351,6 +1357,10 @@ impl WorkspaceCommandTransaction<'_> {
13511357
self.helper.finish_transaction(ui, self.tx, description)
13521358
}
13531359

1360+
/// Returns the wrapped [`Transaction`] for circumstances where
1361+
/// finer-grained control is needed. The caller becomes responsible for
1362+
/// finishing the `Transaction`, including rebasing descendants and updating
1363+
/// the working copy, if applicable.
13541364
pub fn into_inner(self) -> Transaction {
13551365
self.tx
13561366
}

lib/src/operation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ use crate::op_store;
2323
use crate::op_store::{OpStore, OpStoreResult, OperationId, OperationMetadata, ViewId};
2424
use crate::view::View;
2525

26+
/// A wrapper around [`op_store::Operation`] that defines additional methods and
27+
/// stores a pointer to the `OpStore` the operation belongs to.
2628
#[derive(Clone)]
2729
pub struct Operation {
2830
op_store: Arc<dyn OpStore>,

lib/src/transaction.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ use crate::settings::UserSettings;
2727
use crate::view::View;
2828
use crate::{dag_walk, op_store};
2929

30+
/// An in-memory representation of a repo and any changes being made to it.
31+
///
32+
/// Within the scope of a transaction, changes to the repository are made
33+
/// in-memory to `mut_repo` and published to the repo backend when
34+
/// [`Transaction::commit`] is called. When a transaction is committed, it
35+
/// becomes atomically visible as an Operation in the op log that represents the
36+
/// transaction itself, and as a View that represents the state of the repo
37+
/// after the transaction. This is similar to how a Commit represents a change
38+
/// to the contents of the repository and a Tree represents the repository's
39+
/// contents after the change. See the documentation for [`op_store::Operation`]
40+
/// and [`op_store::View`] for more information.
3041
pub struct Transaction {
3142
mut_repo: MutableRepo,
3243
parent_ops: Vec<Operation>,

lib/src/view.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use crate::refs::LocalAndRemoteRef;
2424
use crate::str_util::StringPattern;
2525
use crate::{op_store, refs};
2626

27+
/// A wrapper around [`op_store::View`] that defines additional methods.
2728
#[derive(PartialEq, Eq, Debug, Clone)]
2829
pub struct View {
2930
data: op_store::View,

0 commit comments

Comments
 (0)