MCPcopy Create free account
hub / github.com/PyTables/PyTables / redo

Method redo

tables/file.py:2771–2821  ·  view source on GitHub ↗

Go to a future state of the database. Returns the database to the state associated with the specified mark. Both the identifier of a mark and its name can be used. If the `mark` is omitted, the next created mark is used. If there are no future marks, or the specifi

(self, mark: int | str | None = None)

Source from the content-addressed store, hash-verified

2769 # (self._curaction, self._curmark))
2770
2771 def redo(self, mark: int | str | None = None) -> None:
2772 """Go to a future state of the database.
2773
2774 Returns the database to the state associated with the specified
2775 mark. Both the identifier of a mark and its name can be used.
2776 If the `mark` is omitted, the next created mark is used. If
2777 there are no future marks, or the specified mark is not newer
2778 than the current one, an UndoRedoError is raised.
2779
2780 This method can only be called when the Undo/Redo mechanism has
2781 been enabled. Otherwise, an UndoRedoError is raised.
2782
2783 """
2784 self._check_open()
2785 self._check_undo_enabled()
2786
2787 # print("(pre)REDO: (curaction, curmark) = (%s, %s)" % \
2788 # (self._curaction, self._curmark))
2789 if self._curaction >= self._actionlog.nrows - 1:
2790 # We are at the end of log, so no action
2791 return
2792
2793 if mark is None:
2794 mark = self._curmark + 1
2795 elif mark == -1:
2796 mark = int(self._nmarks) # Go beyond the mark bounds up to the end
2797 # Get the mark ID number
2798 markid = self._get_mark_id(mark)
2799 finalaction = self._get_final_action(markid)
2800 if finalaction < self._curaction + 1:
2801 raise UndoRedoError(
2802 "Mark ``%s`` is older than the current mark. "
2803 "Use `redo()` or `goto()` instead." % (mark,)
2804 )
2805
2806 # The file is going to be changed.
2807 self._check_writable()
2808
2809 # Get the final action ID to go
2810 self._curaction += 1
2811
2812 # Try to reach this mark by redoing the actions in the log
2813 self._doundo(finalaction, 1)
2814 # Increment the current mark only if we are not at the end of marks
2815 if self._curmark < self._nmarks - 1:
2816 self._curmark += 1
2817 if self._curaction > self._actionlog.nrows - 1:
2818 self._curaction = self._actionlog.nrows - 1
2819
2820 # print("(post)REDO: (curaction, curmark) = (%s,%s)" % \
2821 # (self._curaction, self._curmark))
2822
2823 def goto(self, mark: int | str) -> None:
2824 """Go to a specific mark of the database.

Callers 15

gotoMethod · 0.95
_doundoMethod · 0.80
test00_simpleMethod · 0.80
test01_twiceMethod · 0.80
test02_twice2Method · 0.80
test03_6times3marksMethod · 0.80
test04_6times3marksroMethod · 0.80
test05f_destructiveMethod · 0.80
test07_totalrewindMethod · 0.80
test08_marknamesMethod · 0.80
test08_initialmarkMethod · 0.80
test09_marknamesMethod · 0.80

Calls 7

_check_openMethod · 0.95
_check_undo_enabledMethod · 0.95
_get_mark_idMethod · 0.95
_get_final_actionMethod · 0.95
_check_writableMethod · 0.95
_doundoMethod · 0.95
UndoRedoErrorClass · 0.85

Tested by 15

test00_simpleMethod · 0.64
test01_twiceMethod · 0.64
test02_twice2Method · 0.64
test03_6times3marksMethod · 0.64
test04_6times3marksroMethod · 0.64
test05f_destructiveMethod · 0.64
test07_totalrewindMethod · 0.64
test08_marknamesMethod · 0.64
test08_initialmarkMethod · 0.64
test09_marknamesMethod · 0.64
test11_contiguousMethod · 0.64
test00Method · 0.64