Commit Graph

19 Commits

Author SHA1 Message Date
Mark Thomas
398e29caa1 treedirstate: ensure appended data is flushed to disk
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
2017-12-11 08:32:08 -08:00
Mark Thomas
567afadaf1 treedirstate: de-genericize Dirstate
Remove the type parameter from Dirstate.  It's not necessary, and complicates
the implementation.

Differential Revision: https://phab.mercurial-scm.org/D1512
2017-11-28 04:51:38 -08:00
Mark Thomas
2328feb895 treedirstate: extract serialization methods to separate module
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
2017-11-28 04:51:38 -08:00
Mark Thomas
faadc08f74 setup: build treedirstate and rusttreedirstate packages
The treedirstate and rusttreedirstate packages are only built if a suitable
version of Cargo is available.

Differential Revision: https://phab.mercurial-scm.org/D1412
2017-11-28 04:51:38 -08:00
Mark Thomas
6f77bc33b9 treedirstate: implement casefolding maps for case insensitive filesystems
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
2017-11-28 04:51:38 -08:00
Mark Thomas
26e77a0173 treedirstate: use vlqencoding for numbers
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
2017-11-28 04:51:38 -08:00
Mark Thomas
dc03a8d3da treedirstate: auto-repack treedirstate once it reaches 3x its original size
Differential Revision: https://phab.mercurial-scm.org/D1407
2017-11-28 04:51:38 -08:00
Mark Thomas
9fc8a5ecf5 treedirstate: implement efficient case collision detection
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
2017-11-28 04:51:38 -08:00
Mark Thomas
437cacd205 treedirstate: allow absent non-normal sets
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
2017-11-28 04:51:38 -08:00
Mark Thomas
d0a2fc313b treedirstate: clear ambiguous times when writing the dirstate
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
2017-11-28 04:51:38 -08:00
Mark Thomas
842e5de551 treedirstate: better iteration using visitor pattern
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
2017-11-28 04:51:38 -08:00
Mark Thomas
71fa542789 treedirstate: cache dirstate data when iterating all files
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
2017-11-28 04:51:38 -08:00
Mark Thomas
92b2ce7563 treedirstate: add Python linkage
Adds a python module that uses the Rust treedirstate to replace the dirstate
map.

Differential Revision: https://phab.mercurial-scm.org/D1401
2017-11-28 04:51:38 -08:00
Mark Thomas
b0b8543136 treedirstate: add Dirstate
A Dirstate object links a Tree to an underlying Store and StoreView
implementation.

Differential Revision: https://phab.mercurial-scm.org/D1400
2017-11-28 04:51:38 -08:00
Mark Thomas
7bc6c8d231 treedirstate: add Tree
Adds Tree, an implementation of a dirstate tree.

Differential Revision: https://phab.mercurial-scm.org/D1399
2017-11-28 04:51:38 -08:00
Mark Thomas
5294b5f050 treedirstate: add FileStore
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
2017-11-28 04:51:38 -08:00
Mark Thomas
1537d3833e treedirstate: add Store and StoreView traits
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
2017-11-28 04:51:38 -08:00
Mark Thomas
5931d6cf5d treedirstate: add vecmap implementation
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
2017-11-28 04:51:38 -08:00
Mark Thomas
21b68a9e17 treedirstate: create empty Rust project
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
2017-11-28 04:51:38 -08:00