1. Stuart Burrows
  2. Sublime TFS

Commits

Stuart Burrows  committed 49b4371

Added rudimentary auto-checkout options / checks

  • Participants
  • Parent commits 7bb8f4f
  • Branches default

Comments (0)

Files changed (2)

File sublime_tfs.py

View file
  • Ignore whitespace
 import os
 import stat
 
+auto_checkout_dict = {}
 class TfsManager(object):
     def __init__(self):
         self.name = 'sublime_tfs'
         self.success_message = success_message
         self.addend = 1
         self.size = 8
+        id = view.buffer_id()
         sublime.set_timeout(lambda: self.run(0), 100)
 
+        global auto_checkout_dict
+        del auto_checkout_dict[id]
+
     def run(self, i):
         if not self.thread.is_alive():
             self.view.erase_status('tfs')
 
 class TfsEventListener(sublime_plugin.EventListener):
     def on_modified(self, view):
+        global auto_checkout_dict
         path = view.file_name()
-        if not (path is None) and isReadonly(path):
+        id = view.buffer_id()
+        if not (path is None) and not (id in auto_checkout_dict) and isReadonly(path):
             manager = TfsManager()
             thread = TfsRunnerThread(path, manager.auto_checkout)
+            if(sublime.load_settings('sublime_tfs.sublime-settings').get("prompt_checkout") == "True"):
+                if(sublime.ok_cancel_dialog('The file is not checked out. Check out now?', 'Go ahead!')):
+                    auto_checkout_dict[id] = True
+                    return
+                else:
+                    return False
+                retun
             thread.start()
             ThreadProgress(view, thread, "Checkout...", "Checkout success: %s" % path)
 

File sublime_tfs.sublime-settings

View file
  • Ignore whitespace
 {
-    "tf_path": "C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/TF.exe"
+    "tf_path": "C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/TF.exe",
+    "prompt_checkout": "False"
 }