Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java	(revision 1559)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java	(revision 1560)
@@ -58,5 +58,5 @@
             HashMap<Long, P> primhash) {
         // 1. Try to find an identical prim with the same id.
-        if (mergeAfterId(myprims, primhash, other))
+        if (mergeById(myprims, primhash, other))
             return;
 
@@ -200,4 +200,5 @@
                 my.id = other.id;
                 my.modified = other.modified; // match a new node
+                my.version = other.version;
             } else if (my.id != 0 && other.id != 0 && other.modified)
                 my.modified = true;
@@ -218,5 +219,5 @@
      * @return <code>true</code>, if no merge is needed or merge is performed already.
      */
-    private <P extends OsmPrimitive> boolean mergeAfterId(
+    private <P extends OsmPrimitive> boolean mergeById(
             Collection<P> primitives, HashMap<Long, P> hash, P other) {
         // Fast-path merging of identical objects
@@ -235,10 +236,8 @@
             }
             if (my.realEqual(other, true)) {
-                Date myd = my.getTimestamp();
-                Date otherd = other.getTimestamp();
-
-                // they differ in modified/timestamp combination only. Auto-resolve it.
-                merged.put(other, my);
-                if (myd.before(otherd)) {
+                // they differ in modified/version combination only. Auto-resolve it.
+                merged.put(other, my);
+                if (my.version < other.version) {
+                    my.version = other.version;
                     my.modified = other.modified;
                     my.setTimestamp(other.getTimestamp());
@@ -247,7 +246,4 @@
             }
             if (my.id == other.id && my.id != 0) {
-                Date myd = my.getTimestamp();
-                Date otherd = other.getTimestamp();
-
                 if (my.incomplete || other.incomplete) {
                     if (my.incomplete) {
@@ -257,9 +253,9 @@
                     conflicts.put(my, other);
                 } else if (!my.modified && !other.modified) {
-                    if (myd.before(otherd)) {
+                    if (my.version < other.version) {
                         my.cloneFrom(other);
                     }
                 } else if (other.modified) {
-                    if (myd.after(otherd)) {
+                    if (my.version > other.version) {
                         conflicts.put(my, other);
                     } else {
@@ -267,5 +263,5 @@
                     }
                 } else if (my.modified) {
-                    if (myd.before(otherd)) {
+                    if (my.version < other.version) {
                         conflicts.put(my, other);
                     }
