( )βš™ D10200 rhg: Make `files` work on repo-relative paths when possible

This is an archive of the discontinued Mercurial Phabricator instance.

rhg: Make `files` work on repo-relative paths when possible
ClosedPublic

Authored by SimonSapin on Mar 13 2021, 3:54 AM.

Details

Summary

When the current directory is outside of the repository we need to turn
everything into absolute filesystem paths in order to compute correct
relative paths.

This was previously done unconditionally, but is not necessary when
the current directory is inside the repository.

With this change rhg files > /dev/null at the root of a mozilla-central
snapshot goes from ~150 ms to ~70 ms. My repository is located at a
somewhat long path though (93 bytes). The effect may not be as pronounced
at a shorter path.

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.Mar 13 2021, 3:54 AM
Alphare added inline comments.
rust/rhg/src/commands/files.rs
73

Looks to me that the if/else logic could be smaller, and the actual loop written only once after.

pulkit added a subscriber: pulkit.Apr 1 2021, 4:51 AM

Hm, what's the status of this?

Alphare accepted this revision.Apr 1 2021, 8:54 AM
Alphare added inline comments.
rust/rhg/src/commands/files.rs
73

Thinking about it some more, this looks fine as it is.

pulkit accepted this revision.Apr 11 2021, 5:24 PM
This revision is now accepted and ready to land.Apr 11 2021, 5:24 PM

This needs to be rebased.

baymax updated this revision to Diff 26814.Apr 12 2021, 7:46 AM

βœ… refresh by Heptapod after a successful CI run (πŸ™ πŸ’š)

pulkit accepted this revision.Apr 13 2021, 4:54 AM