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 READABLE_TREE with type 'a or_error := 'a or_error
val read : t -> Datakit_path.t -> [ `File of Cstruct.t | `Dir of string list | `Link of string ] or_error Lwt.t
read t path is the contents of the object at the
val stat : t -> Datakit_path.t -> stat option or_error Lwt.t
stat t path is the metadata of the object at
val exists : t -> Datakit_path.t -> bool or_error Lwt.t
exists t path is
stat t path isn't
val exists_file : t -> Datakit_path.t -> bool or_error Lwt.t
exists_file t path is similar to
exists but for files only.
val exists_dir : t -> Datakit_path.t -> bool or_error Lwt.t
exists_dir t path is similar to
exists but for directories only.
val read_file : t -> Datakit_path.t -> Cstruct.t or_error Lwt.t
read_file t path resolves
path to a file, or returns an error if it isn't a file.
val read_dir : t -> Datakit_path.t -> string list or_error Lwt.t
read_dir t path resolves
path to a directory, or returns an error if it isn't one.
val read_link : t -> Datakit_path.t -> string or_error Lwt.t
read_link t path resolves
path to a symlink, or returns an error if it isn't one.
val create_dir : t -> Datakit_path.t -> unit or_error Lwt.t
create_dir t path creates the directory
val create_file : t -> Datakit_path.t -> ?executable:bool -> Cstruct.t -> unit or_error Lwt.t
create_file t path ?executable content creates the file
val create_symlink : t -> Datakit_path.t -> string -> unit or_error Lwt.t
create_symlink t path target creates the symlink
val replace_file : t -> Datakit_path.t -> Cstruct.t -> unit or_error Lwt.t
replace_file t path new_content changes the content of the existing file
val create_or_replace_file : t -> Datakit_path.t -> Cstruct.t -> unit or_error Lwt.t
create_or_replace_file t path content uses either
replace_file as appropriate to set the contents.
val set_executable : t -> Datakit_path.t -> bool -> unit or_error Lwt.t
set_executable t path flag marks the file at
path as executable or not.
val remove : t -> Datakit_path.t -> unit or_error Lwt.t
remove t path removes
path is a directory then the entire subtree is removed.
val rename : t -> Datakit_path.t -> string -> unit or_error Lwt.t
rename t path new_name changes the basename of
new_name. Note: it is only possible to rename within a directory (this is a 9p limitation).
val truncate : t -> Datakit_path.t -> int64 -> unit or_error Lwt.t
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_path.t -> unit or_error Lwt.t
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_path.t list) or_error Lwt.t
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_path.t list or_error Lwt.t
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.
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.