From 0b976547313e07bed0cb2da598e2923a05764fbb Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Tue, 21 Mar 2023 16:43:19 +0000 Subject: [PATCH] Remove `merge_undo` from undo code. (#1999) 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. --- traitsui/tests/test_undo.py | 14 -------------- traitsui/undo.py | 34 ---------------------------------- 2 files changed, 48 deletions(-) diff --git a/traitsui/tests/test_undo.py b/traitsui/tests/test_undo.py index 1eefd95f1..b9cd128f4 100644 --- a/traitsui/tests/test_undo.py +++ b/traitsui/tests/test_undo.py @@ -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) diff --git a/traitsui/undo.py b/traitsui/undo.py index ff2816cb1..ef8328990 100644 --- a/traitsui/undo.py +++ b/traitsui/undo.py @@ -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 @@ -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 @@ -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 )" % ( @@ -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')