Mercurial > hg
view rust/README.rst @ 35665:1ad1e59b405e
lfs: control tracked file selection via a tracked file
Since the lfs tracking policy can dramatically affect the repository, it makes
more sense to have the policy file checked in, than to rely on all developers
configuring their .hgrc properly. The inspiration for this is the .hgeol file.
The configuration lives under '[track]', so that other things can be added in
the future. Eventually, the config option should be limited to `convert` only.
If the file can't be parsed for any reason (including unrecognized elements of
the minifileset language), the commit will abort until the problem is corrected.
This seems more useful than the warning that hgeol emits, and has no effect on
reading the data, so there's no compatibility concerns.
My initial thought was to read the file and change each "key = value" line into
"((key) & (value))", so that each line could be ORed together, and make a single
pass at compiling. Unfortunately, that prevents exclusions if there's a
catchall rule. Consider what happens to a large *.c file here:
[track]
**.c = none()
** = size('>1MB')
# ((**.c) & (none())) | ((**) & (size('>1MB'))) => anything > 1MB
I also thought about having separate [include] and [exclude] sections. But that
just seems to open things up to user mistakes. Consider:
[include]
**.zip = all()
**.php = size('>10MB')
[exclude]
**.zip = all() # Who wins?
**.php = none() # Effectively 'all()' (i.e. nothing excluded), or >10MB ?
Therefore, it just compiles each key and value separately, and walks until the
key matches something. I'm not sure how to enforce just file patterns on LHS
without leaking knowledge about the minifileset here. That means this will
allow odd looking lines like this:
[track]
**.c | **.txt = none()
But that's also fewer lines to compile, so slightly more efficient? Some things
like 'none()' won't work as expected on LHS though, because that won't match, so
that line is skipped. For now, these quirks are not mentioned in the
documentation.
Jun previously expressed concern about efficiency when scaling to large repos,
so I tried avoiding 'repo[None]'. (localrepo.commit() gets repo[None] already,
but doesn't tie it to the workingcommitctx used here.) Therefore, I looked at
the passed context for 'AMR' status. But that doesn't help with the normal case
where the policy file is tracked, but clean. That requires looking up p1() to
read the file. I don't see any way to get the content of one file without first
creating the full parent context.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 14 Jan 2018 18:12:51 -0500 |
parents | 964212780daf |
children | 8a3b045d9086 |
line wrap: on
line source
=================== Mercurial Rust Code =================== This directory contains various Rust code for the Mercurial project. The top-level ``Cargo.toml`` file defines a workspace containing all primary Mercurial crates. Building ======== To build the Rust components:: $ cargo build If you prefer a non-debug / release configuration:: $ cargo build --release Features -------- The following Cargo features are available: localdev (default) Produce files that work with an in-source-tree build. In this mode, the build finds and uses a ``python2.7`` binary from ``PATH``. The ``hg`` binary assumes it runs from ``rust/target/<target>hg`` and it finds Mercurial files at ``dirname($0)/../../../``. Build Mechanism --------------- The produced ``hg`` binary is *bound* to a CPython installation. The binary links against and loads a CPython library that is discovered at build time (by a ``build.rs`` Cargo build script). The Python standard library defined by this CPython installation is also used. Finding the appropriate CPython installation to use is done by the ``python27-sys`` crate's ``build.rs``. Its search order is:: 1. ``PYTHON_SYS_EXECUTABLE`` environment variable. 2. ``python`` executable on ``PATH`` 3. ``python2`` executable on ``PATH`` 4. ``python2.7`` executable on ``PATH`` Additional verification of the found Python will be performed by our ``build.rs`` to ensure it meets Mercurial's requirements. Details about the build-time configured Python are built into the produced ``hg`` binary. This means that a built ``hg`` binary is only suitable for a specific, well-defined role. These roles are controlled by Cargo features (see above). Running ======= The ``hgcli`` crate produces an ``hg`` binary. You can run this binary via ``cargo run``:: $ cargo run --manifest-path hgcli/Cargo.toml Or directly:: $ target/debug/hg $ target/release/hg You can also run the test harness with this binary:: $ ./run-tests.py --with-hg ../rust/target/debug/hg .. note:: Integration with the test harness is still preliminary. Remember to ``cargo build`` after changes because the test harness doesn't yet automatically build Rust code.