This is an archive of the discontinued Mercurial Phabricator instance.

rhg: Add Repo::write_dirstate
ClosedPublic

Authored by SimonSapin on Dec 2 2021, 11:48 AM.

Details

Summary

This method is not used yet. It saves to disk any mutation that was done to
the Repo’s dirstate through Repo::dirstate_map_mut. It takes care of
dirstate-v1 v.s. dirstate-v2, dockets, data files, appending when possible,
etc.

Diff Detail

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

Event Timeline

SimonSapin created this revision.Dec 2 2021, 11:48 AM
Alphare requested changes to this revision.Dec 3 2021, 8:18 AM
Alphare added a subscriber: Alphare.
Alphare added inline comments.
rust/hg-core/src/repo.rs
423

+1 for a WritableRepo that requires the lock in a future patch

445

This should support HGTEST_UUIDFILE (see mercurial/revlogutils/docket.py) otherwise some tests will end up failing. Possibly this chould just be a TODO, but I'd rather at least detect the env variable and print a warning to stderr that its support isn't implemented, so that it's more obvious down the line.

rust/hg-core/src/revlog/node.rs
178

Cool method

This revision now requires changes to proceed.Dec 3 2021, 8:18 AM
SimonSapin updated this revision to Diff 31320.Dec 6 2021, 5:03 AM
SimonSapin added inline comments.Dec 7 2021, 4:06 AM
rust/hg-core/src/repo.rs
445

https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/271544 shows that no test fail because of this.

As far as I understand, this point of HGTEST_UUIDFILE is to have deterministic data filenames for nodemap dockets so it’s less annoying to add glob patterns everywhere in expected test ouptput what it includes these names. But this new Rust code is only used to generate dirstate data filenames which are not printed in tests.

To port the current exact behavior of docket.py we’d need to have the same PRNG algorithm as Python’s random.Random(). Instead we could probably change docket.py to use a known, fixed PRNG algorithm.

I’ll probably stick with the warning for now. By stderr do you mean literally using std::eprintln!, or should we start passing around a &Ui value everywhere?

SimonSapin updated this revision to Diff 31343.Dec 7 2021, 7:52 AM
SimonSapin added inline comments.Dec 7 2021, 7:52 AM
rust/hg-core/src/repo.rs
445

I'd rather at least detect the env variable and print a warning

The env variable is always set by run-tests.py, so a warning would affect the output of every single test where hg status writes dirstate updates. So if a warning exists the only practical thing for tests would be to silence it, but that’s the only place where it would happen.

I’ll add a TODO comment and no warning.

Alphare accepted this revision.Dec 7 2021, 9:55 AM
This revision is now accepted and ready to land.Dec 7 2021, 9:55 AM
This revision was automatically updated to reflect the committed changes.