This is an archive of the discontinued Mercurial Phabricator instance.

rust-filepatterns: add support for `include` and `subinclude` patterns
ClosedPublic

Authored by Alphare on Jan 16 2020, 6:33 AM.

Details

Summary

This prepares a future patch for IncludeMatcher on the road to bare
hg status support.

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

Alphare created this revision.Jan 16 2020, 6:33 AM

Note to reviewers: this stack is part of the larger series of getting a full Rust dirstate.status which is most of the performance hit in bare hg status. More patches are coming, but I figured I would send the patches as I go to help with review timing.

kevincox requested changes to this revision.Jan 16 2020, 10:30 AM
kevincox added inline comments.
rust/hg-core/src/filepatterns.rs
455

I don't see anywhere where this returns None. Should this just be .map() or .flat_map()?

461

I would write this as Some(Ok(match syntax { .. })) as the last expression of this map. Then instead of res.extend() and res.push() you just return the vecs.

524

How about:

if !p.is_empty() {
  p.push(b'/');
}
Ok(p)
This revision now requires changes to proceed.Jan 16 2020, 10:30 AM
Alphare marked 2 inline comments as done.Jan 16 2020, 1:21 PM
Alphare added inline comments.
rust/hg-core/src/filepatterns.rs
461

The match arms would be incompatible. Or maybe I'm missing something.

kevincox added inline comments.Jan 16 2020, 2:40 PM
rust/hg-core/src/filepatterns.rs
461

You would have to make sure you return a Vec on both arms. You will probably want inner_pats.into_iter().collect() on one branch and vec![entry] on the other branch.

Alphare marked an inline comment as done.Jan 16 2020, 4:50 PM
Alphare retitled this revision from rust-filepatterns: add support for `ignore` and `subignore` patterns to rust-filepatterns: add support for `include` and `subinclude` patterns.
Alphare updated this revision to Diff 19385.
Alphare updated this revision to Diff 20039.Feb 10 2020, 10:46 AM
kevincox accepted this revision.Feb 10 2020, 1:14 PM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.