tests: make test-config-env.py a little less hacky
Overriding os.path.isdir to always returns False is very
confusing. Let's make it more explicit by specifically not returning
any defaultrc/ configs.
Differential Revision: https://phab.mercurial-scm.org/D7623
help: get helptext/ data from `resources` module if available
For PyOxidizer, we need to read configs using the `resources`
module. This patch makes it so we use that module if available
(i.e. Python >= 3.7). It does that by adding a new `open_resource()`
function to our `resourceutil` module.
Tested by running `$PYTHON ./hg help pager` for each $PYTHON in
{python2, python3.6, python3.7}.
Differential Revision: https://phab.mercurial-scm.org/D7622
pycompat: allow pycompat.sysbytes() even if input already is bytes
pycompat.sysstr() on py3 accepts an input that's already str
(i.e. unicode). This patch makes it so pycompat.sysbytes() on py3
accepts an input that's already bytes. Allowing that makes it possible
to do pycompat.sysbytes(fp.name) where fp.name is either bytes or
unicode, as we'll get when fp can come from either open() or
resources.open_binary().
Differential Revision: https://phab.mercurial-scm.org/D7621
rust-cpython: do not convert warning pattern to utf-8 bytes
On Unix, both Rust Path and Mercurial expect a locale-dependent bytes,
and we don't support Windows yet.
Differential Revision: https://phab.mercurial-scm.org/D7614
rust-cpython: import utils::files::* function at module level
IIRC, it's common in Rust to call functions with the module prefix.
Differential Revision: https://phab.mercurial-scm.org/D7613
py3: send bytes from Rust-created warning patterns
Python code expects bytes in both Python 2 and Python 3, so we should send
bytes.
Differential Revision: https://phab.mercurial-scm.org/D7612
py3: pass bytes to `configint` and `configbool`
Both functions require bytes, even in Python 3.
Differential Revision: https://phab.mercurial-scm.org/D7611
rust-threads: force Rayon to respect the worker count in config
As per the inline comment, this is a workaround because Rust code does not yet
know how to read config files.
Differential Revision: https://phab.mercurial-scm.org/D7610
rust-dirs: handle forgotten `Result`s
In
1fe2e574616e I introduced a temporary bugfix to align Rust code with a new
behavior from C/Python and forgot about a few `Result`s (cargo's compiler cache
does not re-emit warnings on cached modules). This fixes it.
For the record, I am still unsure that this behavior change is a good idea.
Note: I was already quite unhappy with the setters and getters for the
`DirstateMap` and, indirectly, `Dirs`, and this only further reinforces my
feelings. I hope we can one day fix that situation at the type level; Georges
Racinet and I were just talking about devising a POC for using the builder
pattern in the context of FFI with Python, we'll see what comes out of it.
Differential Revision: https://phab.mercurial-scm.org/D7609