Crate libpijul

source ·
Expand description

This crate contains the core API to access Pijul repositories.

The key object is a Repository, on which Txn (immutable transactions) and MutTxn (mutable transactions) can be started, to perform a variety of operations.

Another important object is a Patch, which encodes two different pieces of information:

  • Information about deleted and inserted lines between two versions of a file.

  • Information about file moves, additions and deletions.

The standard layout of a repository is defined in module fs_representation, and mainly consists of a directory called .pijul at the root of the repository, containing:

  • a directory called pristine, containing a Sanakirja database storing most of the repository information.

  • a directory called patches, actually containing the patches, where each patch is a gzipped compression of the bincode encoding of the patch::Patch type.

At the moment, users of this library, such as the Pijul command-line tool, may use other files in the .pijul directory, such as user preferences, or information about remote branches and repositories.

Re-exports

pub use patch::Patch;
pub use patch::PatchHeader;

Modules

Layout of a repository (files in .pijul) on the disk. This module exports both high-level functions that require no knowledge of the repository, and lower-level constants documented on pijul.org/documentation/repository, used for instance for downloading files from remote repositories.
The data structure of the in-memory version of Pijul’s main datastructure, used to edit and organise it (for instance before a record or before outputting a file).
Definition of patches, and a number of methods.

Structs

The representation of a branch. The “application number” of a patch on a branch is the state of the application counter at the time the patch has been applied to that branch.
The target half of an edge in the repository graph.
Possible flags of edges.
File metadata, essentially flags to indicate permissions and nature of a file tracked by Pijul.
Common type for both mutable transactions (MutTxn) and immutable transaction (Txn). All of Txn’s methods are also MutTxn’s methods.
A unique identifier for files or directories in the actual file system, to map “files from the graph” to real files.
A node in the repository graph, made of a patch internal identifier, and a line identifier in that patch.
An index for file chunks within a patch.
An internal patch identifier, less random than external patch identifiers, but more stable in time, and much smaller.
A repository. All operations on repositories must be done via transactions.
A borrowed version of SmallStr.
A string of length at most 255, with a more compact on-disk encoding.

Enums

The external hash of patches.
A borrowed version of Hash.
An account of the files that have been added, moved or deleted, as returned by record, and used by apply (when applying a patch created locally) to update the trees and inodes databases.
Iterator over parts of a value. On values of size at most 4096 bytes, the iterator will run exactly once. On larger values, it returns all parts of the value, in order.

Constants

The default name of a branch, for users who start working before choosing branch names (or like the default name, “master”).
The Inode representing the root of the repository (on the actual file system).
The node at the root of the repository graph.

Traits

Trait for operations common to mutable and immutable transactions.

Functions

Apply a number of patches, guessing the new repository size. If this fails, the repository size is guaranteed to have been increased by at least some pages, and it is safe to call this function again.
Apply a number of patches, guessing the new repository size. If this fails, the repository size is guaranteed to have been increased by at least some pages, and it is safe to call this function again.
A version of apply_resize with the patches list already loaded.
Open the repository, and unrecord the patch, without increasing the size. If this fails, the repository file is guaranteed to have been increased by increase bytes.

Type Definitions

The type of patch application numbers.
A mutable transaction on a repository.
An immutable transaction on a repository.