initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class BringWindowToFront
|
||||
{
|
||||
internal static void ForWindowsProcess(int processId)
|
||||
{
|
||||
IntPtr handle = FindMainWindowForProcess(processId);
|
||||
|
||||
if (IsIconic(handle))
|
||||
ShowWindow(handle, SW_RESTORE);
|
||||
|
||||
SetForegroundWindow(handle);
|
||||
}
|
||||
|
||||
static IntPtr FindMainWindowForProcess(int processId)
|
||||
{
|
||||
IntPtr result = IntPtr.Zero;
|
||||
|
||||
EnumWindows(delegate (IntPtr wnd, IntPtr param)
|
||||
{
|
||||
uint windowProcessId = 0;
|
||||
GetWindowThreadProcessId(wnd, out windowProcessId);
|
||||
|
||||
if (windowProcessId == processId &&
|
||||
IsMainWindow(wnd))
|
||||
{
|
||||
result = wnd;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}, IntPtr.Zero);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool IsMainWindow(IntPtr handle)
|
||||
{
|
||||
return GetWindow(new HandleRef(null, handle), GW_OWNER) == IntPtr.Zero
|
||||
&& IsWindowVisible(new HandleRef(null, handle));
|
||||
}
|
||||
|
||||
// Delegate to filter which windows to include
|
||||
delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
static extern IntPtr GetWindow(HandleRef hWnd, int uCmd);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
static extern bool IsWindowVisible(HandleRef hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool ShowWindow(IntPtr handle, int nCmdShow);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool SetForegroundWindow(IntPtr handle);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool IsIconic(IntPtr handle);
|
||||
|
||||
const int GW_OWNER = 4;
|
||||
const int SW_RESTORE = 9;
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/BringWindowToFront.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/BringWindowToFront.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bc5c1fa3d4519114cb21f3fedfe6039d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,92 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class FindTool
|
||||
{
|
||||
internal static string ObtainToolCommand(
|
||||
string toolName, List<string> installationPaths)
|
||||
{
|
||||
List<string> processPaths = GetPathsFromEnvVariable(
|
||||
PATH_ENVIRONMENT_VARIABLE,
|
||||
EnvironmentVariableTarget.Process);
|
||||
|
||||
List<string> machinePaths = GetPathsFromEnvVariable(
|
||||
PATH_ENVIRONMENT_VARIABLE,
|
||||
EnvironmentVariableTarget.Machine);
|
||||
|
||||
List<string> pathsToLookup = new List<string>();
|
||||
pathsToLookup.AddRange(processPaths);
|
||||
pathsToLookup.AddRange(machinePaths);
|
||||
pathsToLookup.AddRange(installationPaths);
|
||||
|
||||
string toolPath = FindToolInPaths(toolName, pathsToLookup);
|
||||
|
||||
if (string.IsNullOrEmpty(toolPath))
|
||||
return null;
|
||||
|
||||
EnsureIsInProcessPathEnvVariable(toolPath, processPaths);
|
||||
|
||||
return toolPath;
|
||||
}
|
||||
|
||||
static string FindToolInPaths(
|
||||
string toolName,
|
||||
List<string> paths)
|
||||
{
|
||||
foreach (string path in paths)
|
||||
{
|
||||
if (path == null)
|
||||
continue;
|
||||
|
||||
if (path.Trim() == string.Empty)
|
||||
continue;
|
||||
|
||||
string filePath = CleanFolderPath(path);
|
||||
|
||||
filePath = Path.Combine(filePath, toolName);
|
||||
|
||||
if (File.Exists(filePath))
|
||||
return Path.GetFullPath(filePath);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static string CleanFolderPath(string folderPath)
|
||||
{
|
||||
foreach (char c in Path.GetInvalidPathChars())
|
||||
folderPath = folderPath.Replace(c.ToString(), string.Empty);
|
||||
|
||||
return folderPath;
|
||||
}
|
||||
|
||||
static List<string> GetPathsFromEnvVariable(
|
||||
string variableName,
|
||||
EnvironmentVariableTarget target)
|
||||
{
|
||||
string value = Environment.GetEnvironmentVariable(variableName, target);
|
||||
return new List<string>(value.Split(Path.PathSeparator));
|
||||
}
|
||||
|
||||
static void EnsureIsInProcessPathEnvVariable(
|
||||
string toolPath,
|
||||
List<string> processPaths)
|
||||
{
|
||||
string plasticInstallDir = Path.GetDirectoryName(toolPath);
|
||||
|
||||
if (processPaths.Contains(plasticInstallDir, StringComparer.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
Environment.SetEnvironmentVariable(
|
||||
PATH_ENVIRONMENT_VARIABLE,
|
||||
string.Concat(plasticInstallDir, Path.PathSeparator, processPaths),
|
||||
EnvironmentVariableTarget.Process);
|
||||
}
|
||||
|
||||
const string PATH_ENVIRONMENT_VARIABLE = "PATH";
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/FindTool.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/FindTool.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2e0d1d689c88f76448cad390443d7ba3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,121 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Codice.Utils;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class IsExeAvailable
|
||||
{
|
||||
internal static bool ForMode(bool isGluonMode)
|
||||
{
|
||||
string toolPath = isGluonMode ?
|
||||
PlasticInstallPath.GetGluonExePath() :
|
||||
PlasticInstallPath.GetPlasticExePath();
|
||||
|
||||
return !string.IsNullOrEmpty(toolPath);
|
||||
}
|
||||
}
|
||||
|
||||
internal static class PlasticInstallPath
|
||||
{
|
||||
internal static string GetClientBinDir()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
{
|
||||
string plasticExePath = GetPlasticExePath();
|
||||
|
||||
if (plasticExePath == null)
|
||||
return null;
|
||||
|
||||
return Path.GetDirectoryName(plasticExePath);
|
||||
}
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
string path = GetToolCommand(Plastic.NEW_GUI_MACOS);
|
||||
if (path != null)
|
||||
return GetExistingDir(ToolConstants.NEW_MACOS_BINDIR);
|
||||
|
||||
return GetExistingDir(ToolConstants.LEGACY_MACOS_BINDIR);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static string GetPlasticExePath()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return FindTool.ObtainToolCommand(
|
||||
Plastic.GUI_WINDOWS,
|
||||
new List<String>() { GetWindowsInstallationFolder() });
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
string path = GetToolCommand(Plastic.NEW_GUI_MACOS);
|
||||
if(path != null)
|
||||
return path;
|
||||
|
||||
return GetToolCommand(Plastic.LEGACY_GUI_MACOS);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static string GetGluonExePath()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return FindTool.ObtainToolCommand(
|
||||
Gluon.GUI_WINDOWS,
|
||||
new List<String>() { GetWindowsInstallationFolder() });
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
string path = GetToolCommand(Gluon.NEW_GUI_MACOS);
|
||||
if (path != null)
|
||||
return path;
|
||||
|
||||
return GetToolCommand(Gluon.LEGACY_GUI_MACOS);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static string GetToolCommand(string tool)
|
||||
{
|
||||
return File.Exists(tool) ? tool : null;
|
||||
}
|
||||
|
||||
static string GetExistingDir(string directory)
|
||||
{
|
||||
return Directory.Exists(directory) ? directory : null;
|
||||
}
|
||||
|
||||
static string GetWindowsInstallationFolder()
|
||||
{
|
||||
string programFilesFolder = Environment.GetFolderPath(
|
||||
Environment.SpecialFolder.ProgramFiles);
|
||||
|
||||
return Path.Combine(Path.Combine(programFilesFolder,
|
||||
PLASTICSCM_FOLDER), PLASTICSCM_SUBFOLDER);
|
||||
}
|
||||
|
||||
const string PLASTICSCM_FOLDER = "PlasticSCM5";
|
||||
const string PLASTICSCM_SUBFOLDER = "client";
|
||||
|
||||
class Plastic
|
||||
{
|
||||
internal const string GUI_WINDOWS = "plastic.exe";
|
||||
internal const string LEGACY_GUI_MACOS = "/Applications/PlasticSCM.app/Contents/MacOS/PlasticSCM";
|
||||
internal const string NEW_GUI_MACOS = "/Applications/PlasticSCM.app/Contents/MacOS/macplasticx";
|
||||
}
|
||||
|
||||
class Gluon
|
||||
{
|
||||
internal const string GUI_WINDOWS = "gluon.exe";
|
||||
internal const string LEGACY_GUI_MACOS = "/Applications/Gluon.app/Contents/MacOS/Gluon";
|
||||
internal const string NEW_GUI_MACOS = "/Applications/Gluon.app/Contents/MacOS/macgluonx";
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/IsExeAvailable.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/IsExeAvailable.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f25df29da91c45449ada5f3da8cf20ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,23 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
using Codice.Utils;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class LaunchInstaller
|
||||
{
|
||||
internal static Process ForPlatform(string installerPath)
|
||||
{
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
return Process.Start(
|
||||
ToolConstants.Installer.INSTALLER_MACOS_OPEN,
|
||||
string.Format(ToolConstants.Installer.INSTALLER_MACOS_OPEN_ARGS, installerPath));
|
||||
}
|
||||
|
||||
return Process.Start(
|
||||
installerPath,
|
||||
ToolConstants.Installer.INSTALLER_WINDOWS_ARGS);
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/LaunchInstaller.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/LaunchInstaller.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7b405b01c6be83742bc000fb416b4dbf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,494 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
using Codice.Client.BaseCommands.EventTracking;
|
||||
using Codice.CM.Common;
|
||||
using Codice.LogWrapper;
|
||||
using Codice.Utils;
|
||||
using Unity.PlasticSCM.Editor.Views;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class LaunchTool
|
||||
{
|
||||
public interface IShowDownloadPlasticExeWindow
|
||||
{
|
||||
bool Show(
|
||||
WorkspaceInfo wkInfo,
|
||||
bool isGluonMode,
|
||||
string installCloudFrom,
|
||||
string installEnterpriseFrom,
|
||||
string cancelInstallFrom);
|
||||
bool Show(
|
||||
RepositorySpec repSpec,
|
||||
bool isGluonMode,
|
||||
string installCloudFrom,
|
||||
string installEnterpriseFrom,
|
||||
string cancelInstallFrom);
|
||||
}
|
||||
|
||||
public interface IProcessExecutor
|
||||
{
|
||||
Process ExecuteGUI(
|
||||
string program,
|
||||
string args,
|
||||
string commandFileArg,
|
||||
string commandFileName,
|
||||
int processId);
|
||||
Process ExecuteWindowsGUI(
|
||||
string program,
|
||||
string args,
|
||||
int processId);
|
||||
Process ExecuteProcess(string program, string args);
|
||||
}
|
||||
|
||||
internal static void OpenGUIForMode(
|
||||
IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
IProcessExecutor processExecutor,
|
||||
WorkspaceInfo wkInfo,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (showDownloadPlasticExeWindow.Show(
|
||||
wkInfo,
|
||||
isGluonMode,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticCloudFromOpenGUI,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromOpenGUI,
|
||||
TrackFeatureUseEvent.Features.CancelPlasticInstallationFromOpenGUI))
|
||||
return;
|
||||
|
||||
mLog.DebugFormat(
|
||||
"Opening GUI on wkPath '{0}'.",
|
||||
wkInfo.ClientPath);
|
||||
|
||||
TrackFeatureUseEvent.For(
|
||||
PlasticGui.Plastic.API.GetRepositorySpec(wkInfo),
|
||||
isGluonMode ?
|
||||
TrackFeatureUseEvent.Features.LaunchGluonTool :
|
||||
TrackFeatureUseEvent.Features.LaunchPlasticTool);
|
||||
|
||||
if (isGluonMode)
|
||||
{
|
||||
Process gluonProcess = processExecutor.ExecuteGUI(
|
||||
PlasticInstallPath.GetGluonExePath(),
|
||||
string.Format(
|
||||
ToolConstants.Gluon.GUI_WK_EXPLORER_ARG,
|
||||
wkInfo.ClientPath),
|
||||
ToolConstants.Gluon.GUI_COMMAND_FILE_ARG,
|
||||
ToolConstants.Gluon.GUI_COMMAND_FILE,
|
||||
mGluonProcessId);
|
||||
|
||||
if (gluonProcess != null)
|
||||
mGluonProcessId = gluonProcess.Id;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
Process plasticProcess = processExecutor.ExecuteGUI(
|
||||
PlasticInstallPath.GetPlasticExePath(),
|
||||
string.Format(
|
||||
ToolConstants.Plastic.GUI_MACOS_WK_EXPLORER_ARG,
|
||||
wkInfo.ClientPath),
|
||||
ToolConstants.Plastic.GUI_MACOS_COMMAND_FILE_ARG,
|
||||
ToolConstants.Plastic.GUI_MACOS_COMMAND_FILE,
|
||||
mPlasticProcessId);
|
||||
|
||||
if (plasticProcess != null)
|
||||
mPlasticProcessId = plasticProcess.Id;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
processExecutor.ExecuteProcess(
|
||||
PlasticInstallPath.GetPlasticExePath(),
|
||||
string.Format(
|
||||
ToolConstants.Plastic.GUI_WINDOWS_WK_ARG,
|
||||
wkInfo.ClientPath));
|
||||
}
|
||||
|
||||
internal static void OpenBranchExplorer(
|
||||
IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
IProcessExecutor processExecutor,
|
||||
WorkspaceInfo wkInfo,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (showDownloadPlasticExeWindow.Show(
|
||||
wkInfo,
|
||||
isGluonMode,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticCloudFromOpenBranchExplorer,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromOpenBranchExplorer,
|
||||
TrackFeatureUseEvent.Features.CancelPlasticInstallationFromOpenBranchExplorer))
|
||||
return;
|
||||
|
||||
mLog.DebugFormat(
|
||||
"Opening Branch Explorer on wkPath '{0}'.",
|
||||
wkInfo.ClientPath);
|
||||
|
||||
TrackFeatureUseEvent.For(
|
||||
PlasticGui.Plastic.API.GetRepositorySpec(wkInfo),
|
||||
TrackFeatureUseEvent.Features.LaunchBranchExplorer);
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
Process plasticProcess = processExecutor.ExecuteGUI(
|
||||
PlasticInstallPath.GetPlasticExePath(),
|
||||
string.Format(
|
||||
ToolConstants.Plastic.GUI_MACOS_BREX_ARG,
|
||||
wkInfo.ClientPath),
|
||||
ToolConstants.Plastic.GUI_MACOS_COMMAND_FILE_ARG,
|
||||
ToolConstants.Plastic.GUI_MACOS_COMMAND_FILE,
|
||||
mPlasticProcessId);
|
||||
|
||||
if (plasticProcess != null)
|
||||
mPlasticProcessId = plasticProcess.Id;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Process brexProcess = processExecutor.ExecuteWindowsGUI(
|
||||
PlasticInstallPath.GetPlasticExePath(),
|
||||
string.Format(
|
||||
ToolConstants.Plastic.GUI_WINDOWS_BREX_ARG,
|
||||
wkInfo.ClientPath),
|
||||
mBrexProcessId);
|
||||
|
||||
if (brexProcess != null)
|
||||
mBrexProcessId = brexProcess.Id;
|
||||
}
|
||||
|
||||
internal static void OpenChangesetDiffs(
|
||||
IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
IProcessExecutor processExecutor,
|
||||
RepositorySpec repSpec,
|
||||
string fullChangesetSpec,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (showDownloadPlasticExeWindow.Show(
|
||||
repSpec,
|
||||
isGluonMode,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticCloudFromOpenChangesetDiffs,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromOpenChangesetDiffs,
|
||||
TrackFeatureUseEvent.Features.CancelPlasticInstallationFromOpenChangesetDiffs))
|
||||
return;
|
||||
|
||||
mLog.DebugFormat(
|
||||
"Launching changeset diffs for '{0}'",
|
||||
fullChangesetSpec);
|
||||
|
||||
string exePath = (isGluonMode) ?
|
||||
PlasticInstallPath.GetGluonExePath() :
|
||||
PlasticInstallPath.GetPlasticExePath();
|
||||
|
||||
string changesetDiffArg = (isGluonMode) ?
|
||||
ToolConstants.Gluon.GUI_CHANGESET_DIFF_ARG :
|
||||
ToolConstants.Plastic.GUI_CHANGESET_DIFF_ARG;
|
||||
|
||||
processExecutor.ExecuteProcess(exePath,
|
||||
string.Format(
|
||||
changesetDiffArg, fullChangesetSpec));
|
||||
}
|
||||
|
||||
internal static void OpenSelectedChangesetsDiffs(
|
||||
IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
IProcessExecutor processExecutor,
|
||||
RepositorySpec repSpec,
|
||||
string srcFullChangesetSpec,
|
||||
string dstFullChangesetSpec,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (showDownloadPlasticExeWindow.Show(
|
||||
repSpec,
|
||||
isGluonMode,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticCloudFromOpenSelectedChangesetsDiffs,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromOpenSelectedChangesetsDiffs,
|
||||
TrackFeatureUseEvent.Features.CancelPlasticInstallationFromOpenSelectedChangesetsDiffs))
|
||||
return;
|
||||
|
||||
mLog.DebugFormat(
|
||||
"Launching selected changesets diffs for '{0}' and '{1}'",
|
||||
srcFullChangesetSpec,
|
||||
dstFullChangesetSpec);
|
||||
|
||||
string exePath = (isGluonMode) ?
|
||||
PlasticInstallPath.GetGluonExePath() :
|
||||
PlasticInstallPath.GetPlasticExePath();
|
||||
|
||||
string selectedChangesetsDiffArgs = (isGluonMode) ?
|
||||
ToolConstants.Gluon.GUI_SELECTED_CHANGESETS_DIFF_ARGS :
|
||||
ToolConstants.Plastic.GUI_SELECTED_CHANGESETS_DIFF_ARGS;
|
||||
|
||||
processExecutor.ExecuteProcess(exePath,
|
||||
string.Format(
|
||||
selectedChangesetsDiffArgs,
|
||||
srcFullChangesetSpec,
|
||||
dstFullChangesetSpec));
|
||||
}
|
||||
|
||||
internal static void OpenBranchDiffs(
|
||||
IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
IProcessExecutor processExecutor,
|
||||
RepositorySpec repSpec,
|
||||
string fullBranchSpec,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (showDownloadPlasticExeWindow.Show(
|
||||
repSpec,
|
||||
isGluonMode,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticCloudFromOpenBranchDiff,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromOpenBranchDiff,
|
||||
TrackFeatureUseEvent.Features.CancelPlasticInstallationFromOpenBranchDiff))
|
||||
return;
|
||||
|
||||
mLog.DebugFormat(
|
||||
"Launching branch diffs for '{0}'",
|
||||
fullBranchSpec);
|
||||
|
||||
string exePath = (isGluonMode) ?
|
||||
PlasticInstallPath.GetGluonExePath() :
|
||||
PlasticInstallPath.GetPlasticExePath();
|
||||
|
||||
string branchDiffArg = (isGluonMode) ?
|
||||
ToolConstants.Gluon.GUI_BRANCH_DIFF_ARG :
|
||||
ToolConstants.Plastic.GUI_BRANCH_DIFF_ARG;
|
||||
|
||||
processExecutor.ExecuteProcess(exePath,
|
||||
string.Format(
|
||||
branchDiffArg, fullBranchSpec));
|
||||
}
|
||||
|
||||
internal static void OpenWorkspaceConfiguration(
|
||||
IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
IProcessExecutor processExecutor,
|
||||
WorkspaceInfo wkInfo,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (showDownloadPlasticExeWindow.Show(
|
||||
wkInfo,
|
||||
isGluonMode,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticCloudFromOpenWorkspaceConfiguration,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromOpenWorkspaceConfiguration,
|
||||
TrackFeatureUseEvent.Features.CancelPlasticInstallationFromOpenWorkspaceConfiguration))
|
||||
return;
|
||||
|
||||
mLog.DebugFormat(
|
||||
"Opening Workspace Configuration on wkPath '{0}'.",
|
||||
wkInfo.ClientPath);
|
||||
|
||||
TrackFeatureUseEvent.For(
|
||||
PlasticGui.Plastic.API.GetRepositorySpec(wkInfo),
|
||||
TrackFeatureUseEvent.Features.LaunchPartialConfigure);
|
||||
|
||||
Process gluonProcess = processExecutor.ExecuteGUI(
|
||||
PlasticInstallPath.GetGluonExePath(),
|
||||
string.Format(
|
||||
ToolConstants.Gluon.GUI_WK_CONFIGURATION_ARG,
|
||||
wkInfo.ClientPath),
|
||||
ToolConstants.Gluon.GUI_COMMAND_FILE_ARG,
|
||||
ToolConstants.Gluon.GUI_COMMAND_FILE,
|
||||
mGluonProcessId);
|
||||
|
||||
if (gluonProcess == null)
|
||||
return;
|
||||
|
||||
mGluonProcessId = gluonProcess.Id;
|
||||
}
|
||||
|
||||
internal static void OpenMerge(
|
||||
IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
IProcessExecutor processExecutor,
|
||||
WorkspaceInfo wkInfo,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (showDownloadPlasticExeWindow.Show(
|
||||
wkInfo,
|
||||
isGluonMode,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticCloudFromOpenMerge,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromOpenMerge,
|
||||
TrackFeatureUseEvent.Features.CancelPlasticInstallationFromOpenMerge))
|
||||
return;
|
||||
|
||||
mLog.DebugFormat(
|
||||
"Opening Merge on wkPath '{0}'.",
|
||||
wkInfo.ClientPath);
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
Process plasticProcess = processExecutor.ExecuteGUI(
|
||||
PlasticInstallPath.GetPlasticExePath(),
|
||||
string.Format(ToolConstants.Plastic.GUI_MACOS_MERGE_ARG, wkInfo.ClientPath),
|
||||
ToolConstants.Plastic.GUI_MACOS_COMMAND_FILE_ARG,
|
||||
ToolConstants.Plastic.GUI_MACOS_COMMAND_FILE,
|
||||
mPlasticProcessId);
|
||||
|
||||
if (plasticProcess != null)
|
||||
mPlasticProcessId = plasticProcess.Id;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
processExecutor.ExecuteProcess(
|
||||
PlasticInstallPath.GetPlasticExePath(),
|
||||
string.Format(ToolConstants.Plastic.GUI_WINDOWS_MERGE_ARG, wkInfo.ClientPath));
|
||||
}
|
||||
|
||||
static int mPlasticProcessId = -1;
|
||||
static int mGluonProcessId = -1;
|
||||
static int mBrexProcessId = -1;
|
||||
|
||||
static readonly ILog mLog = LogManager.GetLogger("LaunchTool");
|
||||
|
||||
internal class ShowDownloadPlasticExeWindow : LaunchTool.IShowDownloadPlasticExeWindow
|
||||
{
|
||||
bool LaunchTool.IShowDownloadPlasticExeWindow.Show(
|
||||
WorkspaceInfo wkInfo,
|
||||
bool isGluonMode,
|
||||
string installCloudFrom,
|
||||
string installEnterpriseFrom,
|
||||
string cancelInstallFrom)
|
||||
{
|
||||
RepositorySpec repSpec = PlasticGui.Plastic.API.GetRepositorySpec(wkInfo);
|
||||
|
||||
return ((LaunchTool.IShowDownloadPlasticExeWindow)this).Show(
|
||||
repSpec,
|
||||
isGluonMode,
|
||||
installCloudFrom,
|
||||
installEnterpriseFrom,
|
||||
cancelInstallFrom);
|
||||
}
|
||||
|
||||
bool LaunchTool.IShowDownloadPlasticExeWindow.Show(
|
||||
RepositorySpec repSpec,
|
||||
bool isGluonMode,
|
||||
string installCloudFrom,
|
||||
string installEnterpriseFrom,
|
||||
string cancelInstallFrom)
|
||||
{
|
||||
if (IsExeAvailable.ForMode(isGluonMode))
|
||||
return false;
|
||||
|
||||
DownloadPlasticExeWindow.ShowWindow(
|
||||
repSpec,
|
||||
isGluonMode,
|
||||
installCloudFrom,
|
||||
installEnterpriseFrom,
|
||||
cancelInstallFrom);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal class ProcessExecutor : LaunchTool.IProcessExecutor
|
||||
{
|
||||
Process LaunchTool.IProcessExecutor.ExecuteGUI(
|
||||
string program,
|
||||
string args,
|
||||
string commandFileArg,
|
||||
string commandFileName,
|
||||
int processId)
|
||||
{
|
||||
string commandFile = Path.Combine(
|
||||
Path.GetTempPath(), commandFileName);
|
||||
|
||||
Process process = GetGUIProcess(program, processId);
|
||||
|
||||
if (process == null)
|
||||
{
|
||||
mLog.DebugFormat("Executing {0} (new process).", program);
|
||||
|
||||
return ((LaunchTool.IProcessExecutor)this).ExecuteProcess(
|
||||
program, args + string.Format(commandFileArg, commandFile));
|
||||
}
|
||||
|
||||
mLog.DebugFormat("Executing {0} (reuse process pid:{1}).", program, processId);
|
||||
|
||||
using (StreamWriter writer = new StreamWriter(new FileStream(
|
||||
commandFile, FileMode.Append, FileAccess.Write, FileShare.Read)))
|
||||
{
|
||||
writer.WriteLine(args);
|
||||
}
|
||||
|
||||
return process;
|
||||
}
|
||||
|
||||
Process LaunchTool.IProcessExecutor.ExecuteWindowsGUI(
|
||||
string program,
|
||||
string args,
|
||||
int processId)
|
||||
{
|
||||
Process process = GetGUIProcess(program, processId);
|
||||
|
||||
if (process == null)
|
||||
{
|
||||
mLog.DebugFormat("Executing {0} (new process).", program);
|
||||
|
||||
return ((LaunchTool.IProcessExecutor)this).ExecuteProcess(program, args);
|
||||
}
|
||||
|
||||
mLog.DebugFormat("Not executing {0} (existing process pid:{1}).", program, processId);
|
||||
|
||||
BringWindowToFront.ForWindowsProcess(process.Id);
|
||||
|
||||
return process;
|
||||
}
|
||||
|
||||
Process LaunchTool.IProcessExecutor.ExecuteProcess(string program, string args)
|
||||
{
|
||||
mLog.DebugFormat("Execute process: '{0} {1}'", program, args);
|
||||
|
||||
Process process = BuildProcess(program, args);
|
||||
|
||||
try
|
||||
{
|
||||
process.Start();
|
||||
|
||||
return process;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mLog.ErrorFormat("Couldn't execute the program {0}: {1}",
|
||||
program, ex.Message);
|
||||
mLog.DebugFormat("Stack trace: {0}",
|
||||
ex.StackTrace);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Process BuildProcess(string program, string args)
|
||||
{
|
||||
Process result = new Process();
|
||||
result.StartInfo.FileName = program;
|
||||
result.StartInfo.Arguments = args;
|
||||
result.StartInfo.CreateNoWindow = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
Process GetGUIProcess(string program, int processId)
|
||||
{
|
||||
if (processId == -1)
|
||||
return null;
|
||||
|
||||
mLog.DebugFormat("Checking {0} process [pid:{1}].", program, processId);
|
||||
|
||||
try
|
||||
{
|
||||
Process process = Process.GetProcessById(processId);
|
||||
|
||||
if (process == null)
|
||||
return null;
|
||||
|
||||
return process.HasExited ? null : process;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// process is not running
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
readonly ILog mLog = LogManager.GetLogger("ProcessExecutor");
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/LaunchTool.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/LaunchTool.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a6d05b29e607e62478df26227566e1b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,53 @@
|
|||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class ToolConstants
|
||||
{
|
||||
internal static class Plastic
|
||||
{
|
||||
|
||||
internal const string GUI_CONFIGURE_ARG = "--configure";
|
||||
|
||||
internal const string GUI_WINDOWS_WK_ARG = "--wk=\"{0}\"";
|
||||
internal const string GUI_WINDOWS_BREX_ARG = "--branchexplorer=\"{0}\"";
|
||||
internal const string GUI_WINDOWS_MERGE_ARG = "--resolve=\"{0}\"";
|
||||
internal const string GUI_WINDOWS_INCOMING_CHANGES_ARG = "--resolve=\"{0}\" --incomingmerge";
|
||||
|
||||
internal const string GUI_MACOS_WK_EXPLORER_ARG = "--wk=\"{0}\" --view=ItemsView";
|
||||
internal const string GUI_MACOS_BREX_ARG = "--wk=\"{0}\" --view=BranchExplorerView";
|
||||
internal const string GUI_MACOS_MERGE_ARG = "--wk=\"{0}\" --view=MergeView";
|
||||
internal const string GUI_MACOS_INCOMING_CHANGES_ARG = "--wk=\"{0}\" --view=IncomingChangesView";
|
||||
internal const string GUI_MACOS_COMMAND_FILE_ARG = " --command-file=\"{0}\"";
|
||||
internal const string GUI_MACOS_COMMAND_FILE = "macplastic-command-file.txt";
|
||||
|
||||
internal const string GUI_CHANGESET_DIFF_ARG = "--diffchangeset=\"{0}\"";
|
||||
internal const string GUI_SELECTED_CHANGESETS_DIFF_ARGS = "--diffchangesetsrc=\"{0}\" --diffchangesetdst=\"{1}\"";
|
||||
internal const string GUI_BRANCH_DIFF_ARG = "--diffbranch=\"{0}\"";
|
||||
}
|
||||
|
||||
internal static class Gluon
|
||||
{
|
||||
|
||||
internal const string GUI_CONFIGURE_ARG = "--configure";
|
||||
|
||||
internal const string GUI_WK_EXPLORER_ARG = "--wk=\"{0}\" --view=WorkspaceExplorerView";
|
||||
internal const string GUI_WK_CONFIGURATION_ARG = "--wk=\"{0}\" --view=WorkspaceConfigurationView";
|
||||
internal const string GUI_WK_INCOMING_CHANGES_ARG = "--wk=\"{0}\" --view=IncomingChangesView";
|
||||
internal const string GUI_COMMAND_FILE_ARG = " --command-file=\"{0}\"";
|
||||
internal const string GUI_COMMAND_FILE = "gluon-command-file.txt";
|
||||
|
||||
internal const string GUI_CHANGESET_DIFF_ARG = "--diffchangeset=\"{0}\"";
|
||||
internal const string GUI_SELECTED_CHANGESETS_DIFF_ARGS = "--diffchangesetsrc=\"{0}\" --diffchangesetdst=\"{1}\"";
|
||||
internal const string GUI_BRANCH_DIFF_ARG = "--diffbranch=\"{0}\"";
|
||||
}
|
||||
|
||||
internal static class Installer
|
||||
{
|
||||
internal const string INSTALLER_WINDOWS_ARGS = "--mode unattended --unattendedmodeui minimal";
|
||||
internal const string INSTALLER_MACOS_OPEN = "open";
|
||||
internal const string INSTALLER_MACOS_OPEN_ARGS = "-W -n {0}";
|
||||
}
|
||||
|
||||
internal const string LEGACY_MACOS_BINDIR = "/Applications/PlasticSCM.app/Contents/MonoBundle";
|
||||
internal const string NEW_MACOS_BINDIR = "/Applications/PlasticSCM.app/Contents/MacOS";
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/ToolConstants.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.17.7/Editor/PlasticSCM/Tool/ToolConstants.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: de6e8913aefd69d4ca90a7216d225d3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue