( )⚙ D11942 rhg: Accept different "invalid ignore pattern" error message formatting

This is an archive of the discontinued Mercurial Phabricator instance.

rhg: Accept different "invalid ignore pattern" error message formatting
ClosedPublic

Authored by SimonSapin on Dec 17 2021, 11:57 AM.

Details

Summary

At the moment rhg compiles all patterns into a single big regular expression,
so it’s not practical to find out which file the invalid bit of syntax
came from.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

SimonSapin created this revision.Dec 17 2021, 11:57 AM
Alphare accepted this revision.Dec 20 2021, 4:43 AM
Alphare added a subscriber: Alphare.

This might become a nuisance with a really big regex as it will print it in its entirety... but I'm not sure I have a good solution that isn't over-engineered right now.

This revision is now accepted and ready to land.Dec 20 2021, 4:43 AM

Ideally we’d have a way to parse and validate separate regexps from individual patterns (reporting errors with only the relevant line), then combine them (like in https://twitter.com/thingskatedid/status/1472360823058157569 and the preceding thread). If it’s cheap to combine already-fully-compiled DFAs, maybe the regex crate could have an API that takes multiple Regex values? In the meantime if we accept some duplicated setup-time work we could validate each pattern with Regex::new, report errors individually, throw away successful results and then at the end build the mega-regex from concatenated strings like now.

The second option was my idea, I don't know how much churn that would imply, but I feel like it would make the debugging experience much better.

baymax updated this revision to Diff 31551.Dec 20 2021, 7:25 AM

✅ refresh by Heptapod after a successful CI run (🐙 💚)