Commits

Ali Gholami Rudi  committed b10701e

history: using write_hook

  • Participants
  • Parent commits 8b6480a

Comments (0)

Files changed (3)

File 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()

File 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]

File 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()