pub struct WorkspaceCommandHelper { /* private fields */ }
Expand description
Provides utilities for writing a command that works on a Workspace
(which most commands do).
Implementations§
Source§impl WorkspaceCommandHelper
impl WorkspaceCommandHelper
Sourcepub fn settings(&self) -> &UserSettings
pub fn settings(&self) -> &UserSettings
Settings for this workspace.
pub fn check_working_copy_writable(&self) -> Result<(), CommandError>
Sourcepub fn maybe_snapshot(&mut self, ui: &Ui) -> Result<(), CommandError>
pub fn maybe_snapshot(&mut self, ui: &Ui) -> Result<(), CommandError>
Snapshot the working copy if allowed, and import Git refs if the working copy is collocated with Git.
pub fn repo(&self) -> &Arc<ReadonlyRepo>
pub fn repo_path(&self) -> &Path
pub fn workspace(&self) -> &Workspace
pub fn working_copy(&self) -> &dyn WorkingCopy
pub fn env(&self) -> &WorkspaceCommandEnvironment
pub fn checkout_options(&self) -> CheckoutOptions
pub fn unchecked_start_working_copy_mutation( &mut self, ) -> Result<(LockedWorkspace<'_>, Commit), CommandError>
pub fn start_working_copy_mutation( &mut self, ) -> Result<(LockedWorkspace<'_>, Commit), CommandError>
pub fn workspace_root(&self) -> &Path
pub fn workspace_name(&self) -> &WorkspaceName
pub fn get_wc_commit_id(&self) -> Option<&CommitId>
pub fn format_file_path(&self, file: &RepoPath) -> String
Sourcepub fn parse_file_path(
&self,
input: &str,
) -> Result<RepoPathBuf, UiPathParseError>
pub fn parse_file_path( &self, input: &str, ) -> Result<RepoPathBuf, UiPathParseError>
Parses a path relative to cwd into a RepoPath, which is relative to the workspace root.
Sourcepub fn parse_file_patterns(
&self,
ui: &Ui,
values: &[String],
) -> Result<FilesetExpression, CommandError>
pub fn parse_file_patterns( &self, ui: &Ui, values: &[String], ) -> Result<FilesetExpression, CommandError>
Parses the given strings as file patterns.
Sourcepub fn parse_union_filesets(
&self,
ui: &Ui,
file_args: &[String],
) -> Result<FilesetExpression, CommandError>
pub fn parse_union_filesets( &self, ui: &Ui, file_args: &[String], ) -> Result<FilesetExpression, CommandError>
Parses the given fileset expressions and concatenates them all.
pub fn auto_tracking_matcher( &self, ui: &Ui, ) -> Result<Box<dyn Matcher>, CommandError>
pub fn snapshot_options_with_start_tracking_matcher<'a>( &self, start_tracking_matcher: &'a dyn Matcher, ) -> Result<SnapshotOptions<'a>, CommandError>
pub fn base_ignores(&self) -> Result<Arc<GitIgnoreFile>, GitIgnoreError>
Sourcepub fn diff_renderer(&self, formats: Vec<DiffFormat>) -> DiffRenderer<'_>
pub fn diff_renderer(&self, formats: Vec<DiffFormat>) -> DiffRenderer<'_>
Creates textual diff renderer of the specified formats
.
Sourcepub fn diff_renderer_for(
&self,
args: &DiffFormatArgs,
) -> Result<DiffRenderer<'_>, CommandError>
pub fn diff_renderer_for( &self, args: &DiffFormatArgs, ) -> Result<DiffRenderer<'_>, CommandError>
Loads textual diff renderer from the settings and command arguments.
Sourcepub fn diff_renderer_for_log(
&self,
args: &DiffFormatArgs,
patch: bool,
) -> Result<Option<DiffRenderer<'_>>, CommandError>
pub fn diff_renderer_for_log( &self, args: &DiffFormatArgs, patch: bool, ) -> Result<Option<DiffRenderer<'_>>, CommandError>
Loads textual diff renderer from the settings and log-like command
arguments. Returns Ok(None)
if there are no command arguments that
enable patch output.
Sourcepub fn diff_editor(
&self,
ui: &Ui,
tool_name: Option<&str>,
) -> Result<DiffEditor, CommandError>
pub fn diff_editor( &self, ui: &Ui, tool_name: Option<&str>, ) -> Result<DiffEditor, CommandError>
Loads diff editor from the settings.
If the tool_name
isn’t specified, the default editor will be returned.
Sourcepub fn diff_selector(
&self,
ui: &Ui,
tool_name: Option<&str>,
force_interactive: bool,
) -> Result<DiffSelector, CommandError>
pub fn diff_selector( &self, ui: &Ui, tool_name: Option<&str>, force_interactive: bool, ) -> Result<DiffSelector, CommandError>
Conditionally loads diff editor from the settings.
If the tool_name
is specified, interactive session is implied.
Sourcepub fn merge_editor(
&self,
ui: &Ui,
tool_name: Option<&str>,
) -> Result<MergeEditor, MergeToolConfigError>
pub fn merge_editor( &self, ui: &Ui, tool_name: Option<&str>, ) -> Result<MergeEditor, MergeToolConfigError>
Loads 3-way merge editor from the settings.
If the tool_name
isn’t specified, the default editor will be returned.
Sourcepub fn text_editor(&self) -> Result<TextEditor, ConfigGetError>
pub fn text_editor(&self) -> Result<TextEditor, ConfigGetError>
Loads text editor from the settings.
pub fn resolve_single_op( &self, op_str: &str, ) -> Result<Operation, OpsetEvaluationError>
Sourcepub fn resolve_single_rev(
&self,
ui: &Ui,
revision_arg: &RevisionArg,
) -> Result<Commit, CommandError>
pub fn resolve_single_rev( &self, ui: &Ui, revision_arg: &RevisionArg, ) -> Result<Commit, CommandError>
Resolve a revset to a single revision. Return an error if the revset is empty or has multiple revisions.
Sourcepub fn resolve_some_revsets_default_single(
&self,
ui: &Ui,
revision_args: &[RevisionArg],
) -> Result<IndexSet<CommitId>, CommandError>
pub fn resolve_some_revsets_default_single( &self, ui: &Ui, revision_args: &[RevisionArg], ) -> Result<IndexSet<CommitId>, CommandError>
Evaluates revset expressions to non-empty set of commit IDs. The returned set preserves the order of the input expressions.
If an input expression is prefixed with all:
, it may be evaluated to
any number of revisions (including 0.)
pub fn parse_revset( &self, ui: &Ui, revision_arg: &RevisionArg, ) -> Result<RevsetExpressionEvaluator<'_>, CommandError>
Sourcepub fn parse_union_revsets(
&self,
ui: &Ui,
revision_args: &[RevisionArg],
) -> Result<RevsetExpressionEvaluator<'_>, CommandError>
pub fn parse_union_revsets( &self, ui: &Ui, revision_args: &[RevisionArg], ) -> Result<RevsetExpressionEvaluator<'_>, CommandError>
Parses the given revset expressions and concatenates them all.
pub fn attach_revset_evaluator( &self, expression: Rc<UserRevsetExpression>, ) -> RevsetExpressionEvaluator<'_>
pub fn id_prefix_context(&self) -> &IdPrefixContext
Sourcepub fn parse_template<'a, C, L>(
&self,
ui: &Ui,
language: &L,
template_text: &str,
) -> Result<TemplateRenderer<'a, C>, CommandError>
pub fn parse_template<'a, C, L>( &self, ui: &Ui, language: &L, template_text: &str, ) -> Result<TemplateRenderer<'a, C>, CommandError>
Parses template of the given language into evaluation tree.
Sourcepub fn parse_commit_template(
&self,
ui: &Ui,
template_text: &str,
) -> Result<TemplateRenderer<'_, Commit>, CommandError>
pub fn parse_commit_template( &self, ui: &Ui, template_text: &str, ) -> Result<TemplateRenderer<'_, Commit>, CommandError>
Parses commit template into evaluation tree.
Sourcepub fn parse_operation_template(
&self,
ui: &Ui,
template_text: &str,
) -> Result<TemplateRenderer<'_, Operation>, CommandError>
pub fn parse_operation_template( &self, ui: &Ui, template_text: &str, ) -> Result<TemplateRenderer<'_, Operation>, CommandError>
Parses commit template into evaluation tree.
Sourcepub fn commit_template_language(&self) -> CommitTemplateLanguage<'_>
pub fn commit_template_language(&self) -> CommitTemplateLanguage<'_>
Creates commit template language environment for this workspace.
Sourcepub fn operation_template_language(&self) -> OperationTemplateLanguage
pub fn operation_template_language(&self) -> OperationTemplateLanguage
Creates operation template language environment for this workspace.
Sourcepub fn commit_summary_template(&self) -> TemplateRenderer<'_, Commit>
pub fn commit_summary_template(&self) -> TemplateRenderer<'_, Commit>
Template for one-line summary of a commit.
Sourcepub fn operation_summary_template(&self) -> TemplateRenderer<'_, Operation>
pub fn operation_summary_template(&self) -> TemplateRenderer<'_, Operation>
Template for one-line summary of an operation.
pub fn short_change_id_template(&self) -> TemplateRenderer<'_, Commit>
Sourcepub fn format_commit_summary(&self, commit: &Commit) -> String
pub fn format_commit_summary(&self, commit: &Commit) -> String
Returns one-line summary of the given commit
.
Use write_commit_summary()
to get colorized output. Use
commit_summary_template()
if you have many commits to process.
Sourcepub fn write_commit_summary(
&self,
formatter: &mut dyn Formatter,
commit: &Commit,
) -> Result<()>
pub fn write_commit_summary( &self, formatter: &mut dyn Formatter, commit: &Commit, ) -> Result<()>
Writes one-line summary of the given commit
.
Use commit_summary_template()
if you have many commits to process.
pub fn check_rewritable<'a>( &self, commits: impl IntoIterator<Item = &'a CommitId>, ) -> Result<(), CommandError>
pub fn start_transaction(&mut self) -> WorkspaceCommandTransaction<'_>
pub fn report_repo_conflicts( &self, fmt: &mut dyn Formatter, repo: &ReadonlyRepo, conflicted_commits: Vec<CommitId>, ) -> Result<(), CommandError>
Sourcepub fn get_advanceable_bookmarks<'a>(
&self,
from: impl IntoIterator<Item = &'a CommitId>,
) -> Result<Vec<AdvanceableBookmark>, CommandError>
pub fn get_advanceable_bookmarks<'a>( &self, from: impl IntoIterator<Item = &'a CommitId>, ) -> Result<Vec<AdvanceableBookmark>, CommandError>
Identifies bookmarks which are eligible to be moved automatically
during jj commit
and jj new
. Whether a bookmark is eligible is
determined by its target and the user and repo config for
“advance-bookmarks”.
Returns a Vec of bookmarks in repo
that point to any of the from
commits and that are eligible to advance. The from
commits are
typically the parents of the target commit of jj commit
or jj new
.
Bookmarks are not moved until
WorkspaceCommandTransaction::advance_bookmarks()
is called with the
AdvanceableBookmark
s returned by this function.
Returns an empty std::Vec
if no bookmarks are eligible to advance.
Auto Trait Implementations§
impl !Freeze for WorkspaceCommandHelper
impl !RefUnwindSafe for WorkspaceCommandHelper
impl !Send for WorkspaceCommandHelper
impl !Sync for WorkspaceCommandHelper
impl Unpin for WorkspaceCommandHelper
impl !UnwindSafe for WorkspaceCommandHelper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more