Struct jj_cli::cli_util::WorkspaceCommandHelper
source · 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
pub fn new( ui: &mut Ui, command: &CommandHelper, workspace: Workspace, repo: Arc<ReadonlyRepo> ) -> Result<Self, CommandError>
pub fn git_backend(&self) -> Option<&GitBackend>
pub fn check_working_copy_writable(&self) -> Result<(), CommandError>
sourcepub fn maybe_snapshot(&mut self, ui: &mut Ui) -> Result<(), CommandError>
pub fn maybe_snapshot(&mut self, ui: &mut 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 working_copy(&self) -> &dyn WorkingCopy
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) -> &PathBuf
pub fn workspace_id(&self) -> &WorkspaceId
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, FsPathParseError>
pub fn parse_file_path( &self, input: &str ) -> Result<RepoPathBuf, FsPathParseError>
Parses a path relative to cwd into a RepoPath, which is relative to the workspace root.
sourcepub fn parse_file_patterns(
&self,
values: &[String]
) -> Result<FilesetExpression, CommandError>
pub fn parse_file_patterns( &self, values: &[String] ) -> Result<FilesetExpression, CommandError>
Parses the given strings as file patterns.
sourcepub fn parse_union_filesets(
&self,
file_args: &[String]
) -> Result<FilesetExpression, CommandError>
pub fn parse_union_filesets( &self, file_args: &[String] ) -> Result<FilesetExpression, CommandError>
Parses the given fileset expressions and concatenates them all.
pub fn base_ignores(&self) -> Result<Arc<GitIgnoreFile>, GitIgnoreError>
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.
pub fn resolve_single_op( &self, op_str: &str ) -> Result<Operation, OpsetEvaluationError>
sourcepub fn resolve_single_rev(
&self,
revision_arg: &RevisionArg
) -> Result<Commit, CommandError>
pub fn resolve_single_rev( &self, 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,
revision_args: &[RevisionArg]
) -> Result<IndexSet<Commit>, CommandError>
pub fn resolve_some_revsets_default_single( &self, revision_args: &[RevisionArg] ) -> Result<IndexSet<Commit>, CommandError>
Evaluates revset expressions to non-empty set of commits. 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, revision_arg: &RevisionArg ) -> Result<RevsetExpressionEvaluator<'_>, CommandError>
sourcepub fn parse_union_revsets(
&self,
revision_args: &[RevisionArg]
) -> Result<RevsetExpressionEvaluator<'_>, CommandError>
pub fn parse_union_revsets( &self, revision_args: &[RevisionArg] ) -> Result<RevsetExpressionEvaluator<'_>, CommandError>
Parses the given revset expressions and concatenates them all.
pub fn attach_revset_evaluator( &self, expression: Rc<RevsetExpression> ) -> Result<RevsetExpressionEvaluator<'_>, CommandError>
pub fn id_prefix_context(&self) -> Result<&IdPrefixContext, CommandError>
pub fn template_aliases_map(&self) -> &TemplateAliasesMap
sourcepub fn parse_template<'a, C: Clone + 'a, L: TemplateLanguage<'a> + ?Sized>(
&self,
language: &L,
template_text: &str,
wrap_self: impl Fn(PropertyPlaceholder<C>) -> L::Property
) -> Result<TemplateRenderer<'a, C>, CommandError>
pub fn parse_template<'a, C: Clone + 'a, L: TemplateLanguage<'a> + ?Sized>( &self, language: &L, template_text: &str, wrap_self: impl Fn(PropertyPlaceholder<C>) -> L::Property ) -> Result<TemplateRenderer<'a, C>, CommandError>
Parses template of the given language into evaluation tree.
wrap_self specifies the type of the top-level property, which should
be one of the L::wrap_*() functions.
sourcepub fn parse_commit_template(
&self,
template_text: &str
) -> Result<TemplateRenderer<'_, Commit>, CommandError>
pub fn parse_commit_template( &self, template_text: &str ) -> Result<TemplateRenderer<'_, Commit>, CommandError>
Parses commit template into evaluation tree.
sourcepub fn commit_template_language(
&self
) -> Result<CommitTemplateLanguage<'_>, CommandError>
pub fn commit_template_language( &self ) -> Result<CommitTemplateLanguage<'_>, CommandError>
Creates commit 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 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_branches<'a>(
&self,
from: impl IntoIterator<Item = &'a CommitId>
) -> Result<Vec<AdvanceableBranch>, CommandError>
pub fn get_advanceable_branches<'a>( &self, from: impl IntoIterator<Item = &'a CommitId> ) -> Result<Vec<AdvanceableBranch>, CommandError>
Identifies branches which are eligible to be moved automatically during
jj commit and jj new. Whether a branch is eligible is determined by
its target and the user and repo config for “advance-branches”.
Returns a Vec of branches 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.
Branches are not moved until
WorkspaceCommandTransaction::advance_branches() is called with the
AdvanceableBranchs returned by this function.
Returns an empty std::Vec if no branches 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