Goal
Last time I started changing how chunk IDs are represented. Today I'll finish that work.
Plan
- Change all code to use new
Idand drop the oldId.
Notes
Reviewing what I did last time, I see I have no doc test that serves as an example for the new
IdandIdFactory. That's easy to rectify.Next, the goal is to use the new stuff instead of the old stuff. Generating the old
Idwas infallible. The first step towards the goal is to make any place where anIdis created handle failures.Hmm, I have
Metadata::lossy_id, which is bogus, and always has been. Instead of adding that I should have just fixed ID representation. At least I only use in the chunk inspection code, so it's mostly harmless. Same thing withMetadata::lossy_label. Replaced both suspect methods with corresponding serialization. That'll break the general case until I switch to the newIdtype.This tells me I should also revisit how the labels are serialized, later.
The places that may create an
Idwill need to have anIdFactory. I don't want to create a new factory every time. While I haven't implemented the "start with a small range, make larger if there's a collision" feature, that will need a single factory if it's ever implemented.In practice, this means I'll need to add a chunk metadata factory. Or else I need another way to keep track of the ID factory, but that seems like more work for the caller.
Picking apart all the repercussions from old mistakes is tedious, but it has to be one. I'm bummed that I didn't do this in a better way originally, since that's what I set out to do when I started this Obnam generation. Oh well.
While changing things to use new
Idstuff, ran into a problem: the oldIdcould be used as a type for command line arguments withclap, new one can't. That's awkward. Some day I want to learn how to implement custom parsers forclap, but not today. Today I'll just parse strings in every place that takes chunk IDs on the command line.Another problem: in tests I use hardcoded human-friendly chunk IDs. This now fails, because arbitrary strings aren't acceptable as IDs. The only reason I've been doing that is because it was easy. Rather than adding the arbitrary ID support to new chunk IDs, I'll drop use of that. Because of limitations in Subplot, it's awkward to test the random ID represents a chunk in the backup repository, but I'll make do with labels.
Hmm, no, that's not good enough. I need to reference, in some verification scenarios, the actual chunk ID. That means I need to look up chunk IDs by label and use the ID in a later step.
Added
--id-fileoption to any command that creates a chunk and its ID, and to any command where we need to use the ID.After much fiddling and mostle-mechanical changes to the acceptance test suite to pass again.
Summary
This was a lot of tedious, detailed work. I blame my younger self for causing it. I expect my future self to have more things to complain, the ingrate.
But it's big step forward, even if it's not actually really user-visible.
Comments?
If you have feedback on this, please use the following fediverse thread: https://toot.liw.fi/@liw/116391168664767172.
If you'd like to fund Obnam development, see my funding page.