Bug 170743 - [Sync Info] Ignoring .cvsignore leaves project dirty
Summary: [Sync Info] Ignoring .cvsignore leaves project dirty
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: CVS (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Krzysztof Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-01-17 05:03 EST by Ulrich Küster CLA
Modified: 2007-06-25 05:09 EDT (History)
0 users

See Also:
Michael.Valenta: review+


Attachments
Fix (1.33 KB, patch)
2007-05-11 08:56 EDT, Krzysztof Daniel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Küster CLA 2007-01-17 05:03:51 EST
Build ID: M20060921-0945

Steps To Reproduce:
1. Create a new file test.txt in a shared project
2. Add test.txt to .cvsignore (.cvsignore will be created)
3. Add .cvsignore to .cvsignore
.cvsignore now has content:

test.txt
.cvsignore

Although there are no changes to commit in the shared project, the project will be marked as dirty (>) in the Navigator view. For illustration please see http://hnsp.inf-bb.uni-jena.de/ukuester/EclipseCVSDecoratorBug.jpg

The folder Lebenslauf doesn't contain any changes, which I double checked by synchronizing it (see Synchronize view in the down left corner), yet it is marked as dirty after I did the steps listed above.

The same problem happened to me, when I globally ignored all files Thumbs.db. Folder containing such files where still marked dirty although they didn't contain any commitable changes.
Comment 1 Michael Valenta CLA 2007-01-19 12:11:31 EST
I was able to reproduce this but also noticed that, after a while, the problem fixed itself. This leads me to believe that the problem may be that the dirty state reset is not properly get sent to the parent of the resource that become ignored.
Comment 2 Krzysztof Daniel CLA 2007-04-24 10:44:00 EDT
Michael, could you give me any suggestions where to search for the bug cause?
Comment 3 Michael Valenta CLA 2007-04-24 11:01:43 EDT
This is actually a fairly complex area. I would suggest you put a breakpoint in EclipseSynchronizer.adjustDirtyStateRecursively and see what happens when you dirty a file. By stepping through the code, you should get an idea of what is going on. To summarize, when a file is changed, we set the dirty state to RECOMPUTE. Then, when the dirty state is requested, we either return the cached state or recalculate it if the state is RECOMPUTE.
Comment 4 Krzysztof Daniel CLA 2007-04-26 10:35:44 EDT
this method is not called when ignoring .cvsignore. I welcome any other hints.
Comment 5 Michael Valenta CLA 2007-04-26 11:06:09 EDT
Interesting. Perhaps that is the problem. Try EclipseSynchronizer#ignoreFilesChanged. This should trigger a recalculation of the dirty state of the parent folders but perhaps it is not.
Comment 6 Krzysztof Daniel CLA 2007-04-30 08:36:10 EDT
Michael,

ignoreFilesChanged is not called, neither.

Maybe you have any suspicions? 

What is the difference between regular file and .cvsignore?
Comment 7 Michael Valenta CLA 2007-04-30 11:00:35 EDT
OK. It looks like a call to EclipseSynchronizer#addIgnores doesn't result in a call to those methods (i.e. EclipseSynchronizer#addIgnores  is called indirectly from the IgnoreAction). I guess that explains what the problem is. The call is generating events in the decorator and subscriber but is not setting the dirty state of the parent folders to recompute.
Comment 8 Krzysztof Daniel CLA 2007-05-02 06:34:26 EDT
Micheal,

I have found the cause - look at the flow of ignoring resource:

1. Resource is ignored. (Added to .cvsignore).
2. Some events are propagated (we do not care).
3. POST_CHANGE resourceModified event is generated in separate thread (this one is resposible for adjusting dirty state).
4. The event is ignored, because .cvsignore is now ignored. No update of dirty state.

I do not see any solution for this except forcing full refresh of the three after .cvsignore modification.
Am I missing something?

Comment 9 Michael Valenta CLA 2007-05-02 10:26:55 EDT
In step 3, could you add an explicit check to see if it is the .cvsignore that has changed and, if so, still process it (i.e. never ignore a change to .cvsignore even if the file is ignored)?
Comment 10 Krzysztof Daniel CLA 2007-05-02 10:37:50 EDT
I have tried to do so, but then ignoring other files fails if .cvsignore is ignored.

I think this is because of assumption that modified file is always dirty. But I have not verified that.
Comment 11 Krzysztof Daniel CLA 2007-05-11 08:56:00 EDT
Created attachment 66843 [details]
Fix

The solution is cleaning the .cvsignore state and its path after change manually if it is ignored.
Comment 12 Michael Valenta CLA 2007-05-11 12:53:41 EDT
Patch reviewed and release to HEAD. I did make one modification. Instead of
marking the parent folders as clean to trigger the decorator refresh, I just
added the file to the list of modifiedResources. This triggers a redecoration
of the file and it's parent folders.