Changeset 14922 in josm


Ignore:
Timestamp:
2019-03-24T14:58:24+01:00 (3 months ago)
Author:
Don-vip
Message:

fix #7481 - add missing conflict when merging a primitive modified and deleted in two data sets

Location:
trunk
Files:
2 edited

Legend:

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

    r13497 r14922  
    318318            //
    319319        } else if (!target.isModified() && !source.isModified() && target.isVisible() != source.isVisible()
    320                 && target.getVersion() == source.getVersion())
     320                && target.getVersion() == source.getVersion()) {
    321321            // Same version, but different "visible" attribute and neither of them are modified.
    322322            // It indicates a serious problem in datasets.
     
    325325            throw new DataIntegrityProblemException(tr("Conflict in ''visible'' attribute for object of type {0} with id {1}",
    326326                    target.getType(), target.getId()));
    327         else if (target.isDeleted() && !source.isDeleted() && target.getVersion() == source.getVersion()) {
     327        } else if (target.isDeleted() && !source.isDeleted() && target.getVersion() == source.getVersion()) {
    328328            // same version, but target is deleted. Assume target takes precedence
    329329            // otherwise too many conflicts when refreshing from the server
    330             // but, if source has a referrer that is not in the target dataset there is a conflict
     330            // but, if source is modified, there is a conflict
     331            if (source.isModified()) {
     332                addConflict(new Conflict<>(target, source, true));
     333            }
     334            // or, if source has a referrer that is not in the target dataset there is a conflict
    331335            // If target dataset refers to the deleted primitive, conflict will be added in fixReferences method
    332336            for (OsmPrimitive referrer: source.getReferrers()) {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r14120 r14922  
    2323import org.openstreetmap.josm.data.projection.Projections;
    2424import org.openstreetmap.josm.testutils.JOSMTestRules;
     25import org.openstreetmap.josm.tools.date.DateUtils;
    2526
    2627import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    342343        n1.setOsmId(1, 1);
    343344        n1.put("key1", "value1");
    344         Date timestamp = new Date();
    345         n1.setTimestamp(timestamp);
     345        n1.setTimestamp(new Date());
    346346        their.addPrimitive(n1);
    347347
     
    974974    }
    975975
     976    private void doTestTicket7481(DataSet source, DataSet target) {
     977        // Local node A
     978        Node nA = new Node(2848219691L, 1);
     979        nA.setCoor(LatLon.ZERO);
     980        nA.setTimestamp(DateUtils.fromString("2014-05-10T14:25:40Z"));
     981        nA.setChangesetId(22251108);
     982        nA.setUser(User.createOsmUser(385987, "yaho"));
     983        nA.put("name", "Mionga");
     984        nA.put("tourism", "hotel");
     985
     986        // Local node B, duplicated
     987        Node nB = new Node(nA);
     988
     989        // Move and delete node A
     990        nA.setCoor(new LatLon(0.1321894855, 6.64627402075));
     991        nA.setDeleted(true);
     992        my.addPrimitive(nA);
     993
     994        // Move and modify node B
     995        nB.setCoor(new LatLon(0.1322066, 6.6462202));
     996        nB.put("phone", "999");
     997        nB.setModified(true);
     998        their.addPrimitive(nB);
     999
     1000        // Merge
     1001        DataSetMerger visitor = new DataSetMerger(source, target);
     1002        visitor.merge();
     1003
     1004        assertEquals(1, visitor.getConflicts().size());
     1005    }
     1006
     1007    /**
     1008     * Non-regression test 1 for <a href="https://josm.openstreetmap.de/ticket/7481">Bug #7481</a>.
     1009     */
     1010    @Test
     1011    public void testTicket07481ab() {
     1012        doTestTicket7481(my, their);
     1013    }
     1014
     1015    /**
     1016     * Non-regression test 2 for <a href="https://josm.openstreetmap.de/ticket/7481">Bug #7481</a>.
     1017     */
     1018    @Test
     1019    public void testTicket07481ba() {
     1020        doTestTicket7481(their, my);
     1021    }
     1022
    9761023    /**
    9771024     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/12599">Bug #12599</a>.
     
    10141061    }
    10151062
    1016 
    10171063    /**
    10181064     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/12616">Bug #12616</a>.
Note: See TracChangeset for help on using the changeset viewer.