Documentation
¶
Overview ¶
Package jj shells out to the jj binary for the diff, status, and revision data the UI needs, and carries the one write path that moves selected changes into another revision.
Index ¶
- type ChangeType
- type Client
- func (c *Client) ApplySplit(plans []SplitPlan, source string) error
- func (*Client) CheckInstalled() error
- func (c *Client) Diff(revision string) (string, error)
- func (c *Client) GetRevisions(limit int) ([]RevisionEntry, error)
- func (c *Client) MoveChanges(patch, _, destination string) (err error)
- func (c *Client) ShowRevision(revision string) (*RevisionInfo, error)
- func (c *Client) Status() ([]FileStatus, error)
- func (c *Client) Undo() error
- type FileStatus
- type RevisionEntry
- type RevisionInfo
- type SplitDestination
- type SplitDestinationType
- type SplitPlan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeType ¶
type ChangeType int
ChangeType is what jj status says happened to a file. String returns the one-letter status jj prints.
const ( ChangeTypeModified ChangeType = iota ChangeTypeAdded ChangeTypeDeleted ChangeTypeRenamed )
Change kinds a status line can report. ChangeTypeModified is the zero value and the fallback for a status letter that is not recognized.
func (ChangeType) String ¶
func (ct ChangeType) String() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client runs jj in one repository. Every call shells out and blocks, so callers in the UI wrap them in a tea.Cmd. No call is cancellable, so each one runs under a background context.
func NewClient ¶
NewClient runs jj with baseDir as the working directory, so baseDir decides which repository every call acts on.
func (*Client) ApplySplit ¶
ApplySplit runs the plans in order, creating a commit first for each plan that needs one. A failure part way through restores the operation recorded before the first plan, so the repository goes back to where it started rather than keeping the plans that already succeeded.
This is the one path that rebases source, because a plan targeting a new commit inserts that commit beneath source. Only the parent pointer moves; source keeps every byte it had, so an unselected change cannot be lost here.
func (*Client) CheckInstalled ¶
CheckInstalled reports whether a jj binary is on PATH. It runs outside the repository, so it says nothing about baseDir being a jj repo.
func (*Client) Diff ¶
Diff returns the git-format diff for a revset, uncolored. The revset is resolved by jj at call time, so a moving revset such as @ follows the working copy.
func (*Client) GetRevisions ¶
func (c *Client) GetRevisions(limit int) ([]RevisionEntry, error)
GetRevisions lists recent revisions newest first for the destination picker, defaulting to 20 when limit is not positive.
func (*Client) MoveChanges ¶
MoveChanges applies a patch onto destination and squashes it there. Nothing the patch does not carry is touched: the caller's working copy is never read, written, or moved by the sequence, because every write happens in a throwaway workspace. The temp file holding the patch is removed even on failure, and a failure to remove it is joined onto the returned error.
func (*Client) ShowRevision ¶
func (c *Client) ShowRevision(revision string) (*RevisionInfo, error)
ShowRevision returns one revision's metadata. Fields jj did not print are left empty rather than reported, so the result is never nil on success.
func (*Client) Status ¶
func (c *Client) Status() ([]FileStatus, error)
Status lists the working copy's changed files. Lines jj prints that are not file entries are dropped, so an unparsable output yields an empty slice rather than an error.
type FileStatus ¶
type FileStatus struct {
Path string
ChangeType ChangeType
}
FileStatus is one entry from jj status.
type RevisionEntry ¶
RevisionEntry is one row of the destination picker. ChangeID is jj's shortest unique prefix, so it is only valid against the repository it came from.
type RevisionInfo ¶
RevisionInfo is one revision's metadata as jj show prints it. Any field jj omitted is empty.
type SplitDestination ¶
type SplitDestination struct {
ChangeID string
Description string
Type SplitDestinationType
}
SplitDestination is where one split plan's patch lands. ChangeID is empty for SplitDestNewCommit, where Description becomes the message of the commit that gets created.
type SplitDestinationType ¶
type SplitDestinationType int
SplitDestinationType separates a split target that already exists from one that will be created.
const ( SplitDestExistingRevision SplitDestinationType = iota SplitDestNewCommit )
Targets a split plan can send its patch to. SplitDestExistingRevision is the zero value, so a SplitDestination that was never filled in reads as targeting an existing revision.
type SplitPlan ¶
type SplitPlan struct {
Patch string
Destination SplitDestination
Tag rune
}
SplitPlan is one tag's patch and the destination it goes to. Tag is carried through for error messages and has no meaning to jj.