Commits

Stephen Bunch committed 7bb8f4f

added routine to auto-checkout file when modified

  • Participants
  • Parent commits 965cb90

Comments (0)

Files changed (1)

File sublime_tfs.py

     def status(self, path):
         return self.run_command("status", path)
 
+    def auto_checkout(self, path):
+        if self.status(path)[0]:
+            self.checkout(path)
+            return (True, "")
+        else:
+            return (False, "")
+
     def run_command(self, command, path, is_graph = False):
         commands = [self.tf_path, command, path]
         if (is_graph):
             thread.start()
             ThreadProgress(self.view, thread, "Getting status...")
 
+class TfsEventListener(sublime_plugin.EventListener):
+    def on_modified(self, view):
+        path = view.file_name()
+        if not (path is None) and isReadonly(path):
+            manager = TfsManager()
+            thread = TfsRunnerThread(path, manager.auto_checkout)
+            thread.start()
+            ThreadProgress(view, thread, "Checkout...", "Checkout success: %s" % path)
+
 def isReadonly(path):
     fileAtt = os.stat(path)[0]
     return not fileAtt & stat.S_IWRITE