( )⚙ D11377 rhg: add support for calling `rhg cat` without a revision

This is an archive of the discontinued Mercurial Phabricator instance.

rhg: add support for calling `rhg cat` without a revision
ClosedPublic

Authored by Alphare on Sep 1 2021, 12:42 PM.

Details

Summary

Turns out the necessary pieces were there already.
Like the Python implementation, we default to the first parent of the dirstate.

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.Sep 1 2021, 12:42 PM

Note to reviewers: this needs the other patches in the stack to pass all tests, but in order to make the tests in the patches actually meaningful, this had to go first.

https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/243241 Successful CI run (since baymax does not need to refresh this stack)

SimonSapin added inline comments.
rust/rhg/src/commands/cat.rs
63

What should happen when p1 is null? (Such as in a new empty repository.) Is this case covered by tests?

63

Making a hex string just to parse it again feels a bit silly, but is likely required by the current signature of hg::operations::cat. That can be refactored later.

Alphare added inline comments.Sep 8 2021, 6:27 AM
rust/rhg/src/commands/cat.rs
63

What should happen when p1 is null? (Such as in a new empty repository.) Is this case covered by tests?

If p1 is nullrev, it's the same path as any other revision, but if the dirstate does not exist, then it's an abort in the same way as hg does it. Should I add a testcase in test-cat.t or somewhere similar?

SimonSapin accepted this revision.Sep 9 2021, 9:41 AM
SimonSapin added inline comments.
rust/rhg/src/commands/cat.rs
63

I guess I should have just tried it:

$ cd /tmp
$ hg init repo
$ cd repo
$ hg cat a
a: no such file in rev 000000000000

Indeed that look like the same code path. Still, yes adding that test sounds good.

This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.