Changeset 9961 in josm


Ignore:
Timestamp:
2016-03-11T14:13:23+01:00 (4 years ago)
Author:
simon04
Message:

fix #12599 - Added/deleted "uninteresting" tags are "reverted" by downloading area again (unit test by Don-vip)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java

    r8870 r9961  
    357357            // target is same as source but target is modified
    358358            // => keep target and reset modified flag if target and source are semantically equal
    359             if (target.hasEqualSemanticAttributes(source)) {
     359            if (target.hasEqualSemanticAttributes(source, false)) {
    360360                target.setModified(false);
    361361            }
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r9941 r9961  
    12381238     */
    12391239    public boolean hasEqualSemanticAttributes(OsmPrimitive other) {
     1240        return hasEqualSemanticAttributes(other, true);
     1241    }
     1242
     1243    boolean hasEqualSemanticAttributes(final OsmPrimitive other, final boolean testInterestingTagsOnly) {
    12401244        if (!isNew() &&  id != other.id)
    12411245            return false;
    12421246        if (isIncomplete() ^ other.isIncomplete()) // exclusive or operator for performance (see #7159)
    12431247            return false;
    1244         // can't do an equals check on the internal keys array because it is not ordered
    1245         //
    1246         return hasSameInterestingTags(other);
     1248        return testInterestingTagsOnly ? hasSameInterestingTags(other) : getKeys().equals(other.getKeys());
    12471249    }
    12481250
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r9214 r9961  
    993993        assertEquals(2, w.getNode(1).getId());
    994994    }
     995
     996    /**
     997     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/12599">Bug #12599</a>.
     998     */
     999    @Test
     1000    public void testTicket12599() {
     1001        // Server node: no modifications
     1002        Node n1 = new Node(1, 1);
     1003        n1.setCoor(LatLon.ZERO);
     1004        assertFalse(n1.isModified());
     1005        their.addPrimitive(n1);
     1006
     1007        // Local node: one modification: addition of an uninteresting tag
     1008        Node n1b = new Node(n1);
     1009        n1b.setModified(true);
     1010        n1b.put("note", "something");
     1011        assertTrue(n1b.isModified());
     1012        assertEquals(0, n1b.getInterestingTags().size());
     1013        my.addPrimitive(n1b);
     1014
     1015        // Merge
     1016        DataSetMerger visitor = new DataSetMerger(my, their);
     1017        visitor.merge();
     1018
     1019        // Check that modification is still here
     1020        Node n = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE);
     1021        assertNotNull(n);
     1022        assertEquals("something", n.get("note"));
     1023        assertTrue(n.isModified());
     1024
     1025        // Merge again
     1026        visitor = new DataSetMerger(my, their);
     1027        visitor.merge();
     1028
     1029        // Check that modification is still here
     1030        n = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE);
     1031        assertNotNull(n);
     1032        assertEquals("something", n.get("note"));
     1033        assertTrue(n.isModified());
     1034    }
     1035
    9951036}
Note: See TracChangeset for help on using the changeset viewer.