Anonymous avatar Anonymous committed b10701e

history: using write_hook

Comments (0)

Files changed (3)

rope/base/history.py

         self.save = self.project.get_prefs().get('save_history', False)
         self.compress = project.get_prefs().get('compress_history', False)
         self._load_history()
+        self.project.data_files.add_write_hook(self.write)
         self.current_change = None
 
     def _load_history(self):
                change_.resource == file:
                 return change_.old_contents
 
-    def sync(self):
+    def write(self):
         if self.save:
             data = []
             to_data = change.ChangeToData()

rope/base/project.py

         self.operations = rope.base.change._ResourceOperations(self, fscommands)
         self.prefs = prefs.Prefs()
         self._pycore = None
+        self.data_files = _DataFiles(self)
 
     def get_resource(self, resource_name):
         """Get a resource in a project.
 
     def close(self):
         """Closes project open resources"""
-        if self._history is not None:
-            self.history.sync()
 
     def sync(self):
         """Closes project open resources"""
 
     history = property(_get_history)
     pycore = property(get_pycore)
+    ropefolder = None
 
 
 class Project(_Project):
         super(Project, self).__init__(fscommands)
         self.ignored = _IgnoredResources()
         self.file_list = _FileListCacher(self)
-        self.data_files = _DataFiles(self)
         self.prefs.add_callback('ignored_resources', self.ignored.set_ignored)
         if ropefolder is not None:
             self.prefs['ignored_resources'] = [ropefolder]

ropetest/historytest.py

         history = rope.base.history.History(self.project)
         myfile = self.project.get_file('myfile.txt')
         history.do(CreateResource(myfile))
-        history.sync()
+        history.write()
 
         history = rope.base.history.History(self.project)
         history.undo()
         myfile = self.project.get_file('myfile.txt')
         history.do(CreateResource(myfile))
         history.undo()
-        history.sync()
+        history.write()
 
         history = rope.base.history.History(self.project)
         history.redo()
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.