darcs

Issue 2066 darcs record fails when deleted file and added file are specified on the command line

Title darcs record fails when deleted file and added file are specified on the command line
Priority bug Status resolved
Milestone 2.8.0 Resolved in 2.8.0
Superseder Nosy List bsrkaditya, david
Assigned To bsrkaditya
Topics Regression

Created on 2011-04-18.19:15:50 by david, last changed 2011-12-28.22:43:09 by noreply.

Files
File name Uploaded Type Edit Remove
added-regression-test-for-issue2066.dpatch bsrkaditya, 2011-09-25.13:18:42 application/octet-stream
bug.sh bsrkaditya, 2011-09-05.16:07:08 application/x-sh
dry_run.sh bsrkaditya, 2011-09-05.16:07:08 application/x-sh
moved failing issue2066 to issue2066.dpatch bsrkaditya, 2011-09-26.07:41:08 application/octet-stream
unnamed bsrkaditya, 2011-09-05.16:07:08 text/html
Messages
msg13938 (view) Author: david Date: 2011-04-18.19:15:48
darcs init
echo a > a
darcs add a
darcs record --all -m "a"
rm -f a
echo b > b
darcs add b
darcs record a b

I get this warning:
WARNING: File 'a' does not exist!

And then it only prompts for the "b" patches.

Also, from then on I can just do "darcs record a" and I get this error:
File 'a' does not exist!
Recording changes in "a":


darcs failed:  None of the files you specified exist!

But if I do the "darcs record a" *before* I try "darcs record a b" then
everything works as expected (it shows the patches for removing a). It's
like there's some state in the repo that causes the error to continue
("darcs revert" clears the condition).

$ darcs --version
2.5.2 (release)

I'm running Mac OS X 10.6.7

I also test darcs "2.5 (release)" which has the bug and a linux "2.4.4
(release)" which does not have the bug.
msg13939 (view) Author: kowey Date: 2011-04-18.20:20:25
Hi David!  Nice find and test case.  Would you mind submitting it to us 
as a patch?  http://wiki.darcs.net/Development/RegressionTests

(Don't worry if you really don't have time for this; I just like to 
increase participation as much as I can)

I could have sworn I'd seen something like this and I think you've 
finally nailed it down.  I was complaining about issue2006.  Now I 
wonder if they are the same thing.
msg14713 (view) Author: bsrkaditya Date: 2011-09-05.16:07:08
On Tue, Apr 19, 2011 at 12:45 AM, David <bugs@darcs.net> wrote:

>
> New submission from David <david+darcs@porkrind.org>:
>
> darcs init
> echo a > a
> darcs add a
> darcs record --all -m "a"
> rm -f a
> echo b > b
> darcs add b
> darcs record a b
>
> I get this warning:
> WARNING: File 'a' does not exist!
>
> And then it only prompts for the "b" patches.
>
> Also, from then on I can just do "darcs record a" and I get this error:
> File 'a' does not exist!
> Recording changes in "a":
>
>
> darcs failed:  None of the files you specified exist!
>
>
I have tried to pinpoint where the error creeps up. It seems to happen at
"darcs add b". darcs show files give both a, b before "add b", but gives
only
b after it. The same issue does not happen if I try "darcs add --dry-run b"


> But if I do the "darcs record a" *before* I try "darcs record a b" then
> everything works as expected (it shows the patches for removing a). It's
> like there's some state in the repo that causes the error to continue
> ("darcs revert" clears the condition).
>
>
It seems that "darcs record a" should be tried before "darcs add b". I
tested to see if it works after that, and it does not.


> $ darcs --version
> 2.5.2 (release)
>
> I'm running Mac OS X 10.6.7
>
> I also test darcs "2.5 (release)" which has the bug and a linux "2.4.4
> (release)" which does not have the bug.
>
> ----------
> messages: 13938
> nosy: david
> priority: bug
> status: unknown
> title: darcs record fails when deleted file and added file are specified on
> the command line
>
> __________________________________
> Darcs bug tracker <bugs@darcs.net>
> <http://bugs.darcs.net/issue2066>
> __________________________________
> _______________________________________________
> darcs-devel mailing list
> darcs-devel@darcs.net
> http://lists.osuosl.org/mailman/listinfo/darcs-devel
>


I suspect that the error is in addToPending of "src/Darcs/Repository.hs".
This is the only
function that "darcs add" calls but "darcs add --dry-run" does not.


-- 
BSRK Aditya
Attachments
msg14725 (view) Author: bsrkaditya Date: 2011-09-07.17:18:25
It looks like addToPending (src/Darcs/Repository.hs), calls 
invalidateIndex (src/Darcs/Repository/State.hs). I am writing down
what the comment for invalidateIndex says:

-- | Mark the existing index as invalid. This has to be called whenever 
the
-- listing of pristine changes and will cause darcs to update the index 
next
-- time it tries to read it. (NB. This is about files added and removed 
from
-- pristine: changes to file content in either pristine or working are 
handled
-- transparently by the index reading code.)

So it seems that the problem comes at rebuilding the index.
msg14732 (view) Author: bsrkaditya Date: 2011-09-20.14:32:41
I think I have nailed down why this bug happens. At "darcs add b", 
invalidateIndex is called. When readIndex is called again, It rebuilds 
the index. In the process, it calls readRecordedAndPending, which in 
turn calls readPending. readPending calls applyToTree, with arguments 
pending(a patch), pristine(a tree). In our case, pending had file "a" 
removed, and thus it will also be removed from the rebuilded index!

invalidateIndex, readIndex, readRecordedAndPending, readPending all are 
in Darcs.Repository.State

applyToTree is in Darcs.Patch.Apply
msg14733 (view) Author: bsrkaditya Date: 2011-09-25.12:37:11
As of now, the tests seem to succeed on the screened build.
There is an irc discussion about this: 
http://irclog.perlgeek.de/darcs/2011-09-25#i_4476687.
msg14734 (view) Author: bsrkaditya Date: 2011-09-25.13:18:42
I am submitting the test as a patch.
Attachments
msg14735 (view) Author: david Date: 2011-09-25.21:12:58
I was looking over your test patch and I understand how it could fail
(the test doesn't check for anything and darcs record doesn't return an
error in this case, it just doesn't record the removed file). Am I
missing something?

Also, when I submitted the bug originally I had written a failing test
which I think is correct and which was accepted into the tests dir:
   tests/failing-issue2066_add_and_remove.sh

-David
msg14736 (view) Author: bsrkaditya Date: 2011-09-26.07:41:08
The tests you have written passes now.
Attachments
msg14771 (view) Author: markstos Date: 2011-10-13.13:19:51
The last comment was "The tests you have written passes now."

Unless I'm missing something, that means the bug has been fixed. Please 
re-open if I'm wrong and further action is needed.
msg14884 (view) Author: ganesh Date: 2011-12-28.22:39:44
I think this may have been a victim of our general disorganisation for the 
last few months: patch611 has been around as a fix for a while which 
explains why it's fixed in screened.
msg14886 (view) Author: noreply Date: 2011-12-28.22:43:08
The following patch sent by andreas.brandt.de@googlemail.com updated issue issue2066 with
status=resolved;resolvedin=2.8.0 HEAD

* resolve issue2066: file does not exist when recording deleted file 
Ignore-this: d225dda60711f060ce9f41fbb716eca9
History
Date User Action Args
2011-04-18 19:15:50davidcreate
2011-04-18 20:20:29koweysetstatus: unknown -> needs-reproduction
topic: + Regression
messages: + msg13939
milestone: 2.8.0
2011-09-05 08:46:50bsrkadityasetassignedto: bsrkaditya
nosy: + bsrkaditya
2011-09-05 16:07:10bsrkadityasetfiles: + unnamed, bug.sh, dry_run.sh
messages: + msg14713
2011-09-07 17:18:26bsrkadityasetmessages: + msg14725
2011-09-20 14:32:42bsrkadityasetmessages: + msg14732
2011-09-25 12:37:14bsrkadityasetmessages: + msg14733
2011-09-25 13:18:43bsrkadityasetfiles: + added-regression-test-for-issue2066.dpatch
messages: + msg14734
2011-09-25 21:12:59davidsetmessages: + msg14735
2011-09-26 07:41:09bsrkadityasetfiles: + moved failing issue2066 to issue2066.dpatch
messages: + msg14736
2011-10-13 13:19:52markstossetstatus: needs-reproduction -> resolved
messages: + msg14771
2011-10-27 21:31:25markstossetresolvedin: 2.8.0
2011-12-27 21:54:40ganeshlinkpatch611 issues
2011-12-28 22:39:45ganeshsetstatus: resolved -> unknown
messages: + msg14884
2011-12-28 22:43:09noreplysetstatus: unknown -> resolved
messages: + msg14886