Struct 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

Source

pub fn settings(&self) -> &UserSettings

Settings for this workspace.

Source

pub fn check_working_copy_writable(&self) -> Result<(), CommandError>

Source

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.

Source

pub fn repo(&self) -> &Arc<ReadonlyRepo>

Source

pub fn repo_path(&self) -> &Path

Source

pub fn workspace(&self) -> &Workspace

Source

pub fn working_copy(&self) -> &dyn WorkingCopy

Source

pub fn env(&self) -> &WorkspaceCommandEnvironment

Source

pub fn checkout_options(&self) -> CheckoutOptions

Source

pub fn unchecked_start_working_copy_mutation( &mut self, ) -> Result<(LockedWorkspace<'_>, Commit), CommandError>

Source

pub fn start_working_copy_mutation( &mut self, ) -> Result<(LockedWorkspace<'_>, Commit), CommandError>

Source

pub fn workspace_root(&self) -> &Path

Source

pub fn workspace_name(&self) -> &WorkspaceName

Source

pub fn get_wc_commit_id(&self) -> Option<&CommitId>

Source

pub fn working_copy_shared_with_git(&self) -> bool

Source

pub fn format_file_path(&self, file: &RepoPath) -> String

Source

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.

Source

pub fn parse_file_patterns( &self, ui: &Ui, values: &[String], ) -> Result<FilesetExpression, CommandError>

Parses the given strings as file patterns.

Source

pub fn parse_union_filesets( &self, ui: &Ui, file_args: &[String], ) -> Result<FilesetExpression, CommandError>

Parses the given fileset expressions and concatenates them all.

Source

pub fn auto_tracking_matcher( &self, ui: &Ui, ) -> Result<Box<dyn Matcher>, CommandError>

Source

pub fn snapshot_options_with_start_tracking_matcher<'a>( &self, start_tracking_matcher: &'a dyn Matcher, ) -> Result<SnapshotOptions<'a>, CommandError>

Source

pub fn base_ignores(&self) -> Result<Arc<GitIgnoreFile>, GitIgnoreError>

Source

pub fn diff_renderer(&self, formats: Vec<DiffFormat>) -> DiffRenderer<'_>

Creates textual diff renderer of the specified formats.

Source

pub fn diff_renderer_for( &self, args: &DiffFormatArgs, ) -> Result<DiffRenderer<'_>, CommandError>

Loads textual diff renderer from the settings and command arguments.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn text_editor(&self) -> Result<TextEditor, ConfigGetError>

Loads text editor from the settings.

Source

pub fn resolve_single_op( &self, op_str: &str, ) -> Result<Operation, OpsetEvaluationError>

Source

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.

Source

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.)

Source

pub fn parse_revset( &self, ui: &Ui, revision_arg: &RevisionArg, ) -> Result<RevsetExpressionEvaluator<'_>, CommandError>

Source

pub fn parse_union_revsets( &self, ui: &Ui, revision_args: &[RevisionArg], ) -> Result<RevsetExpressionEvaluator<'_>, CommandError>

Parses the given revset expressions and concatenates them all.

Source

pub fn attach_revset_evaluator( &self, expression: Rc<UserRevsetExpression>, ) -> RevsetExpressionEvaluator<'_>

Source

pub fn id_prefix_context(&self) -> &IdPrefixContext

Source

pub fn parse_template<'a, C, L>( &self, ui: &Ui, language: &L, template_text: &str, ) -> Result<TemplateRenderer<'a, C>, CommandError>
where C: Clone + 'a, L: TemplateLanguage<'a> + ?Sized, L::Property: WrapTemplateProperty<'a, C>,

Parses template of the given language into evaluation tree.

Source

pub fn parse_commit_template( &self, ui: &Ui, template_text: &str, ) -> Result<TemplateRenderer<'_, Commit>, CommandError>

Parses commit template into evaluation tree.

Source

pub fn parse_operation_template( &self, ui: &Ui, template_text: &str, ) -> Result<TemplateRenderer<'_, Operation>, CommandError>

Parses commit template into evaluation tree.

Source

pub fn commit_template_language(&self) -> CommitTemplateLanguage<'_>

Creates commit template language environment for this workspace.

Source

pub fn operation_template_language(&self) -> OperationTemplateLanguage

Creates operation template language environment for this workspace.

Source

pub fn commit_summary_template(&self) -> TemplateRenderer<'_, Commit>

Template for one-line summary of a commit.

Source

pub fn operation_summary_template(&self) -> TemplateRenderer<'_, Operation>

Template for one-line summary of an operation.

Source

pub fn short_change_id_template(&self) -> TemplateRenderer<'_, Commit>

Source

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.

Source

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.

Source

pub fn check_rewritable<'a>( &self, commits: impl IntoIterator<Item = &'a CommitId>, ) -> Result<(), CommandError>

Source

pub fn start_transaction(&mut self) -> WorkspaceCommandTransaction<'_>

Source

pub fn report_repo_conflicts( &self, fmt: &mut dyn Formatter, repo: &ReadonlyRepo, conflicted_commits: Vec<CommitId>, ) -> Result<(), CommandError>

Source

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 AdvanceableBookmarks returned by this function.

Returns an empty std::Vec if no bookmarks are eligible to advance.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,