Anonymous avatar Anonymous committed 3783488

added History.tobe_undone and History.tobe_redone

Comments (0)

Files changed (3)

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?

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):
 

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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.