show undo diff (#3213)

Exposes undo operations via the C API, and uses those to show a (new, differently formatted) diff before committing the undo.
This commit is contained in:
ryneeverett
2024-02-09 22:11:14 -05:00
committed by GitHub
parent 89df80c9f0
commit 34c0e67469
18 changed files with 646 additions and 66 deletions

View File

@@ -74,7 +74,7 @@ class TestUndoStyle(TestCase):
self.t("add one project:foo priority:H")
self.t("1 modify +tag project:bar priority:")
@unittest.expectedFailure # undo diffs are not supported
@unittest.expectedFailure # undo diffs are not supported
def test_undo_side_style(self):
"""Test that 'rc.undo.style:side' generates the right output"""
self.t.config("undo.style", "side")
@@ -82,7 +82,7 @@ class TestUndoStyle(TestCase):
self.assertNotRegex(out, "-tags:\s*\n\+tags:\s+tag")
self.assertRegex(out, "tags\s+tag\s*")
@unittest.expectedFailure # undo diffs are not supported
@unittest.expectedFailure # undo diffs are not supported
def test_undo_diff_style(self):
"""Test that 'rc.undo.style:diff' generates the right output"""
self.t.config("undo.style", "diff")
@@ -90,6 +90,18 @@ class TestUndoStyle(TestCase):
self.assertRegex(out, "-tags:\s*\n\+tags:\s+tag")
self.assertNotRegex(out, "tags\s+tag\s*")
def test_undo_diff_operations(self):
code, out, err = self.t("undo", input="n\n")
# If the clock ticks a second between `add` and `modify` there is a
# fifth operation setting the `modified` property.
self.assertRegex(out, "The following [4|5] operations would be reverted:")
self.assertIn("tag_tag: <empty> -> x", out)
self.assertIn("tags: <empty> -> tag", out)
self.assertIn("project: foo -> bar", out)
self.assertIn("priority: H -> <empty>", out)
class TestBug634(TestCase):
def setUp(self):