Learn R Programming

automerge (version 0.3.0)

am_change_deps: Get the dependencies of a change

Description

Returns the hashes of the changes that this change depends on (i.e., its parent changes in the causal graph). The first change in a document has no dependencies.

Usage

am_change_deps(change)

Value

A list of raw vectors (change hashes), each 32 bytes. Returns an empty list for the first change in a document.

Arguments

change

An am_change object (from am_get_changes(), am_get_changes(), or am_change_from_bytes())

Examples

Run this code
doc <- am_create()
am_put(doc, AM_ROOT, "x", 1)
am_commit(doc, "First")
am_put(doc, AM_ROOT, "y", 2)
am_commit(doc, "Second")

history <- am_get_changes(doc)
deps1 <- am_change_deps(history[[1]])
length(deps1)  # 0 (first change has no deps)

deps2 <- am_change_deps(history[[2]])
length(deps2)  # 1 (depends on first change)

am_close(doc)

Run the code above in your browser using DataLab