Issue 2594 darcs show index breaks test for issue2208

Title darcs show index breaks test for issue2208
Priority Status resolved
Milestone Resolved in 2.14.2
Superseder Nosy List bf
Assigned To

Created on 2018-07-01.15:04:20 by bf, last changed 2018-08-26.13:28:24 by bf.

msg20179 (view) Author: bf Date: 2018-07-01.15:04:19
In the test for issue2208, inserting 'darcs show index' between the
first record and the change to the file leads to a crash of darcs replace:

| darcs replace bar foo testing | not grep Skipping
| + darcs replace bar foo testing
| + not grep Skipping
| + grep Skipping
| darcs: There was an attempt to write an invalid pending! user error
(replace patch to ./testing couldn't apply.)
| If possible, please send the contents of _darcs/patches/pending_buggy
| along with a bug report.
| CallStack (from HasCallStack):
|   error, called at src/Darcs/Util/Printer.hs:145:14 in

The crash happens in addToPending, where we call readPendingAndWorking
and get a wrong result for the difference between pending and working.
This isn't too astonishing since we pass it a hard-coded UseIndex
instead of the value that reflects the command option (--ignore-times).
Indeed, the problem goes away if we pass IgnoreIndex; or if we pass the
command option to addToPending (since the test suite sets --ignore-times
as default for all commands).

However, I think there is still something not quite right here. How can
the execution of 'darcs show index' lead to 'darcs replace' seeing a
different working tree?? Apparently, 'darcs show index' actually
modifies the index. I have tried to find out how this is possible but I
have a hard time to reason about the index with its strange API. For
instance it looks as if one has to call updateIndex to even get a useful
result (i.e. a tree) from the index. WTF?

Also, in order for the crash to happen, doReplace must have successfully
applied the replace patch to the working tree, otherwise the replace
command would have complained, suggesting you use --force. This means
that the call to readUnrecorded in the replace command returned the
correct working tree, even though readUnrecorded unconditionally uses
the index, too!

This is all pretty mysterious to me.
msg20268 (view) Author: bf Date: 2018-08-26.13:28:04
It looks as if the refactorings and fixes for pending had the side
effect of solving this issue, too. I cannot reproduce the crash anymore
with the head of screened.
Date User Action Args
2018-07-01 15:04:20bfcreate
2018-08-26 13:28:05bfsetstatus: unknown -> resolved
messages: + msg20268
2018-08-26 13:28:24bfsetresolvedin: 2.14.2