Removing negative prims
Ben Franksen <[email protected]> Tue, 29 Sep 2020 21:02:34 +0200
| Newsgroups | gmane.comp.version-control.darcs.devel,gmane.comp.version-control.darcs.user |
|---|---|
| Message-ID | <[email protected]> |
Hi All prompted by the Diskussion with James Cook on @darcs-users I noted that all Contexted patches in Darcs are positive throughout i.e. including the context. This led me to investigate whether we could eliminate inversion for named prim patches in a way similar to what we did for Named patches at the repo level, thereby turning what previously was (merely) an invariant into something that is baked into the type. So I have made an experimental change that removes the ability to invert PrimPatchIds, and consequently removes class SignedId and the Invert instance for PrimWithName. For RepoPatchV3 this means we must store the patches that a Conflictor reverts in the backward direction and invert them only after stripping the names (i.e. in the implementation of 'effect'). This change requires a new class CleanUnmerge that does the opposite of CleanMerge. It also requires new functions in the Contexted API. I can compile and successfully run all tests (though the tests for named prims of course have to be stripped down because we no longer have inversion for them). The question is: is this something worthwhile? It does simplify the invariants: we no longer have to test that Contexted patches and Conflictors are positive, because negative named prims no longer exist. It does not simplify the code in any significant way, but it arguably clarifies some details in the RepoPatchV3 implementation; for instance it now becomes obvious at which points we add prims to a context and where we remove them. I don't expect, nor have I seen, any noticeable impact on performance. It would change the on-disk representation of darcs-3 patches. In fact, this makes RepoPatchV3 a bit more like RepoPatchV2 which also stores the effect of a Conflictor in non-inverted form. I can send a patch to make this a bit more concrete if there is interest. Cheers Ben