From e5a84235cbe8ece44c902474850313fd0715e252 Mon Sep 17 00:00:00 2001 From: leetNightshade Date: Thu, 20 Apr 2017 16:20:43 -0700 Subject: [PATCH] Fix issue where clientRoot is null due to multiple view mappings that don't share one root. TODO: should probably leave getClientRoot to return the "null". It's different than returning None. --- p4Helper.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/p4Helper.py b/p4Helper.py index 17546d1..7e1f28b 100644 --- a/p4Helper.py +++ b/p4Helper.py @@ -196,7 +196,8 @@ def get_client_root( ): continue local_path = normpath( line[ len( clientFile_tag ) : ].strip( ) ) - + if local_path == "null": + local_path = None return local_path return None @@ -230,22 +231,33 @@ class P4Workspace: ldirectory = self.directory.lower() oldworkspace_name = None + # If workspace root is null, it could be because there are multiple views and not a single root. + if client_root is None: + results = get_p4_py_results('where', self.directory) + for result in results: + path = result[b'path'] + path = re.sub('...$', '', path) + path = normpath(path) + if ldirectory.startswith(path.lower()): + client_root = path + break + if client_root is None or not ldirectory.startswith(client_root.lower()): #print("\nCurrent directory not in client view, checking other workspaces for user '" + username + "' ...") oldworkspace_name = parse_info_from_command('p4 info', 'Client name: ') # get user workspaces - result = get_p4_py_results('workspaces -u ' + username) + results = get_p4_py_results('workspaces -u ' + username) workspaces = [] - for r in result: + for r in results: whost = get_str_from_process_stdout(r[b'Host']) if whost is not None and len(whost) != 0 and client_host != whost: continue workspace = {'root': get_str_from_process_stdout(r[b'Root']), 'name': get_str_from_process_stdout(r[b'client'])} workspaces.append(workspace) - del result + del results # check current directory against current workspace, see if it matches existing workspaces. for w in workspaces: