All changes to a branch are made in transactions. When a transaction is committed, it is merged with the current contents of the branch.
include Datakit_client.READABLE_TREE with type 'a result := 'a result
val read : t -> Datakit_client.Path.t -> Datakit_client.value result
read t path is the contents of the object at the
val stat : t -> Datakit_client.Path.t -> Datakit_client.stat option result
stat t path is the metadata of the object at
val exists : t -> Datakit_client.Path.t -> bool result
exists t path is
stat t path isn't
val exists_file : t -> Datakit_client.Path.t -> bool result
exists_file t path is similar to
exists but for files only.
val exists_dir : t -> Datakit_client.Path.t -> bool result
exists_dir t path is similar to
exists but for directories only.
val read_file : t -> Datakit_client.Path.t -> Cstruct.t result
read_file t path resolves
path to a file, or returns an error if it isn't a file.
val read_dir : t -> Datakit_client.Path.t -> string list result
read_dir t path resolves
path to a directory, or returns an error if it isn't one.
val read_link : t -> Datakit_client.Path.t -> string result
read_link t path resolves
path to a symlink, or returns an error if it isn't one.
val create_dir : t -> Datakit_client.Path.t -> unit result
create_dir t path creates the directory
val create_file : t -> Datakit_client.Path.t -> ?executable:bool -> Cstruct.t -> unit result
create_file t path ?executable content creates the file
val create_symlink : t -> Datakit_client.Path.t -> string -> unit result
create_symlink t path target creates the symlink
val replace_file : t -> Datakit_client.Path.t -> Cstruct.t -> unit result
replace_file t path new_content changes the content of the existing file
val create_or_replace_file : t -> Datakit_client.Path.t -> Cstruct.t -> unit result
create_or_replace_file t path content uses either
replace_file as appropriate to set the contents.
val set_executable : t -> Datakit_client.Path.t -> bool -> unit result
set_executable t path flag marks the file at
path as executable or not.
val remove : t -> Datakit_client.Path.t -> unit result
remove t path removes
path is a directory then the entire subtree is removed.
val truncate : t -> Datakit_client.Path.t -> int64 -> unit result
truncate t path length sets the length of the file at
length is longer than the current length, the file is padded with zero bytes.
val make_dirs : t -> Datakit_client.Path.t -> unit result
make_dirs t path ensures that
path exists and is a directory, creating it and any missing parents as necessary.
commit t ~message creates a new commit with the given log message and the current contents of the transaction and then merges it into the branch from which the transaction was created. The transaction cannot be used after calling this.
abort t aborts the transaction without committing it. The transaction cannot be used after calling this.
Merging and history
When performing a merge, these three directories can be used to calculate the final result.
ours is the previous contents of the transaction,
theirs is the commit being merged and
base is a least common ancestor. If there is no common ancestor then
base is an empty tree.
val merge : t -> Commit.t -> (merge_inputs * Datakit_client.Path.t list) result
merge t commit merges
commit into the transaction. It performs any trivial merges it can and returns
conflicts) to allow you to resolve the remaining ones. You must write to each path in
conflicts at least once before you can commit the transaction. You may perform multiple merges in one transaction, but the
merge_inputs returned is only valid until the start of the next merge.
parents t is the parents of the transaction (that is, the parents of the commit that would be generated if you committed now.
set_parents t new_parents replaces the current list of parents. Note that this does not perform a merge - it only affects the metadata. Note also that
merge automatically updates the parents, so it is not necessary to call it manually in that case.
val conflicts : t -> Datakit_client.Path.t list result
conflicts t returns the current list of paths that had merge conflicts and have not been written to since. It is not possible to commit while this is non-empty.
val diff : t -> Commit.t -> Datakit_client.Path.t Datakit_client.diff list result
diff t c returns the paths differences between
val closed : t -> bool
closed t is true if
t is closed and thus it is not valid to read/write on it anymore.