Documentation
¶
Overview ¶
Package workcopy manages a vx working copy on disk: the files, the .vx directory with its config, a local object cache and a stat index that avoids rehashing unchanged files.
Index ¶
- Constants
- Variables
- func HasConflictMarkers(data []byte) bool
- type Config
- type WorkingCopy
- func (wc *WorkingCopy) Apply(ctx context.Context, changes []object.Change) error
- func (wc *WorkingCopy) BaseManifest(ctx context.Context) (object.Manifest, error)
- func (wc *WorkingCopy) ReadBlob(ctx context.Context, h hash.Hash) ([]byte, error)
- func (wc *WorkingCopy) Save() error
- func (wc *WorkingCopy) Scan(ctx context.Context) (object.Manifest, error)
- func (wc *WorkingCopy) Snapshot(ctx context.Context) (hash.Hash, []object.Change, error)
- func (wc *WorkingCopy) Status(ctx context.Context) ([]object.Change, error)
Constants ¶
const Dir = ".vx"
Dir is the name of the metadata directory at the root of a working copy.
Variables ¶
var ErrNotFound = errors.New("not inside a vx working copy (no .vx directory found); use `vx clone` first")
ErrNotFound means no working copy contains the directory.
Functions ¶
func HasConflictMarkers ¶
HasConflictMarkers reports whether text contains unresolved conflict markers written by vx sync.
Types ¶
type Config ¶
type Config struct {
Repo string `json:"repo"`
Effort string `json:"effort"`
// Base is the changeset the files are based on, and BaseTree its tree.
Base string `json:"base"`
BaseTree string `json:"base_tree"`
// Workspace is the open workspace, if any.
Workspace string `json:"workspace,omitempty"`
Intent string `json:"intent,omitempty"`
ChangeID string `json:"change_id,omitempty"`
}
Config is what a working copy knows about where it came from.
func (Config) BaseTreeHash ¶
BaseTreeHash returns the parsed base tree.
type WorkingCopy ¶
type WorkingCopy struct {
Root string
Config Config
Objects blob.Store
// contains filtered or unexported fields
}
WorkingCopy is an opened working copy.
func Create ¶
func Create(root string, cfg Config) (*WorkingCopy, error)
Create makes a new working copy at root, which must be empty or missing.
func Open ¶
func Open(root string) (*WorkingCopy, error)
Open opens the working copy rooted at root.
func (*WorkingCopy) Apply ¶
Apply writes changes to disk: deletes first (pruning emptied directories), then writes. The index is updated for every written file.
func (*WorkingCopy) BaseManifest ¶
BaseManifest returns the files of the base snapshot.
func (*WorkingCopy) Scan ¶
Scan walks the working copy and returns its files. Files whose size and modification time match the index are not read again. Contents of new or changed files are stored in the local object store as a side effect, so a snapshot never has to read them twice.