This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 153504 - Makefiles goes to svn in not up to date state
Summary: Makefiles goes to svn in not up to date state
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-20 06:26 UTC by obucinac
Modified: 2012-03-26 07:29 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
First SS (109.82 KB, image/png)
2008-11-26 00:17 UTC, obucinac
Details
Second SS (70.05 KB, text/plain)
2008-11-26 00:18 UTC, obucinac
Details
Second SS (70.05 KB, image/png)
2008-11-26 12:22 UTC, obucinac
Details
log (8.83 KB, text/plain)
2009-04-30 16:09 UTC, Alexander Simon
Details
thread dump (124.59 KB, text/plain)
2010-12-07 09:05 UTC, Alexander Simon
Details
call "Project Properties" window on the attached project and press OK ==> infinite loop (50.83 KB, application/x-gzip)
2010-12-07 09:29 UTC, soldatov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description obucinac 2008-11-20 06:26:05 UTC
I have a four compile configuration for a project. Adding and removing files is very common. Sometimes, makefiles do not
get up to date, and are commited to svn in that state. The result is that other party can not compile the code.
E.g. when I change project properties, the makefiles are recreated. Now, if I try to commit to svn, the svn will report
files as deleted, although the makefiles are recreated and they exist on a file system, and upono commit it will delete
them in a svn repository.
Comment 1 Thomas Preisler 2008-11-25 19:18:27 UTC
I can reproduce the situation the following way:

1) create any sample project
2) add new file
3) build the project
4) delete and remove the new file from the project using Delete from the files context menu

Now the project is marked 'dirty' but hasn't been saved yet. Common actions like building, running, and also closing the project will save the project but 
version control actions won't so I can see if you check in the project before running any other actions would commit inconsistent metadata files. Work-
around is to for instance build the project first.

Perhaps the project should be save every time a file has been added or deleted.
Comment 2 obucinac 2008-11-26 00:14:15 UTC
I will try to provide you a more detailed description of how to reproduce. For now, I am sending you only attachement
with a part of a screenshot. The makefiles are marked deleted after changing project properties, section Linker.
Comment 3 obucinac 2008-11-26 00:17:43 UTC
Created attachment 74151 [details]
First SS
Comment 4 obucinac 2008-11-26 00:18:49 UTC
Created attachment 74152 [details]
Second SS
Comment 5 obucinac 2008-11-26 00:20:57 UTC
As you may see on second screenshot, the project is saved.
Comment 6 Alexander Simon 2008-11-26 11:40:11 UTC
Sorry, you forget to set right mime type for second picture.
Comment 7 obucinac 2008-11-26 12:22:31 UTC
Created attachment 74179 [details]
Second SS
Comment 8 Thomas Preisler 2009-04-24 23:17:18 UTC
Fixed. Now making sure all sharable files are saved before sharebility query.
Comment 9 Quality Engineering 2009-04-25 18:55:38 UTC
Integrated into 'main-golden', will be available in build *200904251401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/924f7ce118c7
User: Thomas Preisler <thp@netbeans.org>
Log: #153504 Makefiles goes to svn in not up to date state
Comment 10 Alexander Simon 2009-04-30 16:00:20 UTC
It seems fix wrong because created second instance of make project that reads already loaded configuration xml.
See attachment. 
Steps:
Start IDE wit opened project.
See two instances of ConfigurationDescriptorProvider: @1ccaf14 and @c7352a
Invoke project context menu.
See exception about reading configuration xml
Comment 11 Alexander Simon 2009-04-30 16:09:19 UTC
Created attachment 81331 [details]
log
Comment 12 Alexander Simon 2009-04-30 16:18:04 UTC
revert modification:
http://hg.netbeans.org/cnd-main/rev/f5e758b1af20
Comment 13 Quality Engineering 2009-05-01 08:12:20 UTC
Integrated into 'main-golden', will be available in build *200905010201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/f5e758b1af20
User: Alexander Simon <alexvsimon@netbeans.org>
Log: revert modifications for IZ#153504:Makefiles goes to svn in not up to date state
Comment 14 Thomas Preisler 2010-04-17 01:05:33 UTC
Refined the code a bit: now won't check if project hasn't bee read. We don't need the information at that point so it is OK to skip it here. Will ask Alexander S. for review.
Comment 15 Quality Engineering 2010-04-18 04:19:33 UTC
Integrated into 'main-golden', will be available in build *201004180201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/96e7254e312d
User: Thomas Preisler <thp@netbeans.org>
Log: #153504 - Makefiles goes to svn in not up to date state
Comment 16 Alexander Simon 2010-04-27 12:47:02 UTC
Fix is OK.
Comment 17 Alexander Simon 2010-12-07 09:05:44 UTC
Created attachment 103657 [details]
thread dump
Comment 18 Alexander Simon 2010-12-07 09:08:15 UTC
Unfortunately fix does not work in case folder nbproject/private is empty.
See infinite loop in attached thread dump.
I will roll back changes.
Comment 19 soldatov 2010-12-07 09:29:37 UTC
Created attachment 103658 [details]
call "Project Properties" window on the attached project and press OK ==> infinite loop
Comment 20 Quality Engineering 2010-12-08 06:34:50 UTC
Integrated into 'main-golden', will be available in build *201012080001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/7a912ffc5827
User: Alexander Simon <alexvsimon@netbeans.org>
Log: roll back changes for Bug #153504 Makefiles goes to svn in not up to date state
Comment 21 Leonid Lenyashin 2010-12-22 11:22:04 UTC
Looks like Alexander is making most of the changes related to the issue. So it seems logical to have it assigned to him.
Comment 22 Alexander Simon 2011-02-18 15:15:59 UTC
Reassign to evaluation.
VCS is responsible for getting files up-to-date.
Comment 23 Ondrej Vrabec 2011-02-21 12:59:51 UTC
cnd team: i guess makefiles appear as removed/deleted because you generate them using either an external tool or delete and recreate them through java.io.File instead of using FileObjects. If you used FOs (or at least just overwrite the files instead of delete/create them), subversion would obtain proper FS events, react accordingly and the makefiles would appear correctly as modified.

*** This bug has been marked as a duplicate of bug 194998 ***
Comment 24 Alexander Simon 2011-02-22 08:29:34 UTC
(In reply to comment #23)
> cnd team: i guess makefiles appear as removed/deleted because you generate them
> using either an external tool or delete and recreate them through java.io.File
> instead of using FileObjects. If you used FOs (or at least just overwrite the
> files instead of delete/create them), subversion would obtain proper FS events,
> react accordingly and the makefiles would appear correctly as modified.
Problem is in saving files before VCS operations.
For example command "Mercurial->Status" saves all unsaved changes in opened editors.
CND projects have several files that must be saved (regenerated) before VCS operations.
So VCS should provide interface for saving changes.
Comment 25 Tomas Stupka 2011-02-22 13:17:13 UTC
Hi Simon, 

> Problem is in saving files before VCS operations.

1.) this issue is a bit confusing. The original report was made about files being deleted by a commit, but the last comment is about files not being saved. So for now we will interprete "getting files up-to-date" as "to save all unsaved files". To avoid further misunderstandings it would be great if you could, one more time, provide the steps necessary to reproduce and exactly point out what files aren't saved or are deleted or whatever else it is that's responsible for this issue.

> For example command "Mercurial->Status" saves all unsaved changes in opened editors.
> CND projects have several files that must be saved (regenerated) before VCS operations.

2.) note that all file relevant vcs actions invoke org.openide.LifecycleManager.getDefault().saveAll() before the actions actual logic is executed. This aplies also to  svn > commit, where LM.saveAll() is called before the commit dialog is opened. If there is something else you would like to do at that point, just let us know...

> So VCS should provide interface for saving changes.
3.) considering the already mentioned inherent confusion in this issue, we are not sure how we are supposed to understand this statement. Is it interface as in API, or is it interface as in UI, or is it something else you have in mind?
Comment 26 Vladimir Voskresensky 2011-02-22 13:45:10 UTC
(In reply to comment #25)
> 2.) note that all file relevant vcs actions invoke
> org.openide.LifecycleManager.getDefault().saveAll() before the actions actual
> logic is executed. This aplies also to  svn > commit, where LM.saveAll() is
> called before the commit dialog is opened. If there is something else you would
> like to do at that point, just let us know...
As I understood Alexander's explanation:
- some project metadata files are in not saved state => it's preferable to save them before status/commit operations

So, one of possible solutions could be:
together with LM.saveAll() vcs should call
ProjectManager.getDefault().saveAllProjects()
(if saveAllProjects forces projects to save it's metadata)
Comment 27 Tomas Stupka 2011-02-23 00:10:01 UTC
> As I understood Alexander's explanation:
> - some project metadata files are in not saved state => it's preferable to save
> them before status/commit operations
> So, one of possible solutions could be:
> together with LM.saveAll() vcs should call
> ProjectManager.getDefault().saveAllProjects()
could work and easy to do, but sounds like a workaround. LM.saveAll() doesn't seem to be meant to care about touched project metadata and PM.saveProject(Project) makes it clear that it wasn't meant to be used this way. So the question here is if this shouldn't be the responsibility/decision of whoever left the project files in a dirty state in the first place and if there is any reasonable justification to move this responsibility to some another module(s) (vcs, system exit maybe, ...) to cleanup at some, undefined, point later...
Comment 28 Alexander Simon 2011-02-23 09:59:13 UTC
(In reply to comment #27)
> So the question here is if this shouldn't be the responsibility/decision
> of whoever left the project files in a dirty state in the first place and if
> there is any reasonable justification to move this responsibility to some
> another module(s) (vcs, system exit maybe, ...) to cleanup at some, undefined,
> point later...
You are right it is C/C++ project responsibility to save dirty meta data.
But C/C++ has a specific:
- size of C/C++ meta data is much bugger then meta data of Java projects.
- C/C++ meta data cannot be saved in EDT without slowness (1Mb in 8 files is ordinary size of meta data). Saving is done under "wait dialog".
- C/C++ meta data is changed in much more places then Java meta data. For example: adding/removing files, changing current configuration/tool collection/development host, at run/debug, while debugging.
So it is unreal to save meta data after each changing.
To solve problem C/C++ need additional "saving hook".
The best way is:
- allow to register own LM. But LM accept only one instance of service.
Another way is:
- VCS provides new "saving service". C/C++ implements and register new service in look up. VCS invoke services before VCS actions.
Way that can have an resistance from NB API:
- VCS call PM.saveAll()
Way that does not work due to deadlock:
- C/C++ save meta data in sharability query.
So C/C++ cannot resolve issue inside C/C++. We need a help from VCS or LM.
Comment 29 Tomas Stupka 2011-02-24 14:45:29 UTC
> You are right it is C/C++ project responsibility to save dirty meta data.
> But C/C++ has a specific:
> - size of C/C++ meta data is much bugger then meta data of Java projects.
> - C/C++ meta data cannot be saved in EDT without slowness (1Mb in 8 files is
> ordinary size of meta data). Saving is done under "wait dialog".
> - C/C++ meta data is changed in much more places then Java meta data. For
> example: adding/removing files, changing current configuration/tool
> collection/development host, at run/debug, while debugging.
> So it is unreal to save meta data after each changing.
this makes the whole thing a bit more difficult to solve on the vcs side as vcs invokes LM.saveAll() in awt. I agree that this isn't to smartest thing to do but it typically deals with a few source files opened in the editor and didn't cause any known trouble yet. A change like you suggest would need a bigger rewrite. The 7.0 schedule is too tight now do that without a risk.

that an operation like removing a file leads to saving about 1mb of data is quite a thing and seems to be the cause of the whole problem. To state that "it is unrealistic to save the metadata when they should be saved" and to expect of everybody who runs into this kind of situation to deal with it on his own doesn't seem to be a realistic approach either. What about other situations, e.g. when the ide is closed or a makefile is to be used from the commandline? Maybe you can figure a few more cases... 

btw - what about saving the metadata in case of file add/remove only once, after the last filevent in an atomicaction?

as to the suggested solutions:
> To solve problem C/C++ need additional "saving hook".
> The best way is:
> - allow to register own LM. But LM accept only one instance of service.
> Another way is:
> - VCS provides new "saving service". C/C++ implements and register new service
> in look up. VCS invoke services before VCS actions.
> Way that can have an resistance from NB API:
> - VCS call PM.saveAll()
not very familiar with LM or PM, but calling PM.saveAllProject seems to be a more pragmatic approach than a new vcs api. 
cc Jesse, he might have something to add  ...

but one way or another, the effect is always the same - suddenly we would have to save dirty cnd metadata at some point in vcs. To do that properly asks for a bigger change in the vcs codebase. This all to workaround another problem which should be solved somewhere else. We would prefer not to do that. We don't know if there already is a precedence in nb for such a thing and we do not like to become such a precedence either.
Comment 30 Jesse Glick 2011-02-24 16:59:18 UTC
Calling ProjectManager.getDefault().saveAllProjects() before running VCS commands seems like the most reasonable solution. You probably want to do this call off EQ. (Saving modified files off EQ would be preferable too.) I'm not sure how this counts as a "big rewrite" but then I'm not familiar with the VCS codebase.

For non-CND projects saveAllProjects will very likely be a no-op, since other project types with savable metadata generally save any modifications very soon after making them - i.e. the client code might update a few properties in quick succession and then call saveProject at the end of the block.

(If we could design projectapi from scratch, I would probably have omitted ProjectState and API-level saving altogether; the project could just as easily persist coalesced change events in a background thread after ~100msec automatically, the way e.g. NbPreferences works, perhaps with a flush() method for clients that needed to immediately invoke external tools. This would have reduced the code burden on most API clients, and avoided a few hard-to-reproduce bugs triggered by clients that forgot to save their own changes. The fact that CND projects keep modified metadata in memory indefinitely - because they take so long to do saves - indicates that they have a poorly designed metadata format, which could perhaps be cleaned up in a future release.)
Comment 32 Tomas Stupka 2011-04-20 19:38:12 UTC
see #77210 - maybe that could also solve the problem with LM.saveAll() not saving cnd metadata