Ignore:
Timestamp:
2020-03-27T15:56:08+01:00 (5 years ago)
Author:
gerdp
Message:

fix #1josm5906: Isn't properly reverting multiple changesets

  • execute commands for each reverted changeset
  • change RevertChangesetCommand so that it just collects already executed commands (see #josm17401)
Location:
applications/editors/josm/plugins/reverter/src/reverter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetCommand.java

    r34953 r35400  
    1919     * Create the command by specifying the list of commands to execute.
    2020     * @param name The description text
    21      * @param sequenz The sequence that should be executed.
     21     * @param sequenz The sequence that was already executed.
    2222     */
    2323    public RevertChangesetCommand(String name, Collection<Command> sequenz) {
    2424        super(name, sequenz);
    2525        ReverterPlugin.reverterUsed = true;
     26        setSequenceComplete(true);
    2627    }
    2728
     
    3637    }
    3738
     39    @Override
     40    public void undoCommand() {
     41        getAffectedDataSet().update(super::undoCommand);
     42    }
     43
     44    @Override
     45    public boolean executeCommand() {
     46        return getAffectedDataSet().update(super::executeCommand);
     47    }
     48
    3849}
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetTask.java

    r35310 r35400  
    1515
    1616import org.openstreetmap.josm.command.Command;
    17 import org.openstreetmap.josm.command.SequenceCommand;
    1817import org.openstreetmap.josm.command.conflict.ConflictAddCommand;
    1918import org.openstreetmap.josm.data.UndoRedoHandler;
     
    9998                newLayer = false; // reuse layer for subsequent reverts
    10099            } catch (OsmTransferException e) {
    101                 Logging.error(e);
     100                                if (!allcmds.isEmpty()) {
     101                                        GuiHelper.runInEDT(() -> UndoRedoHandler.getInstance().undo(allcmds.size()));
     102                                }
     103                                Logging.error(e);
    102104                throw e;
    103105            } catch (UserCancelException e) {
     106                                if (!allcmds.isEmpty()) {
     107                                        GuiHelper.runInEDT(() -> UndoRedoHandler.getInstance().undo(allcmds.size()));
     108                                }
    104109                Logging.warn("Revert canceled");
    105110                Logging.trace(e);
     
    108113        }
    109114        if (!allcmds.isEmpty()) {
    110             Command cmd = allcmds.size() == 1 ? allcmds.get(0) : new SequenceCommand(tr("Revert changesets"), allcmds);
     115            Command cmd = allcmds.size() == 1 ? allcmds.get(0) : new RevertChangesetCommand(tr("Revert changesets"), allcmds);
    111116            GuiHelper.runInEDT(() -> {
    112                 UndoRedoHandler.getInstance().add(cmd);
     117                UndoRedoHandler.getInstance().add(cmd, false);
    113118                if (numberOfConflicts > 0) {
    114119                    MainApplication.getMap().conflictDialog.warnNumNewConflicts(numberOfConflicts);
     
    169174                numberOfConflicts++;
    170175            }
     176            c.executeCommand();
    171177        }
    172178        final String desc;
Note: See TracChangeset for help on using the changeset viewer.