Commits

Jeremy White committed 8fa2f3d

added - TfsManager will now free locks by setting string.
While kind of hackish, it's a simple and effective way to stop racing processes

Comments (0)

Files changed (1)

 import stat
 
 class TfsManager(object):
-    def __init__(self):
+    def __init__(self, view=None, filekey=None):
         self.name = 'sublime_tfs'
         settings = sublime.load_settings('sublime_tfs.sublime-settings')
         self.tf_path = settings.get("tf_path")
         self.tfpt_path = settings.get("tfpt_path")
         self.cwd = os.path.expandvars('%HOMEDRIVE%\\')
+        self.view = view
+        self.filekey = filekey
 
     def is_under_tfs(self, path):
         return self.status(path)
         else:
             p = self.launch_Without_Console(commands)
         (out, err) = p.communicate()
+
+        if(self.view != None and self.filekey != None):
+            sublime.set_timeout( lambda: self.view.settings().erase(self.filekey) , 200)
+        
         if p.returncode != 0:
             return (False, err if not err is None else "Unknown error")
         else:
     def on_modified(self, view):
         path = view.file_name()
         if not (path is None) and isReadonly(path):
-            manager = TfsManager()
+            settings = view.settings()
+            filekey = "tfscheckout: " + path
+            if settings.has(filekey) :
+                return
+            settings.set(filekey, True)
+            manager = TfsManager(view, filekey)
             thread = TfsRunnerThread(path, manager.auto_checkout)
             thread.start()
             ThreadProgress(view, thread, "Checkout...", "Checkout success: %s" % path)