rhg: centralize index header parsing
Centralize index header parsing, parse the generaldelta flag,
and leave breadcrumbs to relate the code to python.
Differential Revision: https://phab.mercurial-scm.org/D11881
rhg: demonstrate that rhg breaks on non-generaldelta revlogs
Differential Revision: https://phab.mercurial-scm.org/D11880
tests: add a short `sleep` in test-status.t
With dirstate-v2 and rhg both enabled, this test would sometimes fail for me
with:
```
--- tests/test-status.t
+++ tests/test-status.t#dirstate-v2.err
@@ -943,7 +943,7 @@
$ rm subdir/unknown
$ hg status
$ hg debugdirstate --all --no-dates | grep '^ '
- 0 -1 set subdir
+ 0 -1 unset subdir
```
Meaning that `status` did not write a directory mtime in the dirstate
as expected. This can happen if the observed mtime of the directory is
the same as "current time" at the start of `status`. This current time
is obtained by creating a temporary file and checking its mtime.
Even with ext4 on my system being able to store nanosecond precision,
identical mtime for successive but separate operations is still possible
becuse the kernel may cache the current time:
https://stackoverflow.com/a/
14393315/1162888
0.1 second should be enough for this cache to be updated, without
significantly slowing down the test.
Differential Revision: https://phab.mercurial-scm.org/D11900
rhg: Add support for `rhg status --copies`
Copy sources are collected during `status()` rather than after the fact like
in Python, because `status()` takes a `&mut` exclusive reference to the dirstate map
(in order to potentially mutate it for directory mtimes) and returns `Cow<'_, HgPath>`
that borrow the dirstate map.
Even though with `Cow` only some shared borrows remain, the still extend the same
lifetime of the initial `&mut` so the dirstate map cannot be borrowed again
to access copy sources after the fact:
https://doc.rust-lang.org/nomicon/lifetime-mismatch.html#limits-of-lifetimes
Additionally, collecting copy sources during the dirstate tree traversal that
`status()` already does avoids the cost of another traversal or other lookups
(though I haven’t benchmarked that cost).
Differential Revision: https://phab.mercurial-scm.org/D11899