Patch 2264 improvements to check/repair

Title improvements to check/repair
Superseder Nosy List bfrk
Related Issues
Status accepted Assigned To

Created on 2022-06-27.08:40:15 by bfrk, last changed 2023-06-27.20:43:16 by bfrk.

File name Status Uploaded Type Edit Remove
bugfix-for-darcs-repair.dpatch bfrk, 2022-11-19.16:48:43 application/x-darcs-patch
cleanup-code-layout-in-darcs_patch_repair.dpatch bfrk, 2022-06-27.08:40:10 application/x-darcs-patch
patch-preview.txt bfrk, 2022-06-27.08:40:09 text/x-darcs-patch
patch-preview.txt bfrk, 2022-11-19.16:48:43 text/x-darcs-patch
See mailing list archives for discussion on individual patches.
msg23039 (view) Author: bfrk Date: 2022-06-27.08:40:10
Some of these patches change behavior, but in a way that is only (I think)

The behavior wrt broken pending is now, I think, more logical and safer. It
keeps as much of pending as is allowed, whereas previously we simply threw
it all away. (This is no longer quite as relevant these days since most of
the bugs that allowed pending to become corrupt have been fixed.)

I realized that darcs repair destroys the inventory structure when I ran it
on the darcs repo itself in order to get rid of patches with broken move
prims: some operations became noticeably slower afterwards. I regard this as
an important bug fix because other projects with a long history may also
contain such broken move prims, and darcs now fails if it encounters them
and suggests 'darcs repair'.

7 patches for repository http://darcs.net/screened:

patch dd953a67e75b4c9cd0474a726459636ccda0c416
Author: Ben Franksen <ben.franksen@online.de>
Date:   Fri Sep 24 09:39:34 CEST 2021
  * cleanup code layout in Darcs.Patch.Repair

patch d8927243c010e96aaa0a9d526a9969c68a6ca27d
Author: Ben Franksen <ben.franksen@online.de>
Date:   Fri Sep 24 09:54:01 CEST 2021
  * check/repair: also handle broken pending patch

  This required a redesign of the interface between D.R.Repair and
  D.UI.Commands.Repair i.e. the data type RepositoryConsistency. Indeed, all
  three types of problems we detect (broken patches, broken pristine, broken
  pending) can occur independently of each other, so a record type seems more

  With the ability to properly fix the pending patch we no longer have to use
  the crude method of "fixing" a broken pending (by removing it) during
  command execution. Instead, commands that try to read a broken pending now
  fail with a hint to the user to run `darcs repair`.

patch 5aeaaeb4c029bd9185af16e722fb1d95dcba165b
Author: Ben Franksen <ben.franksen@online.de>
Date:   Fri Sep 24 10:40:55 CEST 2021
  * fix wrong use of unlines in instance Repair (FL p)

  This avoids extraneous empty lines in the check/repair output.

patch 631e79f5e5eefffaca524fe34ef8ec8fc931d6d3
Author: Ben Franksen <ben.franksen@online.de>
Date:   Fri Sep 24 10:08:15 CEST 2021
  * clarify internal structure of replayRepository', inline checkUniqueness

patch 58b88055cc6d81608f2ce9f682c286e75c983ddc
Author: Ben Franksen <ben.franksen@online.de>
Date:   Tue Oct  5 12:21:02 CEST 2021
  * return the pristine differences from replayRepository', too

  This means we can eliminate the extra procedure brokenPristine from the
  command implementation. This removes the catchall when we read pristine
  inside replayRepository', which is a semantic change, but I haven't observed
  any problems so far, and we have a test that checks we can remove pristine
  files that still works.

patch 016761914d06d342a38db4d2588a35dc1ad1ee37
Author: Ben Franksen <ben.franksen@online.de>
Date:   Sun Jul 18 16:14:59 CEST 2021
  * Darcs.Patch.PatchInfoAnd: cleanup imports

patch 026c01ec6881bc9421be294371b0e02c5fe5cb39
Author: Ben Franksen <ben.franksen@online.de>
Date:   Sat Jun 18 23:36:03 CEST 2022
  * darcs repair: preserve inventory structure

  Previously we stored the repaired PatchSet as a single large inventory. This
  would completely destroy the breaking up of a repository into inventories.
  We now repair each Tagged section separately and rebuild it afterwards. The
  WPatchInfo and its supporting functions from PatchInfoAnd are no longer used
  and therefore deleted.
msg23044 (view) Author: bfrk Date: 2022-11-19.16:48:43
Follow-up bugfix patch.

1 patch for repository http://darcs.net/screened:

patch c1abf7c843b10bfd0d6c010a2f9937134a8c8090
Author: Ben Franksen <ben.franksen@online.de>
Date:   Sat Nov 19 17:30:33 CET 2022
  * bugfix for darcs repair

  This fixes a bug introduced in

  patch 026c01ec6881bc9421be294371b0e02c5fe5cb39
  Author: Ben Franksen <ben.franksen@online.de>
  Date:   Sat Jun 18 23:36:03 CEST 2022
    * darcs repair: preserve inventory structure

  The problem was that darcs repair effectively failed to do any repairs.
  While the patch in question was repaired, and also the inventory directly
  referencing that patch, we failed to propagate the changed inventory hash to
  later inventories. The simple solution is to always throw away inventory
  hashes when doing repair.
msg23416 (view) Author: ganesh Date: 2023-06-24.23:18:57
>   * cleanup code layout in Darcs.Patch.Repair

msg23424 (view) Author: ganesh Date: 2023-06-25.18:57:15
>   * check/repair: also handle broken pending patch

Nice improvement, thanks!

I was wondering if an alternative representation of
`RepositoryConsistency` as a list of things that were broken would
be slightly easier to work with. The main benefit would be that
the pattern
`isJust fixedPatches || isJust fixedPristine || isJust fixedPending`
could be turned into
`null fixes` and there'd be less risk of failing to update it for
future changes. (Though that could also be accomplished with a utility
function near the datatype definition.)

I also wonder if a future refactoring could bring fixing the index
into the same logic.
msg23425 (view) Author: ganesh Date: 2023-06-25.19:12:35
>   * fix wrong use of unlines in instance Repair (FL p)
>   * clarify internal structure of replayRepository', inline 
>  * return the pristine differences from replayRepository', too
>  * Darcs.Patch.PatchInfoAnd: cleanup imports

msg23426 (view) Author: ganesh Date: 2023-06-25.19:46:49
>  * darcs repair: preserve inventory structure
>  * bugfix for darcs repair

These look fine. I wouldn't have caught the bug. Is it worth a test?
msg23449 (view) Author: bfrk Date: 2023-06-27.20:43:16
Your ideas for refactoring RepositoryConsistency are appreciated 
(though I am not sure it's as easy as you make it sound, given that 
its quite different things that can be broken here). Same with 
checking the index. It might be worth a ticket so I don't forget 
next time I hack on repair.

Regarding a test to check that repair actually repairs things: that 
would be nice indeed. However, the hashed repository format makes 
constructing broken patches quite difficult, at least in a way that 
doesn't make darcs fail up-front when it tries to read the files. 
You basically have to do the hashing manually, recursively up to the 
top-level hashed_inventory. So, unfortunately, this would be yet 
another ticket rather than something I can quickly add as a follow-
Date User Action Args
2022-06-27 08:40:15bfrkcreate
2022-06-27 08:43:45bfrksetstatus: needs-screening -> needs-review
2022-11-19 16:48:43bfrksetfiles: + patch-preview.txt, bugfix-for-darcs-repair.dpatch
messages: + msg23044
2023-06-24 23:18:57ganeshsetstatus: needs-review -> review-in-progress
messages: + msg23416
2023-06-25 18:57:16ganeshsetmessages: + msg23424
2023-06-25 19:12:36ganeshsetmessages: + msg23425
2023-06-25 19:46:49ganeshsetstatus: review-in-progress -> accepted-pending-tests
messages: + msg23426
2023-06-25 22:39:23ganeshsetstatus: accepted-pending-tests -> accepted
2023-06-27 20:43:16bfrksetmessages: + msg23449