We recently observed a situation where darcs (2.14.2 or 2.12.5) failed
with the log command and a file name:
> darcs-2.14.2 log README.rst
darcs: not enough bytes
CallStack (from HasCallStack):
error, called at libraries/binary/src/Data/Binary.hs:218:21 in
binary-0.8.3.0:Data.Binary
Searching for where the binary library is used in darcs leads one to the
patch index. In Darcs.Repository.PatchIndex we call
Data.Binary.decodeFile which throws an error when it cannot successfully
decode the file.
To verify this, I changed the code to call decodeFileOrFail and fail
with a more descriptive message. I made this change in the 2.14 branch
because in the development branch the format has been changed (due to
the FileName->AnchoredPath refactor), which means that the patch index
will be re-created from scratch whether it is corrupt or not.
Indeed, now I get
> darcs-2.14.3 log README.rst
darcs failed: Patch index is corrupt (file
.../_darcs/patch_index/touch_map at offset 272129): not enough bytes
It is unclear what exactly has caused the patch index to become corrupt.
This may be a bug in darcs or it may have been accidentally done by the
user.
In any case, the error message should be further extended to contain a
recommendation how the user can fix the problem. The most straight
forward solution is to remove the corrupt file and try again:
> darcs-2.14.3 log README.rst
darcs failed: Patch index is corrupt (file
.../_darcs/patch_index/touch_map at offset 272129): not enough bytes
Please remove the corrupt file and then try again.
Indeed, doing so fixed the patch index.
I will add this mitigation to the 2.14.3 release.
|