Changeset 34958 in osm for applications/editors/josm
- Timestamp:
- 2019-04-02T07:57:58+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/reverter
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reverter/build.xml
r34552 r34958 4 4 <property name="commit.message" value="Reverter: Update MultiOsmReader to support null data after redaction"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="14 153"/>6 <property name="plugin.main.version" value="14946"/> 7 7 8 8 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java
r34953 r34958 10 10 import java.util.Collection; 11 11 import java.util.Collections; 12 import java.util.HashMap; 12 13 import java.util.HashSet; 13 14 import java.util.Iterator; … … 20 21 import org.openstreetmap.josm.data.coor.LatLon; 21 22 import org.openstreetmap.josm.data.osm.Changeset; 23 import org.openstreetmap.josm.data.osm.ChangesetDataSet; 24 import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetDataSetEntry; 25 import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType; 22 26 import org.openstreetmap.josm.data.osm.DataSet; 23 27 import org.openstreetmap.josm.data.osm.Node; … … 39 43 import org.openstreetmap.josm.io.MultiFetchServerObjectReader; 40 44 import org.openstreetmap.josm.io.OsmApiException; 45 import org.openstreetmap.josm.io.OsmServerChangesetReader; 41 46 import org.openstreetmap.josm.io.OsmTransferException; 42 47 import org.openstreetmap.josm.tools.Logging; 43 48 import org.openstreetmap.josm.tools.Utils; 44 45 import reverter.corehacks.ChangesetDataSet;46 import reverter.corehacks.ChangesetDataSet.ChangesetDataSetEntry;47 import reverter.corehacks.ChangesetDataSet.ChangesetModificationType;48 import reverter.corehacks.OsmServerChangesetReader;49 49 50 50 /** … … 80 80 private final HashSet<HistoryOsmPrimitive> updated = new HashSet<>(); 81 81 private final HashSet<HistoryOsmPrimitive> deleted = new HashSet<>(); 82 private final HashMap<PrimitiveId, Integer> earliestVersions = new HashMap<>(); 82 83 83 84 //// Handling missing objects … … 142 143 this.revertType = revertType; 143 144 144 OsmServerChangesetReader csr = new OsmServerChangesetReader( );145 OsmServerChangesetReader csr = new OsmServerChangesetReader(true); 145 146 monitor.beginTask("", 2); 146 changeset = csr.readChangeset(changesetId, monitor.createSubTaskMonitor(1, false));147 changeset = csr.readChangeset(changesetId, false, monitor.createSubTaskMonitor(1, false)); 147 148 if (MODERATOR_REDACTION_ACCOUNTS.contains(changeset.getUser().getId())) { 148 149 throw new RevertRedactedChangesetException(tr("It is not allowed to revert changeset from {0}", changeset.getUser().getName())); … … 158 159 159 160 // Build our own lists of created/updated/modified objects for better performance 160 for ( Iterator<ChangesetDataSetEntry> it = cds.iterator(); it.hasNext();) {161 ChangesetDataSetEntry entry = it.next();162 if (!checkOsmChangeEntry(entry)) continue;163 if (entry.getModificationType() == ChangesetModificationType.CREATED) {164 created.add(entry.getPrimitive());165 } else if (entry.getModificationType() == ChangesetModificationType.UPDATED) {166 updated.add(entry.getPrimitive());167 } else if (entry.getModificationType() == ChangesetModificationType.DELETED) {168 deleted.add(entry.getPrimitive());169 } else throw new AssertionError();161 for (PrimitiveId id : cds.getIds()) { 162 ChangesetDataSetEntry first = cds.getFirstEntry(id); 163 ChangesetDataSetEntry last = cds.getLastEntry(id); 164 earliestVersions.put(id, (int) first.getPrimitive().getVersion()); 165 if (first.getModificationType() == ChangesetModificationType.CREATED) 166 created.add(first.getPrimitive()); 167 else if (last.getModificationType() == ChangesetModificationType.UPDATED) 168 updated.add(last.getPrimitive()); 169 else if (last.getModificationType() == ChangesetModificationType.DELETED) 170 deleted.add(last.getPrimitive()); 170 171 } 171 172 } … … 220 221 for (HistoryOsmPrimitive entry : collection) { 221 222 PrimitiveId id = entry.getPrimitiveId(); 222 readObjectVersion(rdr, id, cds.getEarliestVersion(id)-1, progressMonitor); 223 Integer earliestVersion = earliestVersions.get(id); 224 if (earliestVersion == null || earliestVersion <= 1) 225 throw new OsmTransferException(tr("Unexpected data in changeset #{1}" , String.valueOf(changesetId))); 226 readObjectVersion(rdr, id, earliestVersion - 1, progressMonitor); 223 227 if (progressMonitor.isCanceled()) return; 224 228 }
Note:
See TracChangeset
for help on using the changeset viewer.