Skip to content
Browse files

Update command

  • Loading branch information...
1 parent 7781093 commit 463186024dbfa1ae7cca478ddc5e4daf91ddadc8 Tomek Wytrębowicz committed Jul 1, 2012
Showing with 87 additions and 47 deletions.
  1. +0 −19 .gitattributes
  2. +2 −7 .gitignore
  3. +13 −8 Default.sublime-commands
  4. +0 −5 README
  5. +21 −0 README.md
  6. +4 −0 messages.json
  7. +6 −0 messages/0.1.txt
  8. +9 −0 messages/install.txt
  9. +31 −8 vlt.py
  10. BIN vlt.pyc
  11. +1 −0 vlt.sublime-settings
View
19 .gitattributes
@@ -1,22 +1,3 @@
# Auto detect text files and perform LF normalization
* text=auto
-# Custom for Visual Studio
-*.cs diff=csharp
-*.sln merge=union
-*.csproj merge=union
-*.vbproj merge=union
-*.fsproj merge=union
-*.dbproj merge=union
-
-# Standard to msysgit
-*.doc diff=astextplain
-*.DOC diff=astextplain
-*.docx diff=astextplain
-*.DOCX diff=astextplain
-*.dot diff=astextplain
-*.DOT diff=astextplain
-*.pdf diff=astextplain
-*.PDF diff=astextplain
-*.rtf diff=astextplain
-*.RTF diff=astextplain
View
9 .gitignore
@@ -1,8 +1,3 @@
-#Translations
-*.mo
-
-#Mr Developer
-.mr.developer.cfg
-
-# Mac crap
.DS_Store
+Thumbs.db
+Desktop.ini
View
21 Default.sublime-commands
@@ -1,4 +1,17 @@
[
+
+ {
+ "caption": "vlt: Commit",
+ "command": "vlt_commit"
+ },
+ {
+ "caption": "vlt: Add",
+ "command": "vlt_add"
+ },
+ {
+ "caption": "vlt: Update",
+ "command": "vlt_update"
+ },
{
"caption": "vlt: Import",
"command": "vlt_import"
@@ -10,13 +23,5 @@
{
"caption": "vlt: Delete",
"command": "vlt_delete"
- },
- {
- "caption": "vlt: Commit",
- "command": "vlt_commit"
- },
- {
- "caption": "vlt: Add",
- "command": "vlt_add"
}
]
View
5 README
@@ -1,5 +0,0 @@
-Sublime Text 2 (CQ) VLT Plugin
-
-Tomek Wytrebowicz (tomalecpub@gmail.com)
-
-Available at https://github.com/tomalecpub/
View
21 README.md
@@ -0,0 +1,21 @@
+# Sublime Text 2 (CQ) VLT Plugin
+
+Supports commands to commit, add, update files.
+
+
+Tomek Wytrebowicz (tomalecwp@gmail.com)
+
+Available at https://github.com/tomalec/Sublime-Text-2-Vlt-Plugin
+
+
+# License
+
+All of Sublime Text 2 Vlt Plugin is licensed under the MIT license.
+
+Copyright (c) 2012 Tomek Wytrebowicz (tomalecwp@gmail.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
4 messages.json
@@ -0,0 +1,4 @@
+{
+ "install": "messages/install.txt",
+ "0.1": "messages/0.1.txt"
+}
View
6 messages/0.1.txt
@@ -0,0 +1,6 @@
+Vlt integration 0.1 changelog:
+
+Feature:
+ - (auto) commit a file
+ - (auto) add a file, directories not supported yet
+ - updating a file
View
9 messages/install.txt
@@ -0,0 +1,9 @@
+Vlt (CQ) integration by Tomek Wytrebowicz (tomalecwp@gmail.com)
+
+Code is based on Perforce Plugin https://github.com/ericmartel/Sublime-Text-2-Perforce-Plugin by Eric Marings to control which features are enabled,
+and it is still in progress.
+
+Please direct any feedback to tomalecwp@gmail.com or through github at https://github.com/tomalec/Sublime-Text-2-Vlt-Plugin.
+
+
+Tomek Wytrębowicz
View
39 vlt.py
@@ -22,7 +22,7 @@ def VltCommandOnFile(in_command, in_folder, in_filename):
command = ConstructCommand('vlt ' + in_command + ' "' + in_filename + '"')
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=in_folder, shell=True)
result, err = p.communicate()
-
+
if(not err):
return 1, result.strip()
else:
@@ -41,6 +41,7 @@ def LogResults(success, message):
print "vlt: " + message
else:
WarnUser(message);
+
# Commit section
def Commit(in_folder, in_filename):
# Commit the file
@@ -49,12 +50,12 @@ def Commit(in_folder, in_filename):
class VltAutoCommit(sublime_plugin.EventListener):
preSaveIsFileInRepo = 0
def on_pre_save(self, view):
- perforce_settings = sublime.load_settings('vlt.sublime-settings')
+ vlt_settings = sublime.load_settings('vlt.sublime-settings')
self.preSaveIsFileInRepo = 0
# check if this part of the plugin is enabled
- if(not perforce_settings.get('vlt_auto_add')):
+ if(not vlt_settings.get('vlt_auto_add')):
WarnUser("Auto Add disabled")
return
@@ -84,7 +85,8 @@ def run(self, edit):
def Add(in_folder, in_filename):
# Add the file
success, message = VltCommandOnFile("add", in_folder, in_filename);
- if(not success or message[0,2]!="A "):
+
+ if(not success or message[0:2]!="A "):
return 0, message
return VltCommandOnFile("ci", in_folder, in_filename);
@@ -102,19 +104,19 @@ def IsFileInRepo(in_folder, in_filename):
if(not success):
return 0, message
# locate the line containing "Status: " and extract the following status
- startindex = result.find("Status: ")
+ startindex = message.find("Status: ")
if(startindex == -1):
WarnUser("Unexpected output from 'vlt info'.")
return -1
startindex += 8 # advance after "Status: "
- endindex = result.find("\n", startindex)
+ endindex = message.find("\n", startindex)
if(endindex == -1):
WarnUser("Unexpected output from 'vlt info'.")
return -1
- status = result[startindex:endindex].strip();
+ status = message[startindex:endindex].strip();
if(os.path.isfile(os.path.join(in_folder, in_filename))): # file exists on disk, not being added
if(status != "unknown"):
return 1
@@ -124,4 +126,25 @@ def IsFileInRepo(in_folder, in_filename):
if(status != "unknown"):
return -1 # will be in the depot, it's being added
else:
- return 0
+ return 0
+
+
+# Update section
+def Update(in_folder, in_filename):
+ # update the file
+ return VltCommandOnFile("update", in_folder, in_filename);
+
+class VltUpdateCommand(sublime_plugin.TextCommand):
+ def run(self, edit):
+ if(self.view.file_name()):
+ folder_name, filename = os.path.split(self.view.file_name())
+
+ if(IsFileInRepo(folder_name, filename)):
+ success, message = Update(folder_name, filename)
+ else:
+ success = 0
+ message = "File is not in the repo."
+
+ LogResults(success, message)
+ else:
+ WarnUser("View does not contain a file")
View
BIN vlt.pyc
Binary file not shown.
View
1 vlt.sublime-settings
@@ -2,4 +2,5 @@
"vlt_auto_commit": true, // when true, commit will occur
"vlt_auto_add": true, // when true, add will occur
"vlt_warnings_enabled": true, // will output messages when warnings happen
+ "vlt_log_warnings_to_status": false
}

0 comments on commit 4631860

Please sign in to comment.
Something went wrong with that request. Please try again.