Index: /trunk/src/org/openstreetmap/josm/command/Command.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/Command.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/command/Command.java	(revision 3034)
@@ -2,7 +2,8 @@
 package org.openstreetmap.josm.command;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -32,5 +33,5 @@
 
     private static final class CloneVisitor extends AbstractVisitor {
-        public Map<OsmPrimitive, PrimitiveData> orig = new HashMap<OsmPrimitive, PrimitiveData>();
+        public final Map<OsmPrimitive, PrimitiveData> orig = new LinkedHashMap<OsmPrimitive, PrimitiveData>();
 
         public void visit(Node n) {
@@ -72,5 +73,5 @@
     public boolean executeCommand() {
         CloneVisitor visitor = new CloneVisitor();
-        Collection<OsmPrimitive> all = new HashSet<OsmPrimitive>();
+        Collection<OsmPrimitive> all = new ArrayList<OsmPrimitive>();
         fillModifiedData(all, all, all);
         for (OsmPrimitive osm : all) {
Index: /trunk/src/org/openstreetmap/josm/command/CoordinateConflictResolveCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/CoordinateConflictResolveCommand.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/command/CoordinateConflictResolveCommand.java	(revision 3034)
@@ -23,5 +23,5 @@
 
     /** the conflict to resolve */
-    private Conflict<Node> conflict;
+    private Conflict<? extends OsmPrimitive> conflict;
 
     /** the merge decision */
@@ -35,6 +35,6 @@
      * @param decision the merge decision
      */
-    public CoordinateConflictResolveCommand(Node my, Node their, MergeDecisionType decision) {
-        this.conflict = new Conflict<Node>(my,their);
+    public CoordinateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) {
+        this.conflict = conflict;
         this.decision = decision;
     }
@@ -61,6 +61,6 @@
             // do nothing
         } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) {
-            Node my = conflict.getMy();
-            Node their = conflict.getTheir();
+            Node my = (Node)conflict.getMy();
+            Node their = (Node)conflict.getTheir();
             my.setCoor(their.getCoor());
         } else
Index: /trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java	(revision 3034)
@@ -23,5 +23,5 @@
 
     /** the conflict to resolve */
-    private Conflict<OsmPrimitive> conflict;
+    private Conflict<? extends OsmPrimitive> conflict;
 
     /** the merge decision */
@@ -35,6 +35,6 @@
      * @param decision the merge decision
      */
-    public DeletedStateConflictResolveCommand(OsmPrimitive my, OsmPrimitive their, MergeDecisionType decision) {
-        this.conflict = new Conflict<OsmPrimitive>(my, their);
+    public DeletedStateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) {
+        this.conflict = conflict;
         this.decision = decision;
     }
@@ -61,9 +61,10 @@
 
         if (decision.equals(MergeDecisionType.KEEP_MINE)) {
-            if (conflict.getMy().isDeleted()) {
+            if (conflict.getMy().isDeleted() || conflict.isMyDeleted()) {
                 // because my was involved in a conflict it my still be referred
                 // to from a way or a relation. Fix this now.
                 //
                 layer.data.unlinkReferencesToPrimitive(conflict.getMy());
+                conflict.getMy().setDeleted(true);
             }
         } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) {
@@ -86,4 +87,5 @@
             Collection<OsmPrimitive> added) {
         modified.add(conflict.getMy());
+        modified.addAll(conflict.getMy().getReferrers());
     }
 }
Index: /trunk/src/org/openstreetmap/josm/command/ModifiedConflictResolveCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/ModifiedConflictResolveCommand.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/command/ModifiedConflictResolveCommand.java	(revision 3034)
@@ -24,5 +24,5 @@
 
     /** the conflict to resolve */
-    private Conflict<OsmPrimitive> conflict;
+    private Conflict<? extends OsmPrimitive> conflict;
 
     /**
@@ -31,6 +31,6 @@
      * @param their their primitive (i.e. the primitive from the server)
      */
-    public ModifiedConflictResolveCommand(OsmPrimitive my, OsmPrimitive their) {
-        conflict = new Conflict<OsmPrimitive>(my, their);
+    public ModifiedConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
+        this.conflict = conflict;
     }
 
Index: /trunk/src/org/openstreetmap/josm/command/TagConflictResolveCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/TagConflictResolveCommand.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/command/TagConflictResolveCommand.java	(revision 3034)
@@ -29,5 +29,5 @@
 
     /** the conflict to resolve */
-    private Conflict<OsmPrimitive> conflict;
+    private Conflict<? extends OsmPrimitive> conflict;
 
     /** the list of merge decisions, represented as {@see TagMergeItem}s */
@@ -56,6 +56,6 @@
      * @param mergeItems the list of merge decisions, represented as {@see TagMergeItem}s
      */
-    public TagConflictResolveCommand(OsmPrimitive my, OsmPrimitive their, List<TagMergeItem> mergeItems) {
-        this.conflict = new Conflict<OsmPrimitive>(my,their);
+    public TagConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, List<TagMergeItem> mergeItems) {
+        this.conflict = conflict;
         this.mergeItems = mergeItems;
     }
Index: /trunk/src/org/openstreetmap/josm/command/VersionConflictResolveCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/VersionConflictResolveCommand.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/command/VersionConflictResolveCommand.java	(revision 3034)
@@ -24,5 +24,5 @@
 
     /** the conflict to resolve */
-    private Conflict<OsmPrimitive> conflict;
+    private Conflict<? extends OsmPrimitive> conflict;
 
     /**
@@ -31,6 +31,6 @@
      * @param their their primitive (i.e. the primitive from the server)
      */
-    public VersionConflictResolveCommand(OsmPrimitive my, OsmPrimitive their) {
-        conflict = new Conflict<OsmPrimitive>(my, their);
+    public VersionConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
+        this.conflict = conflict;
     }
 
@@ -39,7 +39,7 @@
         String msg = "";
         switch(OsmPrimitiveType.from(conflict.getMy())) {
-            case NODE: msg = marktr("Resolve version conflict for node {0}"); break;
-            case WAY: msg = marktr("Resolve version conflict for way {0}"); break;
-            case RELATION: msg = marktr("Resolve version conflict for relation {0}"); break;
+        case NODE: msg = marktr("Resolve version conflict for node {0}"); break;
+        case WAY: msg = marktr("Resolve version conflict for way {0}"); break;
+        case RELATION: msg = marktr("Resolve version conflict for relation {0}"); break;
         }
         return new DefaultMutableTreeNode(
Index: /trunk/src/org/openstreetmap/josm/command/WayNodesConflictResolverCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/WayNodesConflictResolverCommand.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/command/WayNodesConflictResolverCommand.java	(revision 3034)
@@ -41,6 +41,7 @@
      * @param mergedNodeList  the list of merged nodes
      */
-    public WayNodesConflictResolverCommand(Way my, Way their, List<Node> mergedNodeList) {
-        conflict = new Conflict<Way>(my,their);
+    @SuppressWarnings("unchecked")
+    public WayNodesConflictResolverCommand(Conflict<? extends OsmPrimitive> conflict, List<Node> mergedNodeList) {
+        this.conflict = (Conflict<Way>) conflict;
         this.mergedNodeList = mergedNodeList;
     }
Index: /trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java	(revision 3034)
@@ -21,8 +21,14 @@
     private final T my;
     private final T their;
+    private final boolean isMyDeleted;
 
     public Conflict(T my, T their) {
+        this(my, their, false);
+    }
+
+    public Conflict(T my, T their, boolean isMyDeleted) {
         this.my = my;
         this.their = their;
+        this.isMyDeleted = isMyDeleted;
     }
 
@@ -96,3 +102,12 @@
         return true;
     }
+
+    /**
+     * 
+     * @return True if my primitive was deleted but it has set non deleted status because it's referred by another
+     * primitive and references to deleted primitives are not allowed.
+     */
+    public boolean isMyDeleted() {
+        return isMyDeleted;
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java	(revision 3034)
@@ -33,6 +33,6 @@
  * </ul>
  */
-public class ConflictCollection implements Iterable<Conflict<?>>{
-    private final List<Conflict<?>> conflicts;
+public class ConflictCollection implements Iterable<Conflict<? extends OsmPrimitive>>{
+    private final List<Conflict<? extends OsmPrimitive>> conflicts;
     private CopyOnWriteArrayList<IConflictListener> listeners;
 
Index: /trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java	(revision 3034)
@@ -13,4 +13,5 @@
 import java.util.logging.Logger;
 
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.conflict.ConflictCollection;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
@@ -160,4 +161,5 @@
      * @param other
      */
+    //TODO This method is probably useless
     protected void fixIncompleteParentWays(Node other) {
         Node myNode = (Node)getMergeTarget(other);
@@ -224,5 +226,6 @@
                     newNodes.add(targetNode);
                     if (targetNode.isDeleted() && !conflicts.hasConflictForMy(targetNode)) {
-                        conflicts.add(targetNode, sourceNode);
+                        conflicts.add(new Conflict<OsmPrimitive>(targetNode, sourceNode, true));
+                        targetNode.setDeleted(false);
                     }
                 } else {
@@ -255,5 +258,6 @@
                 newMembers.add(newMember);
                 if (targetMember.isDeleted() && !conflicts.hasConflictForMy(targetMember)) {
-                    conflicts.add(targetMember, sourceMember.getMember());
+                    conflicts.add(new Conflict<OsmPrimitive>(targetMember, sourceMember.getMember(), true));
+                    targetMember.setDeleted(false);
                 }
             } else {
@@ -319,5 +323,6 @@
             for (OsmPrimitive referrer: source.getReferrers()) {
                 if (targetDataSet.getPrimitiveById(referrer.getPrimitiveId()) == null) {
-                    conflicts.add(target, source);
+                    conflicts.add(new Conflict<OsmPrimitive>(target, source, true));
+                    target.setDeleted(false);
                     break;
                 }
Index: /trunk/src/org/openstreetmap/josm/data/osm/User.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/User.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/data/osm/User.java	(revision 3034)
@@ -27,7 +27,5 @@
 
     private static long getNextLocalUid() {
-        synchronized(User.class) {
-            return uidCounter.decrementAndGet();
-        }
+        return uidCounter.decrementAndGet();
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/ConflictResolver.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/ConflictResolver.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/ConflictResolver.java	(revision 3034)
@@ -19,4 +19,5 @@
 import org.openstreetmap.josm.command.SequenceCommand;
 import org.openstreetmap.josm.command.VersionConflictResolveCommand;
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -77,4 +78,5 @@
     private OsmPrimitive my;
     private OsmPrimitive their;
+    private Conflict<? extends OsmPrimitive> conflict;
 
     private ImageIcon mergeComplete;
@@ -228,8 +230,9 @@
      *
      */
-    public void populate(OsmPrimitive my, OsmPrimitive their) {
-        setMy(my);
-        setTheir(their);
-        propertiesMerger.populate(my, their);
+    public void populate(Conflict<? extends OsmPrimitive> conflict) {
+        setMy(conflict.getMy());
+        setTheir(conflict.getTheir());
+        this.conflict = conflict;
+        propertiesMerger.populate(conflict);
         if (propertiesMerger.getModel().hasVisibleStateConflict()) {
             tabbedPane.setEnabledAt(1, false);
@@ -239,5 +242,5 @@
         }
         tabbedPane.setEnabledAt(0, true);
-        tagMerger.populate(my, their);
+        tagMerger.populate(conflict);
         tabbedPane.setEnabledAt(1, true);
 
@@ -246,5 +249,5 @@
             tabbedPane.setEnabledAt(3,false);
         } else if (my instanceof Way) {
-            nodeListMerger.populate(my, their);
+            nodeListMerger.populate(conflict);
             tabbedPane.setEnabledAt(2, true);
             tabbedPane.setEnabledAt(3, false);
@@ -252,5 +255,5 @@
             tabbedPane.setIconAt(3, null);
         } else if (my instanceof Relation) {
-            relationMemberMerger.populate(my, their);
+            relationMemberMerger.populate(conflict);
             tabbedPane.setEnabledAt(2, false);
             tabbedPane.setTitleAt(2,tr("Nodes"));
@@ -271,14 +274,14 @@
         if (propertiesMerger.getModel().hasVisibleStateConflict()) {
             if (propertiesMerger.getModel().isDecidedVisibleState()) {
-                commands.addAll(propertiesMerger.getModel().buildResolveCommand(my, their));
+                commands.addAll(propertiesMerger.getModel().buildResolveCommand(conflict));
             }
         } else {
             if (tagMerger.getModel().getNumResolvedConflicts() > 0) {
-                commands.add(tagMerger.getModel().buildResolveCommand(my, their));
-            }
-            commands.addAll(propertiesMerger.getModel().buildResolveCommand(my, their));
+                commands.add(tagMerger.getModel().buildResolveCommand(conflict));
+            }
+            commands.addAll(propertiesMerger.getModel().buildResolveCommand(conflict));
             if (my instanceof Way && nodeListMerger.getModel().isFrozen()) {
                 NodeListMergeModel model  =(NodeListMergeModel)nodeListMerger.getModel();
-                commands.add(model.buildResolveCommand((Way)my, (Way)their));
+                commands.add(model.buildResolveCommand(conflict));
             } else if (my instanceof Relation && relationMemberMerger.getModel().isFrozen()) {
                 RelationMemberListMergeModel model  =(RelationMemberListMergeModel)relationMemberMerger.getModel();
@@ -286,6 +289,6 @@
             }
             if (isResolvedCompletely()) {
-                commands.add(new VersionConflictResolveCommand(my, their));
-                commands.add(new ModifiedConflictResolveCommand(my, their));
+                commands.add(new VersionConflictResolveCommand(conflict));
+                commands.add(new ModifiedConflictResolveCommand(conflict));
             }
         }
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/IConflictResolver.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/IConflictResolver.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/IConflictResolver.java	(revision 3034)
@@ -2,4 +2,5 @@
 package org.openstreetmap.josm.gui.conflict.pair;
 
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 
@@ -7,5 +8,5 @@
 
     void deletePrimitive(boolean deleted);
-    void populate(OsmPrimitive my, OsmPrimitive their);
+    void populate(Conflict<? extends OsmPrimitive> conflict);
 
 }
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModel.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModel.java	(revision 3034)
@@ -9,4 +9,5 @@
 
 import org.openstreetmap.josm.command.WayNodesConflictResolverCommand;
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
@@ -61,14 +62,10 @@
      * @param their  their way. Must not be null
      * @return the command
-     * @exception IllegalArgumentException thrown, if my is null or not a {@see Way}
-     * @exception IllegalArgumentException thrown, if their is null or not a {@see Way}
      * @exception IllegalStateException thrown, if the merge is not yet frozen
      */
-    public WayNodesConflictResolverCommand buildResolveCommand(Way my, Way their) {
-        CheckParameterUtil.ensureParameterNotNull(my, "my");
-        CheckParameterUtil.ensureParameterNotNull(their, "their");
+    public WayNodesConflictResolverCommand buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
         if (! isFrozen())
             throw new IllegalArgumentException(tr("Merged nodes not frozen yet. Cannot build resolution command."));
-        return new WayNodesConflictResolverCommand(my, their, getMergedEntries());
+        return new WayNodesConflictResolverCommand(conflict, getMergedEntries());
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java	(revision 3034)
@@ -4,4 +4,5 @@
 import javax.swing.JTable;
 
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -63,6 +64,6 @@
     }
 
-    public void populate(OsmPrimitive my, OsmPrimitive their) {
-        ((NodeListMergeModel)model).populate((Way)my, (Way)their);
+    public void populate(Conflict<? extends OsmPrimitive> conflict) {
+        ((NodeListMergeModel)model).populate((Way)conflict.getMy(), (Way)conflict.getTheir());
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java	(revision 3034)
@@ -21,4 +21,5 @@
 import org.openstreetmap.josm.command.PurgePrimitivesCommand;
 import org.openstreetmap.josm.command.UndeletePrimitivesCommand;
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.DataSet;
@@ -161,6 +162,7 @@
      * @param their their version of the primitive
      */
-    public void populate(OsmPrimitive my, OsmPrimitive their) {
-        this.my = my;
+    public void populate(Conflict<? extends OsmPrimitive> conflict) {
+        this.my = conflict.getMy();
+        OsmPrimitive their = conflict.getTheir();
         if (my instanceof Node) {
             myCoords = ((Node)my).getCoor();
@@ -171,5 +173,5 @@
         }
 
-        myDeletedState = my.isDeleted();
+        myDeletedState =  conflict.isMyDeleted() || my.isDeleted();
         theirDeletedState = their.isDeleted();
 
@@ -418,6 +420,7 @@
      * @return the list of commands
      */
-    public List<Command> buildResolveCommand(OsmPrimitive my, OsmPrimitive their) throws OperationCancelledException{
-        ArrayList<Command> cmds = new ArrayList<Command>();
+    public List<Command> buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) throws OperationCancelledException{
+        OsmPrimitive my = conflict.getMy();
+        List<Command> cmds = new ArrayList<Command>();
         if (hasVisibleStateConflict() && isDecidedVisibleState()) {
             if (isVisibleStateDecision(MergeDecisionType.KEEP_MINE)) {
@@ -436,8 +439,8 @@
         }
         if (hasCoordConflict() && isDecidedCoord()) {
-            cmds.add(new CoordinateConflictResolveCommand((Node)my, (Node)their, coordMergeDecision));
+            cmds.add(new CoordinateConflictResolveCommand(conflict, coordMergeDecision));
         }
         if (hasDeletedStateConflict() && isDecidedDeletedState()) {
-            cmds.add(new DeletedStateConflictResolveCommand(my, their, deletedMergeDecision));
+            cmds.add(new DeletedStateConflictResolveCommand(conflict, deletedMergeDecision));
         }
         return cmds;
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java	(revision 3034)
@@ -22,4 +22,5 @@
 import javax.swing.JPanel;
 
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -718,6 +719,6 @@
     }
 
-    public void populate(OsmPrimitive my, OsmPrimitive their) {
-        model.populate(my, their);
+    public void populate(Conflict<? extends OsmPrimitive> conflict) {
+        model.populate(conflict);
     }
 }
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java	(revision 3034)
@@ -5,4 +5,5 @@
 import javax.swing.JTable;
 
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
@@ -54,7 +55,7 @@
     }
 
-    public void populate(OsmPrimitive my, OsmPrimitive their) {
+    public void populate(Conflict<? extends OsmPrimitive> conflict) {
         RelationMemberListMergeModel model = (RelationMemberListMergeModel)getModel();
-        model.populate((Relation)my, (Relation)their);
+        model.populate((Relation)conflict.getMy(), (Relation)conflict.getTheir());
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeModel.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeModel.java	(revision 3034)
@@ -12,4 +12,5 @@
 
 import org.openstreetmap.josm.command.TagConflictResolveCommand;
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
@@ -189,6 +190,6 @@
     }
 
-    public TagConflictResolveCommand buildResolveCommand(OsmPrimitive my, OsmPrimitive their) {
-        return new TagConflictResolveCommand(my,  their, tagMergeItems);
+    public TagConflictResolveCommand buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
+        return new TagConflictResolveCommand(conflict, tagMergeItems);
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java	(revision 3034)
@@ -26,4 +26,5 @@
 import javax.swing.event.ListSelectionListener;
 
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver;
@@ -421,6 +422,6 @@
     }
 
-    public void populate(OsmPrimitive my, OsmPrimitive their) {
-        model.populate(my, their);
+    public void populate(Conflict<? extends OsmPrimitive> conflict) {
+        model.populate(conflict.getMy(), conflict.getTheir());
         mineTable.getSelectionModel().setSelectionInterval(0, 0);
         theirTable.getSelectionModel().setSelectionInterval(0, 0);
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java	(revision 3033)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java	(revision 3034)
@@ -144,9 +144,7 @@
         }
 
-        Conflict<?> c = conflicts.get(index);
-        OsmPrimitive my = c.getMy();
-        OsmPrimitive their = c.getTheir();
+        Conflict<? extends OsmPrimitive> c = conflicts.get(index);
         ConflictResolutionDialog dialog = new ConflictResolutionDialog(Main.parent);
-        dialog.getConflictResolver().populate(my, their);
+        dialog.getConflictResolver().populate(c);
         dialog.setVisible(true);
 
Index: /trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergerTest.java
===================================================================
--- /trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergerTest.java	(revision 3033)
+++ /trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergerTest.java	(revision 3034)
@@ -6,7 +6,8 @@
 import javax.swing.JFrame;
 
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
-import org.openstreetmap.josm.gui.conflict.pair.nodes.NodeListMerger;
 
 public class NodeListMergerTest extends JFrame {
@@ -35,5 +36,5 @@
         w2.addNode(new Node(6));
 
-        nodeListMerger.populate(w1, w2);
+        nodeListMerger.populate(new Conflict<OsmPrimitive>(w1, w2));
 
     }
@@ -49,5 +50,5 @@
             w2.addNode(new Node(i));
         }
-        nodeListMerger.populate(w1, w2);
+        nodeListMerger.populate(new Conflict<OsmPrimitive>(w1, w2));
 
     }
Index: /trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java
===================================================================
--- /trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java	(revision 3033)
+++ /trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java	(revision 3034)
@@ -7,8 +7,9 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.projection.Epsg4326;
-import org.openstreetmap.josm.gui.conflict.pair.properties.PropertiesMerger;
 
 public class PropertiesMergerTest extends JFrame{
@@ -31,5 +32,5 @@
         their.setCoor(new LatLon(10,10));
 
-        merger.getModel().populate(my, their);
+        merger.getModel().populate(new Conflict<OsmPrimitive>(my, their));
     }
 
Index: /trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMergerTest.java
===================================================================
--- /trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMergerTest.java	(revision 3033)
+++ /trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMergerTest.java	(revision 3034)
@@ -6,9 +6,10 @@
 import javax.swing.JFrame;
 
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationMember;
 import org.openstreetmap.josm.data.osm.Way;
-import org.openstreetmap.josm.gui.conflict.pair.relation.RelationMemberMerger;
 
 public class RelationMemberMergerTest extends JFrame {
@@ -28,5 +29,5 @@
         r2.addMember(new RelationMember("role3", new Relation(3)));
 
-        merger.populate(r1, r2);
+        merger.populate(new Conflict<OsmPrimitive>(r1, r2));
 
     }
Index: /trunk/test/functional/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialogTest.java
===================================================================
--- /trunk/test/functional/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialogTest.java	(revision 3033)
+++ /trunk/test/functional/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialogTest.java	(revision 3034)
@@ -4,5 +4,7 @@
 import javax.swing.JFrame;
 
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
 
@@ -27,5 +29,5 @@
         w2.addNode(new Node(11));
 
-        dialog.getConflictResolver().populate(w1, w2);
+        dialog.getConflictResolver().populate(new Conflict<OsmPrimitive>(w1, w2));
     }
 
Index: /trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java	(revision 3033)
+++ /trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java	(revision 3034)
@@ -815,6 +815,6 @@
      * Their dataset includes a way with three nodes, the first one being my node.
      *
-     * => the merged way should include two nodes only. the deleted node should still be
-     * in the data set.
+     * => the merged way should include all three nodes. Deleted node should have deleted=false and
+     * special conflict with isDeleted should exist
      *
      */
@@ -848,9 +848,5 @@
         theirWay.addNode(tn2);
         theirWay.addNode(tn3);
-        User user = User.getById(1111);
-        if (user == null) {
-            User.createOsmUser(1111, "their");
-        }
-        theirWay.setUser(user);
+        theirWay.setUser(User.createOsmUser(1111, "their"));
         theirWay.setTimestamp(new Date());
         their.addPrimitive(theirWay);
@@ -860,4 +856,5 @@
 
         assertEquals(1, visitor.getConflicts().size());
+        assertTrue(visitor.getConflicts().get(0).isMyDeleted());
 
         Way myWay = (Way)my.getPrimitiveById(4, OsmPrimitiveType.WAY);
@@ -865,9 +862,7 @@
 
         Node n = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE);
-        assertTrue(!myWay.getNodes().contains(n));
-        assertTrue(n != null);
-
-        //a node was removed from the way,it should thus be modified
-        assertTrue(myWay.isModified());
+        assertTrue(myWay.getNodes().contains(n));
+
+        assertFalse(myWay.isModified());
     }
 
@@ -876,6 +871,6 @@
      * Their dataset includes a relation with three nodes, the first one being my node.
      *
-     * => the merged relation should include two nodes only. the deleted node should still be
-     * in the data set
+     * => the merged relation should include all three nodes. There should be conflict for deleted
+     * node with isMyDeleted set
      *
      */
@@ -884,21 +879,21 @@
 
 
-        Node n1 = new Node(new LatLon(0,0));
-        n1.setOsmId(1,1);
-        n1.setDeleted(true);
-        my.addPrimitive(n1);
-
-
-        Node n3 = new Node(new LatLon(0,0));
-        n3.setOsmId(1,1);
-        their.addPrimitive(n3);
-
-        Node n4 = new Node(new LatLon(1,1));
-        n4.setOsmId(2,1);
-        their.addPrimitive(n4);
-
-        Node n5 = new Node(new LatLon(2,2));
-        n5.setOsmId(3,1);
-        their.addPrimitive(n5);
+        Node mn1 = new Node(new LatLon(0,0));
+        mn1.setOsmId(1,1);
+        mn1.setDeleted(true);
+        my.addPrimitive(mn1);
+
+
+        Node tn1 = new Node(new LatLon(0,0));
+        tn1.setOsmId(1,1);
+        their.addPrimitive(tn1);
+
+        Node tn2 = new Node(new LatLon(1,1));
+        tn2.setOsmId(2,1);
+        their.addPrimitive(tn2);
+
+        Node tn3 = new Node(new LatLon(2,2));
+        tn3.setOsmId(3,1);
+        their.addPrimitive(tn3);
 
 
@@ -906,21 +901,23 @@
         theirRelation.setOsmId(4,1);
 
-        theirRelation.addMember(new RelationMember("", n3));
-        theirRelation.addMember(new RelationMember("", n4));
-        theirRelation.addMember(new RelationMember("", n5));
+        theirRelation.addMember(new RelationMember("", tn1));
+        theirRelation.addMember(new RelationMember("", tn2));
+        theirRelation.addMember(new RelationMember("", tn3));
         their.addPrimitive(theirRelation);
 
         DataSetMerger visitor = new DataSetMerger(my,their);
         visitor.merge();
-
-        assertEquals(0,visitor.getConflicts().size());
-
-        Relation r = (Relation)my.getPrimitiveById(4,OsmPrimitiveType.RELATION);
-        assertEquals(2, r.getMembersCount());
 
         Node n = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE);
         assertTrue(n != null);
 
-        assertTrue(r.isModified());
+        assertEquals(1, visitor.getConflicts().size());
+        assertTrue(visitor.getConflicts().hasConflictForMy(n));
+        assertTrue(visitor.getConflicts().get(0).isMyDeleted());
+
+        Relation r = (Relation)my.getPrimitiveById(4,OsmPrimitiveType.RELATION);
+        assertEquals(3, r.getMembersCount());
+
+        assertFalse(r.isModified());
     }
 
Index: /trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java	(revision 3033)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java	(revision 3034)
@@ -12,7 +12,9 @@
 import org.junit.Test;
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.Way;
@@ -47,4 +49,8 @@
     }
 
+    private void populate(OsmPrimitive my, OsmPrimitive their) {
+        model.populate(new Conflict<OsmPrimitive>(my, their));
+    }
+
     @Test
     public void populate() {
@@ -55,5 +61,5 @@
         d1.addPrimitive(n1);
         d2.addPrimitive(n2);
-        model.populate(n1, n2);
+        populate(n1, n2);
 
         Way w1 = new Way(1);
@@ -61,5 +67,5 @@
         d1.addPrimitive(w1);
         d2.addPrimitive(w2);
-        model.populate(w2, w2);
+        populate(w2, w2);
 
         Relation r1 = new Relation(1);
@@ -67,5 +73,5 @@
         d1.addPrimitive(r1);
         d2.addPrimitive(r2);
-        model.populate(r1, r2);
+        populate(r1, r2);
     }
 
@@ -79,9 +85,9 @@
         d1.addPrimitive(n1);
         d2.addPrimitive(n2);
-        model.populate(n1, n2);
+        populate(n1, n2);
         assertFalse(model.hasCoordConflict());
 
         n1.setCoor(new LatLon(1,1));
-        model.populate(n1, n2);
+        populate(n1, n2);
         assertTrue(model.hasCoordConflict());
 
@@ -89,10 +95,10 @@
         n1.cloneFrom(new Node(1));
         n2.setCoor(new LatLon(2,2));
-        model.populate(n1, n2);
+        populate(n1, n2);
         assertTrue(model.hasCoordConflict());
 
         n1.setCoor(new LatLon(1,1));
         n2.setCoor(new LatLon(2,2));
-        model.populate(n1, n2);
+        populate(n1, n2);
         assertTrue(model.hasCoordConflict());
 
