Open amadawn opened 10 years ago
I like the idea though detecting versioning systems might be challenging since there are a number of plugins for git/hg. Not sure there is a universal solution.
Right now it will periodically reindex files that changed in the workspace once Eclipse detects that they've changed. There will be some lag after changing branches but the re-indexing period can be configured in preferences InstaSearch.java#L68. Perhaps tuning that helps in your case.
And there is always the option to manually trigger Re-Indexing with the button from the toolbar.
I don't think that you should use any of the existing mercurial or git plugins to implement this feature.
In theory you should only need to execute a single mercurial or git command to detect that there has been a revision change ('hg id' in the case of mercurial and 'git log -1 --format="%H"' in the case of git). Thus it does not seem such a bad idea to simply execute the command and parse the command output. These commands are so common that they are extremely unlikely to ever change (in the case of mercurial it is guaranteed to never change, since mercurial never changes its command line "API").
So my proposal is to execute these commands relatively often (e.g. once every 10 or 15 seconds or so), and if their output changes then it means that a full reindex is needed.
As for the periodic reindex that you mention, what do you mean when you say "once Eclipse detects that they've changed"? I thought that instasearch would simply reindex all files every period?
Yes, InstaSearch re-indexes only files that have changed. Eclipse provides an api to listen for file changes and then every X seconds InstaSearch will re-index those that changed. Indexing job is scheduled here InstaSearch.java#L75. So, if everything works correctly, we shouldn't need to execute additional commands because Eclipse will tell the plugin about files that changed.
Another thing is that you shouldn't need a full re-index when switching branches because just a few files might have changed.
I'd encourage you to lower the re-indexing interval to, say, 5 seconds and see if within 10-15 seconds of switching branches new files appear in search results. If they don't then it could be a bug.
Currently instasearch can be configured to periodiacally rescan your workspace. This works well in many cases, but it breaks apart if you use a modern version control system such as mercurial or git which makes it very easy to update (or checkout) different revisions of your code, potentially changing a lot of files in the process.
It would be very nice if instasearch were mercurial and git aware. What I mean by that is that it should detect that the working directory is now pointing to a different revision and in that case it should know that it must rescan the corresponding project. Since checking whether the current revision has changed is very fast in both mercurial (hg id) and git (git log -1 --format="%H") this check could be performed often, and when a change was detected a rescan could be triggered.