Add to undo log.
774749
<S extends Storable> void inserted(final MapStorage<S> storage, final S key) {
        addToUndoLog(new Undoable() {
            public void undo() {
                storage.mapRemove(key);
            }

            @Override
            public String toString() {
                return "undo insert by remove: " + key;
            }
        });
    }
8866
def add_log_entry(self, entry):
        
        event_log = self.job_record.event_log
        if len(event_log) > job.MAX_NUMBER_OF_EVENTS:
            del event_log[-1]
        event_log.insert(0, entry)
764880
private void addBackup() {
        // move the current log file to the newly formatted backup name
        String newname = this.fileinfo + this.myFormat.format(new Date(HttpDispatcher.getApproxTime())) + this.extensioninfo;
        File newFile = new File(newname);
        renameFile(this.myFile, newFile);
        // now see if we need to delete an existing backup to make room
        if (this.backups.size() == getMaximumBackupFiles()) {
            File oldest = this.backups.removeLast();
            if (null != oldest && oldest.exists()) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, getFileName() + ": Purging oldest backup-> " + oldest.getName());
                }
                oldest.delete();
            }
        }
        this.backups.addFirst(newFile);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, getFileName() + ": number of backup files-> " + this.backups.size());
        }
    }
681972
def workspace_backup_undo(ctx):
    
    backup_manager = WorkspaceBackupManager(Workspace(ctx.resolver, directory=ctx.directory, mets_basename=ctx.mets_basename, automatic_backup=ctx.automatic_backup))
    backup_manager.undo()
127880
def trigger_deleted(self, filepath):
        """"""
        if not os.path.exists(filepath):
            self._trigger('deleted', filepath)
925399
def undo(self, editor):
        """"""
        inst = self.timemachine
        if not self.is_revertible:
            raise DisciplineException("You tried to undo a non-revertible action! "
                               "Check action.is_revertible and action.undo_errors"
                               " before trying to undo.")

        if self.action_type == "dl":
            obj = inst.restore()
            self.reverted = save_object(obj, editor)
            self.save()
        elif self.action_type == "md":
            # Restore as it was *before* the modification
            obj = inst.at_previous_action.restore()
            self.reverted = save_object(obj, editor)
            self.save()
        else:
            editor.delete_object(inst.get_object())
            # This is safe from race conditions but still a pretty inelegant
            # solution. I can't figure out a different way to find the last action
            # for now
            self.reverted = DeletionCommit.objects.filter(
                object_uid = self.object_uid
            ).order_by("-action__id")[0].action
            self.save()
198549
function addonsManager_undo(aSpec) {
    var spec = aSpec || { };
    spec.link = "undo";

    var link = this.getAddonLink(spec);
    this._controller.click(link);
  }
1063917
def OnUpdate(self, event):
        """"""

        # Gray out undo and redo id not available

        undo_toolid = self.label2id["Undo"]
        redo_toolid = self.label2id["Redo"]

        self.EnableTool(undo_toolid, undo.stack().canundo())
        self.EnableTool(redo_toolid, undo.stack().canredo())

        # Set ToolTip strings to potential next undo / redo action
        undotext = undo.stack().undotext()
        undo_tool = self.FindTool(undo_toolid)
        if undotext is None:
            undo_tool.SetShortHelp(_("No undo actions available"))
        else:
            undo_tool.SetShortHelp(undotext)

        redotext = undo.stack().redotext()
        redo_tool = self.FindTool(redo_toolid)
        if redotext is None:
            redo_tool.SetShortHelp(_("No redo actions available"))
        else:
            redo_tool.SetShortHelp(redotext)

        self.Refresh()

        event.Skip()
385800
function UndoManager(callback, panels) {

        var undoObj = this;
        var undoStack = []; // A stack of undo states
        var stackPtr = 0; // The index of the current state
        var mode = "none";
        var lastState; // The last state
        var timer; // The setTimeout handle for cancelling the timer
        var inputStateObj;

        // Set the mode for later logic steps.
        var setMode = function (newMode, noSave) {
            if (mode != newMode) {
                mode = newMode;
                if (!noSave) {
                    saveState();
                }
            }

            if (!uaSniffed.isIE || mode != "moving") {
                timer = setTimeout(refreshState, 1);
            }
            else {
                inputStateObj = null;
            }
        };

        var refreshState = function (isInitialState) {
            inputStateObj = new TextareaState(panels, isInitialState);
            timer = undefined;
        };

        this.setCommandMode = function () {
            mode = "command";
            saveState();
            timer = setTimeout(refreshState, 0);
        };

        this.canUndo = function () {
            return stackPtr > 1;
        };

        this.canRedo = function () {
            if (undoStack[stackPtr + 1]) {
                return true;
            }
            return false;
        };

        // Removes the last state and restores it.
        this.undo = function () {

            if (undoObj.canUndo()) {
                if (lastState) {
                    // What about setting state -1 to null or checking for undefined?
                    lastState.restore();
                    lastState = null;
                }
                else {
                    undoStack[stackPtr] = new TextareaState(panels);
                    undoStack[--stackPtr].restore();

                    if (callback) {
                        callback();
                    }
                }
            }

            mode = "none";
            panels.input.focus();
            refreshState();
        };

        // Redo an action.
        this.redo = function () {

            if (undoObj.canRedo()) {

                undoStack[++stackPtr].restore();

                if (callback) {
                    callback();
                }
            }

            mode = "none";
            panels.input.focus();
            refreshState();
        };

        // Push the input area state to the stack.
        var saveState = function () {
            var currState = inputStateObj || new TextareaState(panels);

            if (!currState) {
                return false;
            }
            if (mode == "moving") {
                if (!lastState) {
                    lastState = currState;
                }
                return;
            }
            if (lastState) {
                if (undoStack[stackPtr - 1].text != lastState.text) {
                    undoStack[stackPtr++] = lastState;
                }
                lastState = null;
            }
            undoStack[stackPtr++] = currState;
            undoStack[stackPtr + 1] = null;
            if (callback) {
                callback();
            }
        };

        var handleCtrlYZ = function (event) {

            var handled = false;

            if (event.ctrlKey || event.metaKey) {

                // IE and Opera do not support charCode.
                var keyCode = event.charCode || event.keyCode;
                var keyCodeChar = String.fromCharCode(keyCode);

                switch (keyCodeChar) {

                    case "y":
                        undoObj.redo();
                        handled = true;
                        break;

                    case "z":
                        if (!event.shiftKey) {
                            undoObj.undo();
                        }
                        else {
                            undoObj.redo();
                        }
                        handled = true;
                        break;
                }
            }

            if (handled) {
                if (event.preventDefault) {
                    event.preventDefault();
                }
                if (window.event) {
                    window.event.returnValue = false;
                }
                return;
            }
        };

        // Set the mode depending on what is going on in the input area.
        var handleModeChange = function (event) {

            if (!event.ctrlKey && !event.metaKey) {

                var keyCode = event.keyCode;

                if ((keyCode >= 33 && keyCode <= 40) || (keyCode >= 63232 && keyCode <= 63235)) {
                    // 33 - 40: page up/dn and arrow keys
                    // 63232 - 63235: page up/dn and arrow keys on safari
                    setMode("moving");
                }
                else if (keyCode == 8 || keyCode == 46 || keyCode == 127) {
                    // 8: backspace
                    // 46: delete
                    // 127: delete
                    setMode("deleting");
                }
                else if (keyCode == 13) {
                    // 13: Enter
                    setMode("newlines");
                }
                else if (keyCode == 27) {
                    // 27: escape
                    setMode("escape");
                }
                else if ((keyCode < 16 || keyCode > 20) && keyCode != 91) {
                    // 16-20 are shift, etc. 
                    // 91: left window key
                    // I think this might be a little messed up since there are
                    // a lot of nonprinting keys above 20.
                    setMode("typing");
                }
            }
        };

        var setEventHandlers = function () {
            util.addEvent(panels.input, "keypress", function (event) {
                // keyCode 89: y
                // keyCode 90: z
                if ((event.ctrlKey || event.metaKey) && (event.keyCode == 89 || event.keyCode == 90)) {
                    event.preventDefault();
                }
            });

            var handlePaste = function () {
                if (uaSniffed.isIE || (inputStateObj && inputStateObj.text != panels.input.value)) {
                    if (timer == undefined) {
                        mode = "paste";
                        saveState();
                        refreshState();
                    }
                }
            };

            util.addEvent(panels.input, "keydown", handleCtrlYZ);
            util.addEvent(panels.input, "keydown", handleModeChange);
            util.addEvent(panels.input, "mousedown", function () {
                setMode("moving");
            });

            panels.input.onpaste = handlePaste;
            panels.input.ondrop = handlePaste;
        };

        var init = function () {
            setEventHandlers();
            refreshState(true);
            saveState();
        };

        init();
    }
347403
def results(context, history_log):
    """"""
    if context.obj is None:
        context.obj = {}
    context.obj['history_log'] = history_log

    if context.invoked_subcommand is None:
        context.invoke(show, item=1)
1356685
public void registerUndoRedo(Button undo, Button redo) {

        if (getState().m_enableUndoRedo) {
            throw new RuntimeException("Undo/redo already registered.");
        }
        undo.setId(HTML_ID_PREFIX + m_componentId + "-undo");
        redo.setId(HTML_ID_PREFIX + m_componentId + "-redo");
        getState().m_enableUndoRedo = true;
        markAsDirty();
    }
912042
def OnUndo(self, event):
        """"""

        statustext = undo.stack().undotext()
        undo.stack().undo()

        # Update content changed state
        try:
            post_command_event(self.grid.main_window,
                               self.grid.ContentChangedMsg)
        except TypeError:
            # The main window does not exist any more
            pass

        self.grid.code_array.result_cache.clear()

        post_command_event(self.grid.main_window, self.grid.TableChangedMsg,
                           updated_cell=True)

        # Reset row heights and column widths by zooming
        self.grid.actions.zoom()

        # Change grid table dimensions
        self.grid.GetTable().ResetView()

        # Update TableChoiceIntCtrl
        shape = self.grid.code_array.shape
        post_command_event(self.main_window, self.grid.ResizeGridMsg,
                           shape=shape)

        # Update toolbars
        self.grid.update_entry_line()
        self.grid.update_attribute_toolbar()

        post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
                           text=statustext)
361086
protected void undo() {

        try {
            boolean recursive = Boolean.parseBoolean(m_modifySubresourcesField.getValue().toString());
            boolean undoMove = m_undoMoveField.getValue().booleanValue();
            CmsObject cms = m_context.getCms();
            Set<CmsUUID> updateResources = new HashSet<CmsUUID>();
            for (CmsResource resource : m_context.getResources()) {
                updateResources.add(resource.getStructureId());
                if (undoMove) {
                    // in case a move is undone, add the former parent folder
                    updateResources.add(cms.readParentFolder(resource.getStructureId()).getStructureId());
                }
                CmsLockActionRecord actionRecord = null;
                try {
                    actionRecord = CmsLockUtil.ensureLock(m_context.getCms(), resource);
                    CmsResourceUndoMode mode = CmsResourceUndoMode.getUndoMode(undoMove, recursive);
                    cms.undoChanges(cms.getSitePath(resource), mode);
                    if (undoMove) {
                        // in case a move is undone, also add the new parent folder
                        updateResources.add(cms.readParentFolder(resource.getStructureId()).getStructureId());
                    }
                } finally {
                    if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) {
                        try {
                            m_context.getCms().unlockResource(cms.readResource(resource.getStructureId()));
                        } catch (CmsLockException e) {
                            LOG.warn(e.getLocalizedMessage(), e);
                        }
                    }

                }

            }
            m_context.finish(updateResources);
        } catch (Exception e) {
            m_context.error(e);
        }

    }
652166
void undoAdd(Link newLink)
                    throws ObjectManagerException {
        final String methodName = "undoAdd";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass, methodName, new Object[] { newLink });

        // Detach this Link from the list.
        if (newLink.next == null) { // Are we the tail of list?
            tail = newLink.previous;
        } else { // Not tail of the list.
            // Join up the backwards Link.
            Link nextLink = (Link) newLink.next.getManagedObject();
            nextLink.previous = newLink.previous;
        } // if at tail of list.

        if (newLink.previous == null) { // Are we the head of list?
            head = newLink.next;
        } else { // Not head of the list.
            // Join up the forwards Link.
            Link previousLink = (Link) newLink.previous.getManagedObject();
            previousLink.next = newLink.next;
        } // if at head of list.

        // Reset the availableHead.
        availableHead = head;
        skipToBeDeleted();
        decrementSize(); // Adjust list length. 

        // Give back all of the remaining space.
        owningToken.objectStore.reserve((int) -reservedSpaceInStore, false);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass, methodName);
    }
196725
def undo(scm, verbose, fake, hard):
    """"""
    scm.fake = fake
    scm.verbose = fake or verbose

    scm.repo_check()

    status_log(scm.undo, 'Last commit removed from history.', hard)
382298
def append(self, action):
        '''  '''
        if self._receiver is not None:
            self._receiver.append(action)
        if self._receiver is self._undos:
            self._redos.clear()
            self.docallback()
934519
def undo_action_name(self):
        
        if self._open:
            return self._open[-1].name
        elif self._undo:
            return self._undo[-1].name
        return ""