Bug 9869

Summary: Need more support for creating/deleting resources
Product: [Eclipse Project] Platform Reporter: James Moody <James_Moody>
Component: CompareAssignee: Andre Weinand <andre_weinand>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: erich_gamma, jean-michel_lemieux
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description James Moody CLA 2002-02-14 17:13:01 EST
Let me begin by stating what we're trying to do.
Compare With->Repository Contents is an ideal place to reconcile differences 
locally. Simple changes are easy, but additions and deletions are problematic. 
We would like to be able to copy an addition or deletion right-to-left, save, 
and have the resource created or deleted appropriately.

We identify at least two barriers to this:

1. In the addition case (where we have an existing repository node on the 
right and a non-existing resource node on the left), setContents() is not 
called on the node because, for example, the compare text viewer checks if the 
resource exists before calling setContents().

2. In the case of copying a deleted remote file from right-to-left and saving, 
we cannot distinguish the empty content case from the deletion case. In both 
cases, setContents is passed a zero-byte array. We would like to have some way 
to tell the difference between these two cases.

If you have any suggestions about how this can be resolved (either by Compare, 
or by us, or both), we'd appreciate it.
Comment 1 Andre Weinand CLA 2002-03-05 05:35:41 EST
fixed in 20020305.
No API change.

Addition case: ICompareInput.copy(boolean) is called (on your DiffNode) where 
you can create and copy the resource. If the resource is not only copied but 
modified too, a call to ITypedElement.setContents() follows immediately after 
the call to copy().

Deletion case: ICompareInput.copy(boolean) is called where you can delete the 
resource.

The default implementation of DiffNode.copy interprets the above cases and 
calls the replace and setContents methods on the affected ITypedElements. See 
org.eclipse.compare.internal.BufferedResourceNode for an example.