Commits

Ali Gholami Rudi  committed 3783488

added History.tobe_undone and History.tobe_redone

  • Participants
  • Parent commits 3b6aa27

Comments (0)

Files changed (3)

File docs/dev/issues.txt

 
 Ideas:
 
-* Should each wildcard match one ast node?
 * Maybe we can put checks inside args, too::
 
     pattern: ${project:type=rope.base.project.Project}.pycore
 Implementation
 --------------
 
-* how to decide which wildcard should be used when searching?
-* how to pass wildcard parameters to matchers
 * matchers might need to type-check or use other matchers
-* matchers may update ast mappings
 * how to say what matched a node in replacements?
 * how to pass replacement args to replacements?
 * how to decide which wildcard should be used when replacing?

File rope/base/history.py

     undo_list = property(lambda self: self._undo_list)
     redo_list = property(lambda self: self._redo_list)
 
+    @property
+    def tobe_undone(self):
+        if self.undo_list:
+            return self.undo_list[-1]
+
+    @property
+    def tobe_redone(self):
+        if self.redo_list:
+            return self.redo_list[-1]
+
 
 class _FindChangeDependencies(object):
 

File ropetest/historytest.py

         self.history.undo()
         self.assertEquals('', self.file1.read())
 
+    def test_tobe_undone(self):
+        change1 = ChangeContents(self.file1, '1')
+        self.assertEquals(None, self.history.tobe_undone)
+        self.history.do(change1)
+        self.assertEquals(change1, self.history.tobe_undone)
+        change2 = ChangeContents(self.file1, '2')
+        self.history.do(change2)
+        self.assertEquals(change2, self.history.tobe_undone)
+        self.history.undo()
+        self.assertEquals(change1, self.history.tobe_undone)
+
+    def test_tobe_redone(self):
+        change = ChangeContents(self.file1, '1')
+        self.history.do(change)
+        self.assertEquals(None, self.history.tobe_redone)
+        self.history.undo()
+        self.assertEquals(change, self.history.tobe_redone)
+
     @testutils.assert_raises(exceptions.HistoryError)
     def test_undo_limit(self):
         history = rope.base.history.History(self.project, maxundos=1)