Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 73260

Summary: [Sync View] Should automatically refresh before synchronising
Product: [Eclipse Project] Platform Reporter: Alain ésilets <alain.desilets>
Component: CVSAssignee: platform-cvs-inbox <platform-cvs-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P4 CC: avital.oliver, chrislong, ekuleshov, infomail, jamesblackburn+eclipse, noel, oyvind.harboe, preston, rnorton
Version: 3.0Keywords: helpwanted
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Alain ésilets CLA 2004-09-03 13:39:39 EDT
Context:
--------
On one of my projects, I have a regression test harness that runs some programs
and send their outputs to file. Then it compares the outputs to benchmark files
(which contain the expected output) to see if there are differences. Those
benchmark files are stored in CVS.

Whenever a change in a program that results in an expected difference in the
outputs, I copy the new outpus over the old benchmarks. This is done at the
command line, i.e. OUTSIDE OF ECLIPSE.

Bug symptoms
------------

The problem is that if I then do a synchronize with repository, Eclipse does not
show that the benchmark files need to be committed. Often, I don't notice this
and commit, resulting in a version in CVS whose benchmark files are out of synch
with what the code actually does.

This has happened to me time and time again, and has caused lot of confusion.
The next time I check out the code and run the regression test, it looks like
the system is broken when in fact, it's just that the benchmark files are out of
date.

It seems to me that synchronise with repository should automatically do a
Refresh before comparing with the content of the repository.

Thx

Alain Désilets
Comment 1 Jean-Michel Lemieux CLA 2004-09-10 09:09:03 EDT
Enable the following preference:
Preferences > Workbench > Refresh Workspace Automatically.
Comment 2 Michael Valenta CLA 2005-06-29 08:31:43 EDT
*** Bug 101915 has been marked as a duplicate of this bug. ***
Comment 3 Michael Valenta CLA 2005-08-15 14:32:15 EDT
*** Bug 106919 has been marked as a duplicate of this bug. ***
Comment 4 Michael Valenta CLA 2005-10-14 21:14:29 EDT
*** Bug 112296 has been marked as a duplicate of this bug. ***
Comment 5 Oyvind Harboe CLA 2005-10-15 10:57:10 EDT
Removing "Refresh" would help make CVS/Team functionality more accessible to a
wider audience, i.e. non-technical personell would find the Team functionality
less intimidating.
Comment 6 Michael Valenta CLA 2006-02-20 08:17:18 EST
*** Bug 128597 has been marked as a duplicate of this bug. ***
Comment 7 Michael Valenta CLA 2006-08-10 10:12:21 EDT
*** Bug 151949 has been marked as a duplicate of this bug. ***
Comment 8 Preston L. Bannister CLA 2006-08-10 14:05:22 EDT
First, this bug is marked as "PC/Windows XP" when the problem is generic.

Note that as written this bug specifies a solution (sync view in Eclipse before CVS operation), when the solution should be left up to the implementor.

The underlying problem is that CVS operations (and perhaps other "Team" operations) may fail if changes to the filesystem occur outside Eclipse.  

The current manual work-around is to perform a "Refresh".  The current suggested configuration work-around is to enable the option under Preferences | General | Workspace | "Refresh automatically".  Neither is optimal.

I am assuming that the manual "Refresh" operation on a project in Eclipse visits the directory enties for all files within the project.  I am also assuming that for some large projects the "Refresh" operation is expensive (especially when files are remote).

The current implementation does not perform a "Refresh" before "Team" operations.  This is optimal and correct *most* of the time (when changes are made from within Eclipse).

On Windows we can use file-change notifications to detect when changes are made outside of Eclipse.  This is optimal and will catch *most* changes (not all!) - but only on Windows.  This is a very worthwhile optimization given the majority of Eclipse users are likely on Windows desktops.  Unfortunately the file-change notifications are *not* currently looked for by default.

On non-Windows platforms (and on Windows when file-change notifications fail) performing a full-tree refresh is a non-optimal waste of time, in *most* cases.

This is a case where being lazy is optimal. :)

Better to omit the full-refresh operation until needed.  The CVS client in Eclipse currently detects when a refresh is needed.  When the CVS client complains - then and only then force an automatic refresh.
Comment 9 Michael Valenta CLA 2006-08-10 16:47:37 EDT
The problem is that the CVS operations in Eclipse are built on top of the Workspace resources and make use of the cached file information (for improved performance). Because of this, a CVS operation may miss externally modified files (i.e. the operation would not detect that a refresh is needed). Here is a restatement of what you said with some additional comments.

1) On windows, the file system can notify clients of file system changes. The Eclipse "refresh automatically" preference makes use of this facility already. Therefore, on Windows, your best bet is to enable the preference.

2) On Linux and other platforms, we need to poll for changes. One way to do this is the run a job every so often that looks for changes which is what the "refresh automatically" preference does on these platforms. Another is for the user (or the CVS operation) to explicitly perform a refresh. In the former case, it is possible that changes get missed. The later has a perfomance overhead but will ensure that external changes are not missed.

Given the above, it looks to me that the best solution is to provide a preference to perform a refresh before certain CVS operations (e.g. synchronize, update, and commit). On windows, you probably wouldn't need to use it since the "refresh automatically" uses the windows API to be notified of changes but you may want to use it on other platforms where the automatic refresh uses polling.

Comment 10 Preston L. Bannister CLA 2006-08-10 19:17:59 EDT
Thanks for the clarification - in particular where I was reduced to guessing about Eclipse implementation. :)

At the risk of repeating - on Windows the file-change notification is a best-effort service.  For local files the file-change notification is very reliable.  For remote files, it might work.  

http://support.microsoft.com/kb/q188321/
http://support.microsoft.com/kb/271148/EN-US/
(also local changes on Samba servers)

Since the filesystem changes other than through Eclipse are more unusual than usual, performing a refresh every time is not optimal.

Could skip the unconditional refresh.  Could delay performing a refresh until the need is indicated by the CVS client.  

Seems like this breaks down into the following cases - in order of probability.

1.  Local files on Windows : Optimal default would be to use file-change notifications so "Refresh" is never needed.  

2.  Local files on non-Windows : Optimal default would be to perform "Refresh" before CVS operations (walking the local filesystem is cheap).

3.  Remote files on any platform : Optimal default would be to perform "Refresh" only if the CVS operation fails (due to stale info).

(And again this is not PC/Windows XP specific.)
Comment 11 Oyvind Harboe CLA 2006-08-11 01:39:47 EDT
The biggest impact of this bug is that newcomers to Eclipse(or indeed developers in general that loathe version control, yes, they do exist) keep stumbling over minor issues with CVS/Team in Eclipse.

With this in mind, I would like no configuration options, nothing to read up on, no user enforced rules, it should just work.

- If automatic refresh works without negative side effects, then it should be made default and the Refresh button should be removed(at least when automatic refresh is enabled). Note that novice users can have a large number of files in their projects. Automatic Refresh with a Refresh button does not inspire to great confidence in that feature.
- If automatic refresh is off, then a forced Refresh(or it's equivalent thereof implementation wise) should happen before a Team synchronize.
Comment 12 Robert Norton CLA 2006-11-20 10:09:26 EST
*** Bug 165158 has been marked as a duplicate of this bug. ***
Comment 13 Robert Norton CLA 2006-11-20 10:11:45 EST
This bug can result in corruption of working tree (i.e. data loss) as described in above bug.
Comment 14 Preston L. Bannister CLA 2006-11-20 12:17:44 EST
To add to prior comments ...

Behaviors (1) or (2) should be ENABLED by default (rather than disabled) as this is simply the right thing to do the vast majority of the time.  I believe all this requires is a change in the default value of an option.

Behavior (3) is likely to require new code, may be tricky, but is optimal for remote/large sets of resources.  The idea is to:
a) Run the CVS operation (or other "Team" implementation?).
b) If the CVS client reports "out of sync" then force (2), a full tree refresh.
c) Re-run the CVS operation (once).

(And again this is *NOT* PC/Windows XP specific.)

Comment 15 Robert Norton CLA 2006-11-20 12:36:48 EST
Other commenters seem to be mentioning a warning about the file system being out of sync. I never receive such a warning using Eclipse 3.2.0 and got a corrupted checkout as a result. Is this then a separate bug?
Comment 16 Michael Valenta CLA 2006-11-20 13:04:18 EST
The warning happens in some situations and not others (e.g. if the file had an outgoing change and then was modified externally, you would get a warning but if the file was clean when it was modified externally, you wouldn't).
Comment 17 Robert Norton CLA 2006-11-20 13:11:22 EST
OK. In fact all my edits are happening within Eclipse -- it is just the commit which was done on the command line. Is it possible to detect if the CVS/Entries file has been modified outside of Eclipse and issue the same warning in this case?
Comment 18 Michael Valenta CLA 2006-11-20 13:24:39 EST
It would be possible but, in the end, you would end up doing just as much work as a refresh (i.e. you would need to compare the cached timestamp with the on-disk timestamp for every file.
Comment 19 Avital Oliver CLA 2007-01-03 12:54:47 EST
This bug happened to me several times, but in my case refresh does *not* solve the issue. I tried reproducing the bug and succeeded.

This is the scenario:
I create a new CVS module with one file (0.mp3). If I change 0.mp3 from an external editor (a text editor), and then refresh in eclipse, it notices the change. 

But, if I run a different program (in this case id3remover [http://sourceforge.net/projects/id3remover/]), it does *not* notice the change, although the file size has changed.

When I tried to research it better, I noticed that id3remover does *not* change the date of the file.

Is there a solution for this scenario?
Comment 20 Michael Valenta CLA 2007-01-03 13:01:24 EST
It seems odd that the timestamp is not changed when the file contents have changed. You may want to contact the providers of the software in question to see if this is intended behavior.
Comment 21 Avital Oliver CLA 2007-01-03 13:06:41 EST
That is true, and I can never be sure that other programs won't have the same behavior. Could there be a way of doing some sort of 'hard refresh' which compares some type of hash for each file? What would happen if I used the command prompt and did a 'cvs commit'? Would it recognize the changed files?
Comment 22 Michael Valenta CLA 2007-01-03 13:20:09 EST
What you propose would have a cost that is not trivial. I think it is reasonable to assume that, if the contents of a file are changed that clients can expect the timestamp to change. Conversely, it is reasonable to expect that there will be problems if the contents of a file are changed and the timestamp is not changed.
Comment 23 Avital Oliver CLA 2007-01-03 13:22:02 EST
It is reasonable to assume that, but in my case I have modified files which I *cannot* commit. My only solution would be to touch them and then commit them, but I would like to avoid future situations similar to this one, instead of just finding a 'patch' solution here.
Comment 24 Michael Valenta CLA 2007-01-03 13:32:33 EST
If your assessment is correct, the proper solution would be to get a fixed version of the software that is at fault. I think it is unreasonable to expect that every piece of software that depends on the timestamp to indicate that the contents of a file has changed should be modified to compensate for such a bug. If you can't get an updated version of the software, then your stated work around sounds reasonable to me. 

I must admit that I am surprised that the software in question would modify the file contents with out changing the modification timestamp given that they would explicitly need to write the code to prevent the timestamp from changing (i.e. the file system write will automatially change the timestamp). Seriously, I would contact the providers of the software or post on one of their forums to see why this is occurring.
Comment 25 Preston L. Bannister CLA 2007-06-21 12:45:00 EDT
First, this issue is (still!) marked PC/Windows-specific for "OS".
This is wrong.  The issue applies to all platforms.

Second, I am not sure what the change in priority means, but "least important" does not seem right.  Eclipse does the wrong thing in this instance.  It is easy to forget just how confusing this behavior can be for someone not familiar with the underlying implementation.

Comment 26 Michael Valenta CLA 2007-06-21 13:00:44 EDT
Fair enough. I can increase the priority. However, we just don't have enough manpower to address this issue. Contributions are appreciated.
Comment 27 Oyvind Harboe CLA 2007-06-21 16:27:35 EDT
I'd just like to say that I find this is the single most annoying problem with the Eclipse Team->CVS support today. Especially as it seems like, over time, more changes are happening to files behind Eclipse back as more and more projects are undertaken under the Eclipse umbrella.

It is especially annoying when teaching people to use Eclipse & CVS who have never set their foot in a source control system and who are looking for *any* excuse to sabotage adoption of source control :-)
Comment 28 Eclipse Webmaster CLA 2019-09-06 16:15:13 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 29 Eclipse Genie CLA 2021-09-22 16:49:09 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.