From 5553126490179292488995883745344364507378 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 18 Feb 2025 16:16:23 -0500 Subject: Add BinaryView.forget_undo_actions Closes Vector35/binaryninja-api#6430 --- python/binaryview.py | 25 +++++++++++++++++++++++++ python/filemetadata.py | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/binaryview.py b/python/binaryview.py index f9f955fe..96bac051 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -4306,6 +4306,31 @@ class BinaryView: """ self._file.commit_undo_actions(id) + def forget_undo_actions(self, id: Optional[str] = None) -> None: + """ + ``forget_undo_actions`` removes the actions taken since a call to :py:func:`begin_undo_actions` + Pass as `id` the value returned by :py:func:`begin_undo_actions`. Empty values of + `id` will remove all changes since the last call to :py:func:`begin_undo_actions`. + + :param Optional[str] id: id of undo state, from :py:func:`begin_undo_actions` + :rtype: None + :Example: + + >>> bv.get_disassembly(0x100012f1) + 'xor eax, eax' + >>> state = bv.begin_undo_actions() + >>> bv.convert_to_nop(0x100012f1) + True + >>> bv.forget_undo_actions(state) + >>> bv.get_disassembly(0x100012f1) + 'nop' + >>> bv.undo() + >>> bv.get_disassembly(0x100012f1) + 'nop' + >>> + """ + self._file.forget_undo_actions(id) + def revert_undo_actions(self, id: Optional[str] = None) -> None: """ ``revert_undo_actions`` reverts the actions taken since a call to :py:func:`begin_undo_actions` diff --git a/python/filemetadata.py b/python/filemetadata.py index a840bd78..e3357441 100644 --- a/python/filemetadata.py +++ b/python/filemetadata.py @@ -429,7 +429,7 @@ class FileMetadata: >>> state = bv.begin_undo_actions() >>> bv.convert_to_nop(0x100012f1) True - >>> bv.commit_undo_actions(state) + >>> bv.forget_undo_actions(state) >>> bv.get_disassembly(0x100012f1) 'nop' >>> bv.undo() -- cgit v1.3.1