Documentation
¶
Index ¶
- Constants
- Variables
- func AssertDir(t *testing.T, lkr *Linker, path string, shouldExist bool)
- func Copy(lkr *Linker, nd n.ModNode, dstPath string) (newNode n.ModNode, err error)
- func Log(lkr *Linker, fn func(cmt *n.Commit) error) error
- func Mkdir(lkr *Linker, repoPath string, createParents bool) (dir *n.Directory, err error)
- func Move(lkr *Linker, nd n.ModNode, dstPath string) error
- func MustCommit(t *testing.T, lkr *Linker, msg string) *n.Commit
- func MustCommitIfPossible(t *testing.T, lkr *Linker, msg string) *n.Commit
- func MustLookupDirectory(t *testing.T, lkr *Linker, path string) *n.Directory
- func MustMkdir(t *testing.T, lkr *Linker, repoPath string) *n.Directory
- func MustModify(t *testing.T, lkr *Linker, file *n.File, seed int)
- func MustMove(t *testing.T, lkr *Linker, nd n.ModNode, destPath string) n.ModNode
- func MustRemove(t *testing.T, lkr *Linker, nd n.ModNode) n.ModNode
- func MustTouch(t *testing.T, lkr *Linker, touchPath string, seed byte) *n.File
- func MustTouchAndCommit(t *testing.T, lkr *Linker, path string, seed byte) (*n.File, *n.Commit)
- func Remove(lkr *Linker, nd n.ModNode, createGhost, force bool) (parentDir *n.Directory, ghost *n.Ghost, err error)
- func Stage(lkr *Linker, repoPath string, contentHash, backendHash h.Hash, size uint64, ...) (file *n.File, err error)
- func StageFromFileNode(lkr *Linker, f *n.File) (*n.File, error)
- func WithDummyKv(t *testing.T, fn func(kv db.Database))
- func WithDummyLinker(t *testing.T, fn func(lkr *Linker))
- func WithLinkerPair(t *testing.T, fn func(lkrSrc, lkrDst *Linker))
- func WithReloadingLinker(t *testing.T, fn1 func(lkr *Linker), fn2 func(lkr *Linker))
- type GarbageCollector
- type Linker
- func (lkr *Linker) AddMoveMapping(from, to n.Node) (err error)
- func (lkr *Linker) Atomic(fn func() error) (err error)
- func (lkr *Linker) AtomicWithBatch(fn func(batch db.Batch) error) (err error)
- func (lkr *Linker) CheckoutCommit(cmt *n.Commit, force bool) error
- func (lkr *Linker) CommitByHash(hash h.Hash) (*n.Commit, error)
- func (lkr *Linker) CommitByIndex(index int64) (*n.Commit, error)
- func (lkr *Linker) DirectoryByHash(hash h.Hash) (*n.Directory, error)
- func (lkr *Linker) ExpandAbbrev(abbrev string) (h.Hash, error)
- func (lkr *Linker) FileByHash(hash h.Hash) (*n.File, error)
- func (lkr *Linker) FilesByContents(contents []h.Hash) (map[string]*n.File, error)
- func (lkr *Linker) HaveStagedChanges() (bool, error)
- func (lkr *Linker) Head() (*n.Commit, error)
- func (lkr *Linker) IterAll(from, to *n.Commit, fn func(n.ModNode, *n.Commit) error) error
- func (lkr *Linker) ListRefs() ([]string, error)
- func (lkr *Linker) LookupDirectory(repoPath string) (*n.Directory, error)
- func (lkr *Linker) LookupFile(repoPath string) (*n.File, error)
- func (lkr *Linker) LookupGhost(repoPath string) (*n.Ghost, error)
- func (lkr *Linker) LookupModNode(repoPath string) (n.ModNode, error)
- func (lkr *Linker) LookupModNodeAt(cmt *n.Commit, repoPath string) (n.ModNode, error)
- func (lkr *Linker) LookupNode(repoPath string) (n.Node, error)
- func (lkr *Linker) LookupNodeAt(cmt *n.Commit, repoPath string) (n.Node, error)
- func (lkr *Linker) MakeCommit(author string, message string) error
- func (lkr *Linker) MemIndexAdd(nd n.Node)
- func (lkr *Linker) MemIndexClear()
- func (lkr *Linker) MemIndexPurge(nd n.Node)
- func (lkr *Linker) MemIndexSwap(nd n.Node, oldHash h.Hash)
- func (lkr *Linker) MemSetRoot(root *n.Directory)
- func (lkr *Linker) MetadataGet(key string) ([]byte, error)
- func (lkr *Linker) MetadataPut(key string, value []byte) error
- func (lkr *Linker) MoveEntryPoint(nd n.Node) (n.Node, MoveDir, error)
- func (lkr *Linker) MoveMapping(cmt *n.Commit, nd n.Node) (n.Node, MoveDir, error)
- func (lkr *Linker) NextInode() uint64
- func (lkr *Linker) NodeByHash(hash h.Hash) (n.Node, error)
- func (lkr *Linker) NodeByInode(uid uint64) (n.Node, error)
- func (lkr *Linker) Owner() (string, error)
- func (lkr *Linker) RemoveRef(refname string) error
- func (lkr *Linker) ResolveDirectory(dirpath string) (*n.Directory, error)
- func (lkr *Linker) ResolveNode(nodePath string) (n.Node, error)
- func (lkr *Linker) ResolveRef(refname string) (n.Node, error)
- func (lkr *Linker) Root() (*n.Directory, error)
- func (lkr *Linker) SaveRef(refname string, nd n.Node) error
- func (lkr *Linker) SetMergeMarker(with string, remoteHead h.Hash) error
- func (lkr *Linker) SetOwner(owner string) error
- func (lkr *Linker) StageNode(nd n.Node) error
- func (lkr *Linker) Status() (*n.Commit, error)
- type MoveDir
Constants ¶
const ( MoveDirUnknown = iota MoveDirSrcToDst MoveDirDstToSrc MoveDirNone )
Variables ¶
var (
ErrIsGhost = errors.New("Is a ghost")
)
Functions ¶
func Mkdir ¶
Mkdir creates the directory at repoPath and any intermediate directories if createParents is true. It will fail if there is already a file at `repoPath` and it is not a directory.
func MustCommitIfPossible ¶
func MustLookupDirectory ¶
func MustTouchAndCommit ¶
func Remove ¶
func Remove(lkr *Linker, nd n.ModNode, createGhost, force bool) (parentDir *n.Directory, ghost *n.Ghost, err error)
Remove removes a single node from a directory. `nd` is the node that shall be removed and may not be root. The parent directory is returned.
func WithDummyLinker ¶
func WithLinkerPair ¶
Types ¶
type GarbageCollector ¶
type GarbageCollector struct {
// contains filtered or unexported fields
}
func NewGarbageCollector ¶
func (*GarbageCollector) Run ¶
func (gc *GarbageCollector) Run(allObjects bool) error
type Linker ¶
type Linker struct {
// contains filtered or unexported fields
}
Linker implements the basic logic of brig's data model It uses an underlying key/value database to storea a Merkle-DAG with versioned metadata, similar to what git does internally.
func NewLinker ¶
NewFilesystem returns a new lkr, ready to use. It assumes the key value store is working and does no check on this.
func (*Linker) AddMoveMapping ¶
AddMoveMapping takes note that the the node `from` has been moved to `to` in the staging commit.
func (*Linker) AtomicWithBatch ¶
Atomic will execute `fn` in one transaction. If anything goes wrong (i.e. `fn` returns an error)
func (*Linker) CheckoutCommit ¶
CheckoutCommit resets the current staging commit back to the commit referenced by cmt. If force is false, it will check if there any staged errors in the staging area and return ErrStageNotEmpty if there are any. If force is true, all changes will be overwritten.
func (*Linker) CommitByHash ¶
CommitByHash lookups a commit by it's hash. If the commit could not be found, nil is returned.
func (*Linker) DirectoryByHash ¶
DirectoryByHash calls NodeByHash and attempts to convert it to a Directory as convinience.
func (*Linker) ExpandAbbrev ¶
ExpandAbbrev tries to find an object reference that stats with `abbrev`. If so, it will return the respective hash for it. If none is found, it is considered as an error. If more than one was found ie.ErrAmbigious is returned.
func (*Linker) FileByHash ¶
FileByHash calls NodeByHash and converts the result to a File.
func (*Linker) FilesByContents ¶
func (*Linker) HaveStagedChanges ¶
HaveStagedChanges returns true if there were changes in the staging area. If an error occurs, the first return value is undefined.
func (*Linker) IterAll ¶
IterAll goes over all nodes in the commit range `from` until (including) `to`. Already visited nodes will not be visited again if they did not change. If `from` is nil, HEAD is assumed. If `to` is nil, INIT is assumed.
func (*Linker) LookupDirectory ¶
LookupDirectory calls LookupNode and converts the result to a Directory.
func (*Linker) LookupFile ¶
LookupFile calls LookupNode and converts the result to a file.
func (*Linker) LookupGhost ¶
LookupGhost calls LookupNode and converts the result to a ghost.
func (*Linker) LookupModNodeAt ¶
func (*Linker) LookupNode ¶
LookupNode takes the root node and tries to resolve the path from there. Deleted paths are recognized in contrast to ResolveNode. If a path does not exist NoSuchFile is returned.
func (*Linker) LookupNodeAt ¶
TODO: Write tests for the At() variants.
func (*Linker) MakeCommit ¶
MakeCommit creates a new full commit in the version history. The current staging commit is finalized with `author` and `message` and gets saved. A new, identical staging commit is created pointing to the root of the now new HEAD.
func (*Linker) MemIndexAdd ¶
MemIndexAdd adds `nd` to the in memory index.
func (*Linker) MemIndexClear ¶
func (lkr *Linker) MemIndexClear()
MemIndexClear resets the memory index to zero. This should not be called mid-flight in operations, but should be okay to call between atomic operations.
func (*Linker) MemIndexPurge ¶
MemIndexPurge removes `nd` from the memory index.
func (*Linker) MemIndexSwap ¶
MemIndexSwap updates an entry of the in memory index, by deleting the old entry referenced by oldHash (may be nil). This is necessary to ensure that old hashes do not resolve to the new, updated instance. If the old instance is needed, it will be loaded as new instance. You should not need to call this function, except when implementing own Nodes.
func (*Linker) MemSetRoot ¶
MemSetRoot sets the current root, but does not store it yet. It's supposed to be called after in-memory modifications. Only implementors of new Nodes might need to call this function.
func (*Linker) MetadataGet ¶
MetadataGet retriesves a previosuly put key value pair. It will return nil if no such value could be retrieved.
func (*Linker) MetadataPut ¶
MetadataPut remembers a value persisntenly identified by `key`. It can be used as single-level key value store for user purposes.
func (*Linker) MoveEntryPoint ¶
func (*Linker) MoveMapping ¶
MoveMapping will lookup if the node pointed to by `nd` was part of a moving operation and if so, to what node it was moved and if it was the source or the dest node.
func (*Linker) NextInode ¶
NextInode() returns a unique identifier, used to identify a single node. You should not need to call this function, except when implementing own nodes.
func (*Linker) NodeByHash ¶
NodeByHash returns the node identified by hash. If no such hash could be found, nil is returned.
func (*Linker) NodeByInode ¶
NodeByInode resolves a node by it's unique ID. It will return nil if no corresponding node was found.
func (*Linker) ResolveDirectory ¶
ResolveDirectory calls ResolveNode and converts the result to a Directory. This only accesses nodes from the filesystem and does not differentiate between ghosts and living nodes.
func (*Linker) ResolveNode ¶
ResolveNode resolves a path to a hash and resolves the corresponding node by calling NodeByHash(). If no node could be resolved, nil is returned. It does not matter if the node was deleted in the meantime. If so, a Ghost node is returned which stores the last known state.
func (*Linker) ResolveRef ¶
ResolveRef resolves the hash associated with `refname`. If the ref could not be resolved, ErrNoSuchRef is returned. Typically, Node will be a Commit. But there are no technical restrictions on which node typ to use.
func (*Linker) Root ¶
Root returns the current root directory of CURR. It is never nil when err is nil.
func (*Linker) SaveRef ¶
SaveRef stores a reference to `nd` persistently. The caller is responsbiel to ensure that the node is already in the blockstore, otherwise it won't be resolvable.
func (*Linker) SetMergeMarker ¶
SetMergeMarker sets the current status to be a merge commit. Note that this function only will have a result when MakeCommit() is called afterwards. Otherwise, the changes will not be written to disk.