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 result := 'a result
exists_file t path is similar to
exists but for files only.
exists_dir t path is similar to
exists but for directories only.
read_file t path resolves
path to a file, or returns an error if it isn't a file.
read_dir t path resolves
path to a directory, or returns an error if it isn't one.
read_link t path resolves
path to a symlink, or returns an error if it isn't one.
create_file t path ?executable content creates the file
create_symlink t path target creates the symlink
replace_file t path new_content changes the content of the existing file
create_or_replace_file t path content uses either
replace_file as appropriate to set the contents.
set_executable t path flag marks the file at
path as executable or not.
remove t path removes
path is a directory then the entire subtree is removed.
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.
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.
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.
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.
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.