This is an archive of the discontinued Mercurial Phabricator instance.

rust-nodemap: mutable NodeTree data structure

Authored by gracinet on Jan 6 2020, 2:25 PM.



Thanks to the previously indexing abstraction,
the only difference in the lookup algorithm is that we
don't need the special case for an empty NodeTree any more.

We've considered making the mutable root an Option<Block>,
but that leads to unpleasant checks and unwrap() unless we
abstract it as typestate patterns (NodeTree<Immutable> and
NodeTree<Mutated>) which seem exaggerated in that

The initial copy of the root block is a very minor
performance penalty, given that it typically occurs just once
per transaction.

Diff Detail

rHG Mercurial
No Linters Available
No Unit Test Coverage

Event Timeline

gracinet created this revision.Jan 6 2020, 2:25 PM
gracinet updated this revision to Diff 19136.Jan 10 2020, 10:03 AM
gracinet updated this revision to Diff 19326.Jan 15 2020, 6:47 PM
kevincox accepted this revision.Jan 16 2020, 5:15 AM
kevincox added inline comments.

This strikes me as a weird name. The fact that it is an adjective rather than a noun is a hint. Can you rename to answer "Growable what?"


I would use for consistency unless you really want to avoid printing the struct name.

gracinet updated this revision to Diff 19633.Jan 27 2020, 10:49 AM
gracinet added inline comments.Jan 27 2020, 10:54 AM

In a previous version, I was calling it mutable (also an adjective, btw), but that became just wrong with the introduction of the separate root block. I don't have many ideas:

  • added_inner_blocks ? actually, these are added on top of the readonly part and often mask some of the readonly blocks
  • added_non_root_blocks ? Eww
  • mutable_inner_blocks ?

I'm no native speaker, but the adjective thing doesn't deter me, I would expect it to be rather clear that it refers to blocks, given the type.
Open to suggestions, leaving as is for the time being


sadly, Formatter.debug_struct doesn't tale ?Sized arguments (at least in our target 1.34 version):

   --> hg-core/src/revlog/
298 |             .field("readonly", readonly)
    |                                ^^^^^^^^ doesn't have a size known at compile-time
    = help: the trait `std::marker::Sized` is not implemented for `[revlog::nodemap::Block]`

Kept it as it was for the time being, just dropped the unneeded anonymous lifetime

Omitting the struct name was indeed on purpose, to make it more manageable in test data. That was useful in early versions. I would have been willing to drop it for the final form. Anyone using this for real data wouldn't care about just a few bytes at the beginning.

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