-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathp4wrapper.py
More file actions
executable file
·48 lines (41 loc) · 1.22 KB
/
p4wrapper.py
File metadata and controls
executable file
·48 lines (41 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
## Place this file into sublimeText 2 installation folder
## under Data\Packages\User
##
## From SublimeText2, Open User Key Binding file From Preferences -> Key Bindings - User,
## Add following lines:
## {
## "command": "p4_checkout",
## "keys": ["ctrl+alt+e"]
## },
## {
## "command": "p4_revert",
## "keys": ["ctrl+alt+r"]
## }
##
import sublime, sublime_plugin
import os
def Checkout(file):
command = "c:\\portable\\perforce\\p4wrapper.exe"
command += " -file=" + file
command += " -action=edit"
command += " & pause"
print command
os.system(command)
def Revert(file):
command = "c:\\portable\\perforce\\p4wrapper.exe"
command += " -file=" + file
command += " -action=revert"
command += " & pause"
os.system(command)
class P4CheckoutCommand(sublime_plugin.TextCommand):
def run(self, edit):
if(self.view.file_name()):
Checkout(self.view.file_name())
else:
print("View does not contain a file")
class P4RevertCommand(sublime_plugin.TextCommand):
def run(self, edit):
if(self.view.file_name()):
Revert(self.view.file_name())
else:
print("View does not contain a file")