Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First steps to migrate to sublime text 3 #22

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions Perforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def on_activated(self, view):
global_folder, filename = os.path.split(view.file_name())

# Executed at startup to store the path of the plugin... necessary to open files relative to the plugin
perforceplugin_dir = os.getcwdu()
perforceplugin_dir = os.getcwd()

# Utility functions
def ConstructCommand(in_command):
Expand Down Expand Up @@ -82,6 +82,8 @@ def GetUserFromClientspec():
command = ConstructCommand('p4 info')
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()
result = result.decode()
err = err.decode()

if(err):
WarnUser("usererr " + err.strip())
Expand All @@ -107,6 +109,8 @@ def GetClientRoot(in_dir):
command = ConstructCommand('p4 info')
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()
result = result.decode()
err = err.decode()

if(err):
WarnUser(err.strip())
Expand Down Expand Up @@ -177,6 +181,9 @@ def GetPendingChangelists():

p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()
result = result.decode()
err = err.decode()

if(not err):
return 1, result
return 0, result
Expand All @@ -186,6 +193,8 @@ def AppendToChangelistDescription(changelist, input):
command = ConstructCommand('p4 change -o ' + changelist)
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()
result = result.decode()
err = err.decode()

if(err):
return 0, err
Expand Down Expand Up @@ -223,7 +232,9 @@ def AppendToChangelistDescription(changelist, input):
command = ConstructCommand('p4 change -i < ' + temp_changelist_description_file.name)
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()

result = result.decode()
err = err.decode()

# Clean up
os.unlink(temp_changelist_description_file.name)

Expand All @@ -236,7 +247,9 @@ def PerforceCommandOnFile(in_command, in_folder, in_filename):
command = ConstructCommand('p4 ' + in_command + ' "' + in_filename + '"')
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()

result = result.decode()
err = err.decode()

if(not err):
return 1, result.strip()
else:
Expand All @@ -248,11 +261,11 @@ def WarnUser(message):
if(perforce_settings.get('perforce_log_warnings_to_status')):
sublime.status_message("Perforce [warning]: " + message)
else:
print "Perforce [warning]: " + message
print ("Perforce [warning]: " + message)

def LogResults(success, message):
if(success >= 0):
print "Perforce: " + message
print ("Perforce: " + message)
else:
WarnUser(message);

Expand Down Expand Up @@ -439,7 +452,7 @@ def Revert(in_folder, in_filename):
return PerforceCommandOnFile("revert", in_folder, in_filename);

class PerforceRevertCommand(sublime_plugin.TextCommand):
def run_(self, args): # revert cannot be called when an Edit object exists, manually handle the run routine
def run_(self, *args): # revert cannot be called when an Edit object exists, manually handle the run routine
if(self.view.file_name()):
folder_name, filename = os.path.split(self.view.file_name())

Expand Down Expand Up @@ -597,6 +610,9 @@ def MakeFileListFromChangelist(self, in_changelistline):
command = ConstructCommand('p4 opened -c ' + in_changelistline[1] + ' -u ' + currentuser)
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()
result = result.decode()
err = err.decode()

if(not err):
lines = result.splitlines()
for line in lines:
Expand Down Expand Up @@ -629,6 +645,8 @@ def MakeCheckedOutFileList(self):

p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()
result = result.decode()
err = err.decode()

if(not err):
changelists = result.splitlines()
Expand Down Expand Up @@ -670,7 +688,9 @@ def CreateChangelist(description):
command = ConstructCommand('p4 change -o')
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()

result = result.decode()
err = err.decode()

if(err):
return 0, err

Expand All @@ -696,6 +716,8 @@ def CreateChangelist(description):
command = ConstructCommand('p4 change -i < ' + temp_changelist_description_file.name)
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()
result = result.decode()
err = err.decode()

# Clean up
os.unlink(temp_changelist_description_file.name)
Expand Down Expand Up @@ -728,6 +750,8 @@ def MoveFileToChangelist(in_filename, in_changelist):
command = ConstructCommand('p4 reopen -c ' + in_changelist + ' "' + filename + '"')
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()
result = result.decode()
err = err.decode()

if(err):
return 0, err
Expand Down Expand Up @@ -897,6 +921,9 @@ def MakeChangelistsList(self):
command = ConstructCommand('p4 opened -c default -u ' + currentuser)
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()
result = result.decode()
err = err.decode()

if err:
resultchangelists.pop()

Expand Down Expand Up @@ -937,6 +964,8 @@ def on_done(self, picked):
command = ConstructCommand('p4 submit')
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()
result = result.decode()
err = err.decode()

def on_description_change(self, input):
pass
Expand Down Expand Up @@ -1024,7 +1053,9 @@ def on_done(self, picked):
command = ConstructCommand("p4 " + cmdString)
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True)
result, err = p.communicate()

result = result.decode()
err = err.decode()

if(err):
WarnUser("usererr " + err.strip())
return -1
Expand Down