Skip to content

Commit 5553126

Browse files
committed
Add BinaryView.forget_undo_actions
Closes #6430
1 parent 9d6ca8c commit 5553126

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

python/binaryview.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4306,6 +4306,31 @@ def commit_undo_actions(self, id: Optional[str] = None) -> None:
43064306
"""
43074307
self._file.commit_undo_actions(id)
43084308

4309+
def forget_undo_actions(self, id: Optional[str] = None) -> None:
4310+
"""
4311+
``forget_undo_actions`` removes the actions taken since a call to :py:func:`begin_undo_actions`
4312+
Pass as `id` the value returned by :py:func:`begin_undo_actions`. Empty values of
4313+
`id` will remove all changes since the last call to :py:func:`begin_undo_actions`.
4314+
4315+
:param Optional[str] id: id of undo state, from :py:func:`begin_undo_actions`
4316+
:rtype: None
4317+
:Example:
4318+
4319+
>>> bv.get_disassembly(0x100012f1)
4320+
'xor eax, eax'
4321+
>>> state = bv.begin_undo_actions()
4322+
>>> bv.convert_to_nop(0x100012f1)
4323+
True
4324+
>>> bv.forget_undo_actions(state)
4325+
>>> bv.get_disassembly(0x100012f1)
4326+
'nop'
4327+
>>> bv.undo()
4328+
>>> bv.get_disassembly(0x100012f1)
4329+
'nop'
4330+
>>>
4331+
"""
4332+
self._file.forget_undo_actions(id)
4333+
43094334
def revert_undo_actions(self, id: Optional[str] = None) -> None:
43104335
"""
43114336
``revert_undo_actions`` reverts the actions taken since a call to :py:func:`begin_undo_actions`

python/filemetadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def forget_undo_actions(self, id: Optional[str] = None) -> None:
429429
>>> state = bv.begin_undo_actions()
430430
>>> bv.convert_to_nop(0x100012f1)
431431
True
432-
>>> bv.commit_undo_actions(state)
432+
>>> bv.forget_undo_actions(state)
433433
>>> bv.get_disassembly(0x100012f1)
434434
'nop'
435435
>>> bv.undo()

0 commit comments

Comments
 (0)