Skip to content

Commit

Permalink
Remove merge_undo from undo code. (#1999)
Browse files Browse the repository at this point in the history
Fixes #1515.  Also removes a no-longer used `history` trait.

This completes the transition of TraitsUI undo/redo to share the same basis as the Pyface/Apptools undo/redo.

There is still an issue in #1060 that is unresolved which is about refactoring TraitsUI to be more command-stack based, rather than building the command stack reactively.
  • Loading branch information
corranwebster authored Mar 21, 2023
1 parent 86927f5 commit 0b97654
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 48 deletions.
14 changes: 0 additions & 14 deletions traitsui/tests/test_undo.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,6 @@ def redo(self):
pass


class TestAbstractUndoItem(UnittestTools, unittest.TestCase):
def test_merge_undo_deprecated(self):
undo_item = LegacyUndoItem()
other_item = LegacyUndoItem()

with catch_warnings(record=True) as w:
result = undo_item.merge(other_item)
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[0].category, DeprecationWarning))
self.assertIn("merge_undo", str(w[0].message))

self.assertFalse(result)


class TestUndoItem(UnittestTools, unittest.TestCase):
def test_undo(self):
example = SimpleExample(value=11)
Expand Down
34 changes: 0 additions & 34 deletions traitsui/undo.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,6 @@ def redo(self):

def merge(self, other):
"""Merges two undo items if possible."""
import warnings

warnings.warn(
"'merge_undo' is deprecated and will be removed in TraitsUI 8, "
"use 'merge' instead",
DeprecationWarning,
)
return self.merge_undo(other)

def merge_undo(self, undo_item):
"""Merges two undo items if possible.
This method is deprecated.
"""
return False


Expand Down Expand Up @@ -209,13 +195,6 @@ def merge(self, undo_item):
return True
return False

def merge_undo(self, undo_item):
"""Merges two undo items if possible.
This is deprecated.
"""
return self.merge(undo_item)

def __repr__(self):
"""Returns a "pretty print" form of the object."""
n = self.name
Expand Down Expand Up @@ -299,13 +278,6 @@ def merge(self, undo_item):
return True
return False

def merge_undo(self, undo_item):
"""Merges two undo items if possible.
This is deprecated.
"""
return self.merge(undo_item)

def __repr__(self):
"""Returns a 'pretty print' form of the object."""
return "undo( %s.%s[%d:%d] = %s )" % (
Expand Down Expand Up @@ -364,12 +336,6 @@ class UndoHistory(HasStrictTraits):
#: The command stack for the history.
stack = Instance(ICommandStack, allow_none=False)

#: List of accumulated undo changes. Each item is a list of
#: AbstractUndoItems that should be done or undone as a group.
#: This trait should be considered private.
#: This trait is no longer used.
history = List()

#: The current position in the list
now = Property(Int, observe='stack._index')

Expand Down

0 comments on commit 0b97654

Please sign in to comment.