This is an archive of the discontinued Mercurial Phabricator instance.

hg-core: vendor Facebook's configparser crate
Needs RevisionPublic

Authored by indygreg on Dec 7 2019, 3:17 PM.

Details

Reviewers
baymax
Group Reviewers
hg-reviewers
Summary

I added a number of files from https://github.com/facebookexperimental/eden
at commit b745b4421b8a8b130d2094b598cedf65655410ec. Files are unmodified from
their original versions. However, the paths are different: I've put all
files in the same directory. And I've removed some files we don't care about
(such as the C++ bindings and CMake rules). Notably missing is the
auto-generated parser.rs and the Python script to generate it. We will
be able to generate this file automatically at build time (unlike
Facebook, which is constrained by not using Cargo or something).

The added files are not part of the hg-core project yet. Things will be
incorporated in future commits.

I haven't extensively audited the added code for functional correctness
and compatibility. But I did skim it and it seems to be a highly compatible
config parsing implementation. The most suspect code I found was around
config file path handling. There are references to "tupperware," which
appears to be a Facebook-specific thing. We will want to clean this up
at some point...

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

indygreg created this revision.Dec 7 2019, 3:17 PM
quark added a subscriber: quark.Dec 7 2019, 6:06 PM
quark added inline comments.
rust/hg-core/src/configparser/config.rs
72

You might want to revert D13875655 for the directory include feature, which has some test changes.

rust/hg-core/src/configparser/generate_parser.py
103–107

You might want to follow this and remove the generated code.

rust/hg-core/src/configparser/hg.rs
141–144

You might want to remove these lines.

262–263

You might want to respect $PAGER. We ignored it to reduce support burden for mis-configuration.

Thank you for the feedback, @quark! You enlightened me to a few issues I missed during my very quick perusal.

I agree that doing away with the auto-generated parser.rs feels like a better solution. I may revise this series yet again...

indygreg edited the summary of this revision. (Show Details)Dec 7 2019, 10:03 PM
indygreg updated this revision to Diff 18545.
Alphare added a subscriber: Alphare.Dec 9 2019, 6:38 AM
Alphare added inline comments.
rust/hg-core/src/configparser/c_api.rs
2

Do we need bindings to C ? I don't see what the use-case is at this stage of the Rust development.

rust/hg-core/src/configparser/hg.rs
227

This function looks very Facebook specific, I don't think we want to include it at all.

262–263

+1

414

Our current strategy is to assume config files to be in local encoding, not UTF-8. This makes sense from Facebook's perspective, but now as an upstream solution (see previous work on HgPath).

596

Is this hack still needed as of 1.34.2?

rust/hg-core/src/configparser/spec.pest
64

pest is really cool.

Alphare added inline comments.Dec 9 2019, 8:02 AM
rust/hg-core/src/configparser/hg.rs
227

My bad, it looks like you took care of it in a future patch.

durin42 added inline comments.Dec 11 2019, 12:44 PM
rust/hg-core/src/configparser/c_api.rs
2

+1, I'm not sure what the use case for this would be in core.

pulkit added a subscriber: pulkit.Jan 13 2020, 11:37 AM

The C bindings need to be dropped in this patch. Queued the previous patches, many thanks for importing things!

@Alphare What's your current opinion on this diff, can you mark it accepted or request change appropriatly ?

baymax requested changes to this revision.Jul 15 2020, 12:20 PM

There seems to have been no activities on this Diff for the past 3 Months.

By policy, we are automatically moving it out of the need-review state.

Please, move it back to need-review without hesitation if this diff should still be discussed.

:baymax:need-review-idle:

This revision now requires changes to proceed.Jul 15 2020, 12:20 PM
rust/hg-core/src/configparser/lib.rs