Documentation
¶
Overview ¶
Package modelsync is what `sysml -sync` and the REPL's repository commands share above reposync: reading a model as the graph a sync compares, cutting the graph rooted in one element, stamping a graph with the project branch it came from so its notation declares a ProjectRef, and applying a change set while advancing the sync state. Neither client diffs or applies on its own.
Index ¶
- Variables
- func Baseline(ctx context.Context, repo Repository, state *reposync.State) (*rdf.Graph, error)
- func Notation(graph *rdf.Graph, warn func(string)) ([]byte, error)
- func Rooted(graph *rdf.Graph, qualifiedName string) (*rdf.Graph, error)
- func RootedAt(graph *rdf.Graph, root rdf.Term) *rdf.Graph
- func Roots(graph *rdf.Graph) []rdf.Term
- func Scoped(graph *rdf.Graph, scope reposync.Scope) *rdf.Graph
- func WithoutDerived(graph *rdf.Graph) *rdf.Graph
- type AmbiguousNameError
- type Applied
- type NotFoundError
- type Repository
Constants ¶
This section is empty.
Variables ¶
var ErrAmbiguousName = errors.New("ambiguous project name")
ErrAmbiguousName is a name several projects share.
Functions ¶
func Baseline ¶
Baseline reads the repository as the state's last-seen commit left it: the graph a diff tells repository changes since then apart against. Nil when the state names no commit.
func Notation ¶
Notation writes a graph as SysML notation, each warning the writer raises passed to warn.
func Rooted ¶
Rooted cuts the graph down to the element of the given qualified name and everything it owns, directly or through its relationships. The element becomes a root: the triples tying it to its own owner are dropped, as a project's root element has none. Elements the cut references but does not own stay references.
func RootedAt ¶
RootedAt is Rooted at a given element. An element the graph does not hold cuts to an empty graph.
func Roots ¶
Roots lists the elements the graph declares and nothing in it owns, in the graph's subject order: the elements a document's namespace would hold.
func Scoped ¶
Scoped returns graph with scope stamped on every root element — each element of the graph that nothing in it owns and that is not a library reference — in place of any scope it carried, so the notation written from it declares the ProjectRef a later sync finds the branch by.
func WithoutDerived ¶
WithoutDerived returns graph without the sysml: properties the metamodel derives on each subject's metaclass, readerDerived aside: what a publish without derived properties sends. The pilot's sends none of them; this writer's reader needs most, so only the ones it recomputes are left out.
Types ¶
type AmbiguousNameError ¶
AmbiguousNameError names the projects that share one name, so the caller can pick one by id.
func (*AmbiguousNameError) Error ¶
func (e *AmbiguousNameError) Error() string
func (*AmbiguousNameError) Is ¶
func (e *AmbiguousNameError) Is(target error) bool
type Applied ¶
Applied is what one apply left behind: the commit it ended on and how many changes of each kind landed. Commit is empty when the repository already agreed with the model.
func Apply ¶
func Apply(ctx context.Context, repo Repository, set *reposync.ChangeSet, state *reposync.State, message string) (*Applied, error)
Apply writes an appliable change set and advances the state: to the last commit written, or, when nothing needed writing, to the head the repository was read at. A partial apply returns the result with the error.
type NotFoundError ¶
type NotFoundError struct {
QualifiedName string
}
NotFoundError is a qualified name no element of the graph carries.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Repository ¶
type Repository interface {
reposync.Committer
// Head is the branch's current head commit, empty for a branch no commit
// has reached yet.
Head(ctx context.Context) (string, error)
// Seen is the head the last read stood at or the last commit written.
Seen() string
// Resume records the last-seen commit a saved state carries.
Resume(commit string)
// Graph reads the branch at its head.
Graph(ctx context.Context) (*rdf.Graph, error)
// GraphAt reads the branch as one commit left it.
GraphAt(ctx context.Context, commit string) (*rdf.Graph, error)
}
Repository is a project branch a sync reads and writes: the surface sysmlapi.Repository and flexo.Repository both offer.