Skip to content

Commit

Permalink
Fix #23846: Setting all referrers downloaded doesn't happen if the ta…
Browse files Browse the repository at this point in the history
…rget object has been modified

This ''may'' also fix (or partially fix) #23808 and #23810.

git-svn-id: https://josm.openstreetmap.de/svn/trunk@19175 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
taylor.smock committed Aug 8, 2024
1 parent 2f2830b commit faad75b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/org/openstreetmap/josm/data/osm/DataSetMerger.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ private boolean mergeById(OsmPrimitive source) {
if (target.hasEqualSemanticAttributes(source, false)) {
target.setModified(false);
}
target.setReferrersDownloaded(target.isReferrersDownloaded() || source.isReferrersDownloaded());
} else if (source.isDeleted() != target.isDeleted()) {
// target is modified and deleted state differs.
// this has to be resolved manually.
Expand Down
29 changes: 29 additions & 0 deletions test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
import java.io.StringWriter;
import java.time.Instant;
import java.util.Arrays;
import java.util.function.BiConsumer;
import java.util.stream.Stream;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.projection.ProjectionRegistry;
import org.openstreetmap.josm.data.projection.Projections;
Expand Down Expand Up @@ -1356,4 +1360,29 @@ void testTicket20091() {
assertEquals(w1b, visitor.getConflicts().iterator().next().getMy());
}

static Stream<BiConsumer<Node, Node>> testNonRegression23846() {
return Stream.of(
(firstNode, secondNode) -> firstNode.setModified(true),
(firstNode, secondNode) -> { /* No modifications */ }
);
}

@ParameterizedTest
@MethodSource
void testNonRegression23846(BiConsumer<Node, Node> nodeSetup) {
final Node firstNode = new Node(1234, 1);
final Node secondNode = new Node(1234, 1);
final DataSetMerger merge = new DataSetMerger(my, their);
firstNode.setCoor(LatLon.ZERO);
secondNode.setCoor(LatLon.ZERO);
nodeSetup.accept(firstNode, secondNode);
my.addPrimitive(firstNode);
their.addPrimitive(secondNode);
secondNode.setReferrersDownloaded(true);
assertFalse(firstNode.isReferrersDownloaded());
assertTrue(secondNode.isReferrersDownloaded());
merge.merge();
assertTrue(firstNode.isReferrersDownloaded());
assertTrue(secondNode.isReferrersDownloaded());
}
}

0 comments on commit faad75b

Please sign in to comment.