A dirstate update that appends data to the treedirstate tree file, followed by
a hard reboot before the filesystem cache is flushed, can result in a dirstate
tree root that is referred to by the dirstate file, but does not contain the
correct data. Ensure the appended data is synced to disk before returning from
`Store.flush()`.
Differential Revision: https://phab.mercurial-scm.org/D1654
Remove the type parameter from Dirstate. It's not necessary, and complicates
the implementation.
Differential Revision: https://phab.mercurial-scm.org/D1512
The serialization and deserialization of the treedirstate tree file is
scattered across various functions in several files. Gather these together in
a single module so that the file format is obvious.
Differential Revision: https://phab.mercurial-scm.org/D1510
The treedirstate and rusttreedirstate packages are only built if a suitable
version of Cargo is available.
Differential Revision: https://phab.mercurial-scm.org/D1412
The dirfoldmap and filefoldmap on the dirstatemap object map from normalized
filename to the form it appears in the dirstate (denormalized form).
The dicts these functions return are also modified by the dirstate with
filenames discovered by examining the disk, so use an overlay dictionary backed
by the real dirstate to allow this to happen.
Differential Revision: https://phab.mercurial-scm.org/D1409
Change to use VLQ-encoded numbers for everything in the tree file. Block sizes
remain as u32s so that they can be read by the store in a single read
operation, but everything else is a VLQ as it is generally smaller and more
futureproof.
Differential Revision: https://phab.mercurial-scm.org/D1408
Add a mechanism to the dirstate trees to allow lookups based on filtered views
of the keys. For a given filtering function, this returns one (if any) of the
keys for which filter(key) matches the input. The filtered values in each
directory node are cached to improve subsequent lookups.
Differential Revision: https://phab.mercurial-scm.org/D1406
If the non-normal sets get particularly large, the dirstate root file can get
large again. Avoid this happening by not storing large sets, and instead
recalculating them on-demand as needed. Large sets of non-normal files should
be rare, so this shouldn't be a performance hit in the normal case.
Differential Revision: https://phab.mercurial-scm.org/D1405
When writing out changes to the dirstate, mark any files that have the same
mtime as the current time as requiring lookup. This matches the behaviour
of the C-based pack_dirstate.
Differential Revision: https://phab.mercurial-scm.org/D1404
In order to allow the python interface code to perform actions on each node in
the tree without creating python-specific interfaces in the generic Rust code,
add a method of iterating over the tree, executing a closure at each file.
Use this to implement the methods that give iterators over the filenames in the
tree. This performs better than the get_first/get_next-style iterators.
Differential Revision: https://phab.mercurial-scm.org/D1403
Iterations over all files will cause most of the file to be read in a piecemeal
fashion. This will be inefficient on disks with slow seek times. Instead,
read the whole file into memory before iterating.
Differential Revision: https://phab.mercurial-scm.org/D1402
Adds FileStore, an implementation of the Store and StoreView traits that uses a
file on disk to store the data, and reads and writes blocks using file I/O.
Differential Revision: https://phab.mercurial-scm.org/D1398
These traits represent abstract store objects than can store arbitrary data
blocks with store-generated indexes.
A NullStore implementation is provided which acts an always-empty StoreView.
Differential Revision: https://phab.mercurial-scm.org/D1397
This adds an implementation of an ordered map that uses a vector pairs, sorted
by the key.
This is largely compatibly with std::collections::BTreeMap, but has performance
characteristics more suited for use in treedirstate.
Differential Revision: https://phab.mercurial-scm.org/D1396
Create an empty Rust project for treedirstate. This will be a
re-implementation of the dirstate map using a tree structure, where nodes in
the tree are directories, and leaves are files.
Differential Revision: https://phab.mercurial-scm.org/D1395