From 080d9374a9ffbea76469c888c4241024db2187dc Mon Sep 17 00:00:00 2001 From: Oleksandr Chekhovskyi Date: Thu, 26 Feb 2015 13:47:34 +0100 Subject: [PATCH 1/2] Use specific current directory for p4 instead of global when possible. This fixes bug with Save All where files are marked for add in incorrect locations. --- Perforce.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Perforce.py b/Perforce.py index af00fd8..46be54a 100644 --- a/Perforce.py +++ b/Perforce.py @@ -93,7 +93,7 @@ def GetUserFromClientspec(): def GetClientRoot(in_dir): # check if the file is in the depot command = ConstructCommand('p4 info') - p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True) + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=in_dir, shell=True) result, err = p.communicate() result = result.decode("utf-8") err = err.decode("utf-8") @@ -108,7 +108,7 @@ def GetClientRoot(in_dir): # sometimes the clientspec is not displayed sublime.error_message("Perforce Plugin: p4 info didn't supply a valid clientspec, launching p4 client"); command = ConstructCommand('p4 client') - p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True) + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=in_dir, shell=True) result, err = p.communicate() return -1 @@ -230,7 +230,7 @@ def AppendToChangelistDescription(changelist, input): def PerforceCommandOnFile(in_command, in_folder, in_filename): command = ConstructCommand('p4 {0} "{1}"'.format(in_command, in_filename)) - p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True) + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=in_folder, shell=True) result, err = p.communicate() result = result.decode("utf-8") err = err.decode("utf-8") @@ -330,9 +330,6 @@ def on_pre_save(self, view): if view.file_name() and os.path.isfile(view.file_name()): return - global global_folder - global_folder, filename = os.path.split(view.file_name()) - perforce_settings = sublime.load_settings('Perforce.sublime-settings') self.preSaveIsFileInDepot = 0 From e60a9caea78ef71441e27b1de3e88b88cade4d6a Mon Sep 17 00:00:00 2001 From: Oleksandr Chekhovskyi Date: Wed, 29 Apr 2015 11:47:22 +0200 Subject: [PATCH 2/2] Resolve symlinks when performing auto-checkout. --- Perforce.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Perforce.py b/Perforce.py index 46be54a..14ad641 100644 --- a/Perforce.py +++ b/Perforce.py @@ -296,7 +296,7 @@ def on_modified(self, view): return if(view.is_dirty()): - success, message = Checkout(view.file_name()) + success, message = Checkout(os.path.realpath(view.file_name())) LogResults(success, message); def on_pre_save(self, view): @@ -307,7 +307,7 @@ def on_pre_save(self, view): return if(view.is_dirty()): - success, message = Checkout(view.file_name()) + success, message = Checkout(os.path.realpath(view.file_name())) LogResults(success, message); class PerforceCheckoutCommand(sublime_plugin.TextCommand):