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

Bug 357263

Summary: [ccp] Copying an empty folder and pasting onto self loops infinitely
Product: [Eclipse Project] Platform Reporter: Randy Hudson <hudsonr>
Component: UIAssignee: Dani Megert <daniel_megert>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: cbmcgee, daniel_megert, jwkeck15, markus.kell.r, raksha.vasisht, remy.suen
Version: 3.6.2   
Target Milestone: 3.8 M4   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Eclipse about dialog
none
Showing the problem none

Description Randy Hudson CLA 2011-09-09 13:10:29 EDT
The "New folder" wizard takes so many steps, I tried simply copying an empty folder named "web" and pasting it onto itself, after which I would have renamed it.

But, the paste action ran recursively.  Instead of copying the contents of the folder at the time I invoked copy, it seemed pick up the folder's new content as a result of the ongoing paste operation.  I was able to interrupt the operation eventually, but I ended up with tons of folders:

web/web/web/web/web/web/web/web/web…
Comment 1 Remy Suen CLA 2011-09-09 15:02:16 EDT
(In reply to comment #0)
> The "New folder" wizard takes so many steps, I tried simply copying an empty
> folder named "web" and pasting it onto itself, after which I would have renamed
> it.
> 
> But, the paste action ran recursively.

I just tried this on 3.6.2 on Windows XP and I got an error dialog saying 'Cannot import 'web'. The source and destination are the same.'.

Randy, what kind of project were you using? Do you get the same problem if you just make a generic project (non-Java/non-C/nothing)?
Comment 2 Randy Hudson CLA 2011-09-09 15:54:07 EDT
Plug-in project.  The path to my eclipse workspace includes uppercase characters.
Comment 3 Oleg Besedin CLA 2011-09-12 09:52:03 EDT
On Mac using either 3.6.2 or 3.8M1 I am getting "Cannot import 'web'. The source and destination are the same." error message. (Same for workspace with upper case characters.)

BTW, the "New Folder" wizard has exactly one step unless you go into "Advanced" settings.
Comment 4 Randy Hudson CLA 2011-09-12 12:19:13 EDT
Created attachment 203172 [details]
Eclipse about dialog
Comment 5 Randy Hudson CLA 2011-09-12 12:19:54 EDT
Created attachment 203173 [details]
Showing the problem
Comment 6 Randy Hudson CLA 2011-09-12 12:21:22 EDT
(In reply to comment #3)
> On Mac using either 3.6.2 or 3.8M1 I am getting "Cannot import 'web'.

"Cannot import"?  Why would it say import when the action was "paste"?

BTW, I was referring to the steps needed just to get to the New Folder wizard as well.
Comment 7 Remy Suen CLA 2011-09-12 13:10:02 EDT
(In reply to comment #6)
> "Cannot import"?  Why would it say import when the action was "paste"?

I think this is an artefact of the action being from JDT.

Both the 'Package Explorer' and 'Project Explorer' gave me the same error message, the 'Navigator' didn't let me execute the Ctrl+V. Randy, which view were you in when you got this problem?

To be clear, this is what I did.

1. Make a new plug-in project.
2. Create a folder named 'web' in the root of this project.
3. Select this 'web' project in the 'Package Explorer'.
4. Ctrl+C
5. Ctrl+V
6. An error dialog appears preventing me from executing this operation.
Comment 8 Randy Hudson CLA 2011-09-12 14:47:39 EDT
I was in the Package Explorer
Comment 9 Dani Megert CLA 2011-09-13 01:29:56 EDT
Raksha, please investigate.
Comment 10 Raksha Vasisht CLA 2011-10-24 06:48:26 EDT
(In reply to comment #3)
> On Mac using either 3.6.2 or 3.8M1 I am getting "Cannot import 'web'. The
> source and destination are the same." error message. (Same for workspace with
> upper case characters.)
Same with Mac OSX 10.6.8 with 3.8 build I20111004-1128 and on windows 7 with build I20111021-0800. 

(In reply to comment #7)
> (In reply to comment #6)
> Both the 'Package Explorer' and 'Project Explorer' gave me the same error
> message, the 'Navigator' didn't let me execute the Ctrl+V. Randy, which view
> were you in when you got this problem?
> 
> To be clear, this is what I did.
> 
> 1. Make a new plug-in project.
> 2. Create a folder named 'web' in the root of this project.
> 3. Select this 'web' project in the 'Package Explorer'.
> 4. Ctrl+C
> 5. Ctrl+V
> 6. An error dialog appears preventing me from executing this operation.

Randy, could you pls provide steps if it differs from the above? Also, can you always reproduce it?
Comment 11 Dani Megert CLA 2011-10-24 12:37:10 EDT
Looks like this has been fixed during 3.7.
Comment 12 Dani Megert CLA 2011-10-25 02:26:20 EDT
(In reply to comment #11)
> Looks like this has been fixed during 3.7.

I quickly tried in 3.6.2 and it works there as well.
Comment 13 Randy Hudson CLA 2011-10-25 10:19:31 EDT
(In reply to comment #12)
> I quickly tried in 3.6.2 and it works there as well.

Dani, I didn't understand your last comment ("works").  This bug was filed against 3.6.2.
Comment 14 Dani Megert CLA 2011-10-25 10:29:16 EDT
(In reply to comment #13)
> (In reply to comment #12)
> > I quickly tried in 3.6.2 and it works there as well.
> 
> Dani, I didn't understand your last comment ("works").  This bug was filed
> against 3.6.2.

Yes that's why I tested it in 3.6.2 and I cannot reproduce it i.e. "works fine". Same as what Oleg already mentioned in comment 3.
Comment 15 Randy Hudson CLA 2011-10-25 11:30:47 EDT
[in package explorer]

1) Inside a project, create nested folders "parent/child"
2) Select "parent" and copy
3) Select "child" and paste
Comment 16 Dani Megert CLA 2011-10-25 12:06:19 EDT
(In reply to comment #15)
> [in package explorer]
> 
> 1) Inside a project, create nested folders "parent/child"
> 2) Select "parent" and copy
> 3) Select "child" and paste

OK, this I can reproduce (but not the copy onto itself as reported in comment 0). Also fails with Juno M2.
Comment 17 Dani Megert CLA 2011-10-25 12:30:20 EDT
Raksha, we should disable 'Paste' in this case (like the Navigator does).
Comment 18 Raksha Vasisht CLA 2011-11-03 05:26:33 EDT
(In reply to comment #17)
> Raksha, we should disable 'Paste' in this case (like the Navigator does).

Navigator does not disable paste but shows a dialog with msg :
"Destination cannot be a descendent of the source". We (JDT/UI) also detect such cases and return with an error msg in 

org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory.FilesFoldersAndCusReorgPolicy.verifyDestination(IResource)

The fix has to go in 

org.eclipse.ui.actions.CopyFilesAndFoldersOperation.validateImportDestinationInternal(IContainer destination, IFileStore[] sourceStores)

here: 

....

// work around bug 16202. replacement for
// sourcePath.isPrefixOf(destinationPath)
IFileStore destinationParent = destinationStore.getParent();
if (sourceStore.isParentOf(destinationParent)) {
.....


There should also be a check for sourceStore.equals(destinationParent). 

Moving to Platform UI.
Comment 19 Dani Megert CLA 2011-11-08 09:12:47 EST
> // work around bug 16202. replacement for
> // sourcePath.isPrefixOf(destinationPath)
> IFileStore destinationParent = destinationStore.getParent();
> if (sourceStore.isParentOf(destinationParent)) {
> .....
> 
> 
> There should also be a check for sourceStore.equals(destinationParent). 

Nope, it should simply compare with the destinationStore.
Comment 20 Dani Megert CLA 2011-11-08 09:14:09 EST
Fixed in master: b24ba5418fc852ee518e5aad66e8e0bc93469a6c
Comment 21 Dani Megert CLA 2011-11-08 09:14:55 EST
(In reply to comment #20)
> Fixed in master: b24ba5418fc852ee518e5aad66e8e0bc93469a6c
Sorry, of course it's in R3_development.
Comment 22 Dani Megert CLA 2011-11-17 10:09:29 EST
(In reply to comment #21)
> (In reply to comment #20)
> > Fixed in master: b24ba5418fc852ee518e5aad66e8e0bc93469a6c
> Sorry, of course it's in R3_development.

Cherry-picked to master: 50356ff1cb6948a904a0eeeeee25141ad1295f92
Comment 23 Dani Megert CLA 2012-02-15 07:20:51 EST
*** Bug 371415 has been marked as a duplicate of this bug. ***
Comment 24 Dani Megert CLA 2012-02-23 04:38:24 EST
*** Bug 372299 has been marked as a duplicate of this bug. ***