Bug 143757 - [Import/Export] Cannot Import existing project into workspace if <name> different from actual folder name
Summary: [Import/Export] Cannot Import existing project into workspace if <name> diffe...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M1   Edit
Assignee: Karice McIntyre CLA
QA Contact:
URL: http://www.eclipse.org/newsportal/art...
Whiteboard:
Keywords:
: 76417 140733 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-25 12:18 EDT by Jeevan Sunkersett CLA
Modified: 2006-08-09 13:45 EDT (History)
5 users (show)

See Also:


Attachments
Fix (1.96 KB, patch)
2006-06-27 16:18 EDT, John Arthorne CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeevan Sunkersett CLA 2006-05-25 12:18:30 EDT
Hi,

I am not sure where this belongs Core/ UI or Debug; however discovered this today,

In eclipse I can "Import exiting projects into Workspace", *IF and only IF* the <name></name> in the .project file matches the name of the folder in which it exists.

To confirm; I created a Java project in my workspace, by name HelloWorld.
Subsquently deleted it from workspace, WITHOUT deleting contents from the file system.
Next in the file system, edited ONLY the ".project" file of this project.
I changed <name>HellWorld</name> into <name>Not-HelloWorld</name>
Returning back to eclipse, tried the command File -> Import -> Import exiting projects into Workspace

Specified the folder for the HelloWorld. The Projects list box in the dialog listed Not-HelloWorld. (read the .project file). I selected it and clicked finnish. An error dialog popped up, saying Invalid project description.
Detail showed   D:\Users\Jeevan\workspace\HelloWorld overlaps the workspace location: D:\Users\Jeevan\workspace.

I reedited the .project file manually and restored the <name></name> following which I was able to import it into my workspace.

This happens with:
Eclipse SDK
Version: 3.1.2
Build id: M20060118-1600

But does NOT with a older version.
Eclipse SDK
Version: 3.1.0
Build id: I20050627-1435
Comment 1 Jeevan Sunkersett CLA 2006-05-25 12:49:37 EDT
(In reply to comment #0)
Yes, following the example I indicate to recreate the bug, there may be no valid reason for editing a .project file.
But I chanced on this behaviour cause my .classpath and .project files were created by the maven2 task eclipse:eclipse.

~g1
Comment 2 Olivier Thomann CLA 2006-05-25 15:57:20 EDT
Moving to JDT/UI
Comment 3 Martin Aeschlimann CLA 2006-05-26 04:30:53 EDT
'Import exiting projects into Workspace' is platform/ui
Comment 4 Jeevan Sunkersett CLA 2006-06-21 12:10:00 EDT
Hi,

There has been no change/ action with regards to this bug.
I would like to know if it has been accepted and will it be rectified in future versions?

thx
Comment 5 Todd Jonker CLA 2006-06-22 18:02:45 EDT
Looking at http://dev.eclipse.org/newslists/news.eclipse.platform/msg42442.html it appears that this may not be a bug, and instead an attempt to make sure that paths  within the workspace (virtual or real) are unique.

What IS a problem is that the error message is utterly uninformative about the root issue (project name doesn't match directory name).  I've wasted lots of time tracking this down every few months...
Comment 6 Karice McIntyre CLA 2006-06-26 17:20:20 EDT
I get the invalid project description error in 3.1.0 Build id: I20050627-1435, so this is not a regression.  The UI displays the error messages it gets from Core and it is expanded upon in the details.  Also, it isn't always the case that the project name has to match the name of the root folder, as was mentioned in the newsgroup posting that is referenced in comment #5.  Moving to Resources to see if they can provide a better error message in this case.  
Comment 7 Karice McIntyre CLA 2006-06-26 17:22:42 EDT
*** Bug 140733 has been marked as a duplicate of this bug. ***
Comment 8 Karice McIntyre CLA 2006-06-26 17:35:57 EDT
John, feel free to punt back if it is more appropriate that the UI do an additional check, in an attempt to get a more fine-grained error message, before we try to create the project.  
Comment 9 John Arthorne CLA 2006-06-27 15:00:16 EDT
The problem here is that creating a project called "foo" in a directory called "bar" in the workspace is not allowed.  You can't store a project in the default location for another project.  However, the import wizard *could* be changed to use the directory name rather than the name in the .project file as the project name, and then the import would proceed without error.

*** This bug has been marked as a duplicate of 40493 ***
Comment 10 Todd Jonker CLA 2006-06-27 15:32:34 EDT
I don't think it's accurate to call this a duplicate of 40493.  True, if that issue is in fact resolved, then this one should become irrelevant.  But if that issue is not resolved (and a comment says it won't be fixed for 3.2) then this issue still exists: the error message is misleading and causes user pain.

It should be much easier to fix the error message, and get that fix in 3.2, than to add new features that work around the core error condition.
Comment 11 John Arthorne CLA 2006-06-27 15:39:14 EDT
> It should be much easier to fix the error message, and get that fix in 3.2

We have already declared the final 3.2 build.  We are now working on 3.3. In 3.3, it would be more interesting to allow such an import to proceed than to improve the error message.
Comment 12 John Arthorne CLA 2006-06-27 16:16:13 EDT
On further reflection, you're right.  This isn't entirely a duplicate of bug 40493.  That bug is requesting the ability to change the name of a project on import.  This particular error can be solved by using the directory name rather than the name in .project in the case where the project resides in the default location.
Comment 13 John Arthorne CLA 2006-06-27 16:18:22 EDT
Created attachment 45408 [details]
Fix

Karice, this patch uses the project directory as the project name when importing a project in the workspace directory.  Since that is the only valid name for a project in that location, this seems like the correct behaviour.
Comment 14 Karice McIntyre CLA 2006-06-27 18:59:53 EDT
Thanks for the patch, John.  I applied it and just have some minor points to bring up.  Do you think it is confusing to have the project name in the list be the folder name instead of what is in the .project file as the name?  I think it would be helpful to have the name of the project (in the .project file) followed by the folder name (if different) appear in the list. I am still thinking about a nice way to display this in the list - I haven't thought much about how I would display the folder for  projects that are not in the default workspace location.  What do you think?
Comment 15 John Arthorne CLA 2006-06-28 13:29:25 EDT
I can see the potential for confusion, but it seems just as confusing to present two names in the list. The behaviour with the patch is actually consistent with how the underlying APIs work.  For example if you create a new project called "Foo", but there is an existing .project file on disk in that location whose name is "Bar", then the name in the .project file is ignored and "Foo" is used. I.e., the name in the description is really only a "hint" about what the name should be, but it can be overridden.
Comment 16 Karice McIntyre CLA 2006-06-28 14:15:50 EDT
Ah yes, good point.  
Comment 17 Karice McIntyre CLA 2006-06-28 14:25:49 EDT
I just found a case where you can have 2 projects with the same name in the import list.  If, in one workspace, you have a project called A and a project called B then change the name in the .project file of B to A then (in another workspace) do import project, you will have two projects called A in the list.  Should we always use the name of the directory as the name we show in the list of projects to import?
Comment 18 John Arthorne CLA 2006-06-28 14:59:08 EDT
The directory name only needs to match the project name when it is in the default location (a direct sub-directory of the workspace directory).

I guess the ultimate fix is to let the user chose the name of each project that is not in the default location from within the wizard (bug 40493).
Comment 19 Karice McIntyre CLA 2006-06-28 15:47:32 EDT
Ok then, this will hold over until that bug can be fixed.  Fixed in HEAD for build > 20060628.  Oh, and I changed the title back to what it was originally.
Comment 20 Karice McIntyre CLA 2006-06-28 16:04:39 EDT
*** Bug 76417 has been marked as a duplicate of this bug. ***
Comment 21 Karice McIntyre CLA 2006-08-09 13:45:26 EDT
verified in I20060809-0010