Bug 15192 - PackageFragment::copy never overwrites
Summary: PackageFragment::copy never overwrites
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 3926
  Show dependency tree
 
Reported: 2002-05-03 10:51 EDT by Adam Kiezun CLA
Modified: 2002-05-16 11:18 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2002-05-03 10:51:01 EDT
20020502
setup is: 2 jProjects a and b - both with 1 source folder src and a package p 
inside

i call copy(destination, null, null, true, pm)
were the receiver is 'p' in 'a' and 'destination' is 'src' in 'b' 

it does not overwrite as spec'ed
Comment 1 Olivier Thomann CLA 2002-05-09 16:08:58 EDT
I traced the problem 
till
org.eclipse.jdt.internal.corext.refactoring.changes.CopyPackageChange
protected 
void doPerform(IProgressMonitor pm) throws 
JavaModelException{
	getPackage().copy(getDestination(), null, getNewName(), true, 
pm);
}
if you replace this call with:
protected void doPerform(IProgressMonitor pm) 
throws JavaModelException{
	getPackage().copy(getDestination(), null, null, true, 
pm);
}
it works as expected. Then I cannot reproduce the problem.
Here is the scenario I 
tried:
1) Create a project P with a source folder src, in which you create a package p, in which you 
create a class A.
2) Create a project P1 with a source folder src, in which you create a package p, 
in which you create a class A with a different contents from A in P.
3) Select p in P/src and copy 
it.
4) Paste in P1/src.
5) Open A in P1. It has the same contents than A in P.

So I believe it is 
working as expected. If my test case doesn't work for you, please give me the complete steps and the 
version of JDT/Core you are using.

Comment 2 Adam Kiezun CLA 2002-05-14 04:30:31 EDT
the thing is - getName() equals null so it is the same code really.

here's my scenario:
1. project s, source folder src, package p, file A.java, X.java
2. project s1, source folder src, package p, files A.java (different content 
than the other A.java) and B.java

now, after asking you to overwrite it does overwrite A.java's content
but X.java is not deleted as i'd expect
Comment 3 Olivier Thomann CLA 2002-05-14 10:48:37 EDT
I don't see why the class X would be removed. It is not a conflict case. For me 
it should only override the conflicts between the source and the destination.
Comment 4 Adam Kiezun CLA 2002-05-14 10:53:49 EDT
then the doc is confusing - it says that the content will be replaced.
so i assumed that the content of the package will be replaced.
but it was just merged.

it's really merging - not overwritting
Comment 5 Olivier Thomann CLA 2002-05-14 11:34:03 EDT
Then I will simply clarify the doc and then close the PR. Is this ok for you?
Comment 6 Olivier Thomann CLA 2002-05-14 11:52:38 EDT
Could you please tell me which doc is incorrect? I looked at the ISourceManipulation 
documentation for the method copy and IJavaModel copy and they looked pretty straight forward.
Comment 7 Adam Kiezun CLA 2002-05-14 12:17:08 EDT
it is straighforawrd but the actual behavior is different than what the doc 
says.

the doc:
* @param replace <code>true</code> if any existing child in the container with
*   the target name should be replaced, and <code>false</code> to throw an
*   exception in the event of a name collision

behavior: target is not replaced - it is merged with the existing target
Comment 8 Olivier Thomann CLA 2002-05-14 12:47:37 EDT
No, I disagree. It is replaced. It is not merged. The contents of a conflict is 
replaced with the contents of the conflicting file from the source container. 
It doesn't say that the target container will be replaced with the contents of 
the source container. It simply refers to the child collision case. I don't 
want to be picky, but I would say the doc is clear enough.
Comment 9 Adam Kiezun CLA 2002-05-14 13:38:43 EDT
it's really ok for me. 
would have to check what explorer does when you do 'overwrite' on folders.
but i guess you're right - it does the same as jcore.
ok to close. will reopen if anything.
thanks.
Comment 10 Olivier Thomann CLA 2002-05-16 11:17:41 EDT
This appears not to be a bug.
Closed.