Initial project commit

This commit is contained in:
2026-01-08 16:50:20 +00:00
commit f0c5a8b267
29596 changed files with 4861782 additions and 0 deletions

View File

@@ -0,0 +1,381 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Codice.Client.Common.WebApi;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.CloudDrive.Workspaces;
using Unity.PlasticSCM.Editor.AssetUtils;
using Unity.PlasticSCM.Editor.CloudDrive;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.PlasticSCM.Editor.AssetMenu.Dialogs
{
internal class AddToCloudDriveDialog :
PlasticDialog,
FillOrganizationsAndProjects.INotify,
FillCloudWorkspaces.IAddToCloudDriveDialog
{
protected override Rect DefaultRect
{
get
{
var baseRect = base.DefaultRect;
return new Rect(baseRect.x, baseRect.y, 600, 350);
}
}
internal static void ShowDialog(
string[] assetPaths,
IPlasticWebRestApi restApi,
IPlasticAPI plasticApi,
EditorWindow parentWindow)
{
AddToCloudDriveDialog dialog = Create(assetPaths, plasticApi);
dialog.InitializeProposedOrganizationProject(restApi);
FillOrganizationsAndProjects.LoadOrganizations(
restApi,
plasticApi,
dialog.mProgressControls,
dialog);
ResponseType dialogResult = dialog.RunModal(parentWindow);
if (dialogResult != ResponseType.Ok)
return;
CloudDriveWindow cloudDriveWindow = ShowWindow.CloudDrive();
cloudDriveWindow.CopyPaths(
dialog.mSelectedOrganization,
dialog.mSelectedProject,
dialog.mSelectedCloudDrive.WorkspaceInfo,
assetPaths,
dialog.mCloudDriveRelativePath);
}
protected override string GetTitle()
{
return PlasticLocalization.Name.AddToUnityCloudDriveTitle.GetString();
}
protected override string GetExplanation()
{
return PlasticLocalization.Name.AddToCloudDriveDescription.GetString();
}
protected override void DoComponentsArea()
{
bool isOperationRunning = mProgressControls.ProgressData.IsWaitingAsyncResult;
GUI.enabled = !isOperationRunning;
EntryBuilder.CreateComboBoxEntry(
PlasticLocalization.Name.OrganizationLabel.GetString(),
mSelectedOrganization,
mOrganizations,
OnOrganizationSelected,
ENTRY_WIDTH,
ENTRY_X);
GUILayout.Space(5);
if (CloudServer.IsUnityOrganization(mSelectedOrganization))
{
EntryBuilder.CreateComboBoxEntry(
PlasticLocalization.Name.ProjectLabel.GetString(),
mSelectedProject,
mProjects,
OnProjectSelected,
ENTRY_WIDTH,
ENTRY_X);
GUILayout.Space(5);
}
string selectedDriveName = mSelectedCloudDrive != null ?
mSelectedCloudDrive.RepositoryInfo.Name.GetLastPartFromSeparator('/') : string.Empty;
List<string> driveNames = mCloudDrives.Select(
workspace => workspace.RepositoryInfo.Name.GetLastPartFromSeparator('/')).ToList();
EntryBuilder.CreateComboBoxEntry(
PlasticLocalization.Name.CloudDriveLabel.GetString(),
selectedDriveName,
driveNames,
OnDriveSelected,
ENTRY_WIDTH,
ENTRY_X);
GUILayout.Space(10);
using (new EditorGUILayout.HorizontalScope())
{
mCloudDriveRelativePath = EntryBuilder.CreateTextEntry(
PlasticLocalization.Name.RelativePathLabel.GetString(),
mCloudDriveRelativePath,
ENTRY_WIDTH - BROWSE_BUTTON_WIDTH,
ENTRY_X);
Rect browseButtonRect = new Rect(
ENTRY_X + ENTRY_WIDTH - BROWSE_BUTTON_WIDTH + BUTTON_MARGIN,
GUILayoutUtility.GetLastRect().y,
BROWSE_BUTTON_WIDTH - BUTTON_MARGIN,
20);
if (GUI.Button(browseButtonRect, "..."))
DoBrowseForPath();
}
GUI.enabled = true;
}
void FillOrganizationsAndProjects.INotify.OrganizationsRetrieved(List<string> organizations)
{
mOrganizations = organizations;
mSelectedOrganization = GetDefaultValue(mProposedOrganization, mOrganizations);
if (mSelectedOrganization == null)
return;
OnOrganizationSelected(mSelectedOrganization);
Repaint();
}
void FillOrganizationsAndProjects.INotify.ProjectsRetrieved(List<string> projects)
{
mProjects = projects;
mSelectedProject = GetDefaultValue(mProposedProject, mProjects);
if (mSelectedProject == null)
return;
OnProjectSelected(mSelectedProject);
Repaint();
}
void FillCloudWorkspaces.IAddToCloudDriveDialog.CloudDrivesRetrieved(
List<CloudDriveWorkspace> workspaces)
{
mCloudDrives = workspaces;
if (mCloudDrives.Count > 0)
mSelectedCloudDrive = mCloudDrives[0];
Repaint();
}
static AddToCloudDriveDialog Create(string[] assetPaths, IPlasticAPI plasticApi)
{
var instance = CreateInstance<AddToCloudDriveDialog>();
instance.IsResizable = false;
instance.mPlasticApi = plasticApi;
instance.mCloudDriveRelativePath = GetProposedCloudDriveRelativePath(assetPaths);
instance.mEnterKeyAction = instance.OkButtonAction;
instance.mEscapeKeyAction = instance.CancelButtonAction;
return instance;
}
void OnOrganizationSelected(object organization)
{
mSelectedOrganization = organization != null ? organization.ToString() : null;
mProposedOrganization = mSelectedOrganization;
mSelectedProject = null;
mSelectedCloudDrive = null;
mProjects.Clear();
mCloudDrives.Clear();
if (!CloudServer.IsUnityOrganization(mSelectedOrganization))
{
OnProjectSelected(string.Empty);
return;
}
FillOrganizationsAndProjects.LoadProjects(
mSelectedOrganization, mPlasticApi, mProgressControls, this);
}
void OnProjectSelected(object project)
{
mSelectedProject = project != null ? project.ToString() : null;
mProposedProject = mSelectedProject;
mSelectedCloudDrive = null;
mCloudDrives.Clear();
if (string.IsNullOrEmpty(mSelectedOrganization))
return;
FillCloudWorkspaces.LoadWorkspaces(
mSelectedOrganization, mSelectedProject, this, mProgressControls);
}
void OnDriveSelected(object selectedDrive)
{
string driveName = selectedDrive != null ? selectedDrive.ToString() : null;
mSelectedCloudDrive = mCloudDrives.FirstOrDefault(
wkInfo =>
wkInfo.RepositoryInfo.Name.GetLastPartFromSeparator('/') == driveName);
Repaint();
}
void DoBrowseForPath()
{
if (mSelectedCloudDrive == null)
{
((IProgressControls)mProgressControls).ShowError(
PlasticLocalization.Name.SelectCloudDriveFirst.GetString());
return;
}
string workspacePath = AssetsPath.GetFullPath.ForPath(mSelectedCloudDrive.WorkspaceInfo.ClientPath);
string selectedPath = EditorUtility.SaveFolderPanel(
PlasticLocalization.Name.SelectDestinationPath.GetString(),
workspacePath,
"");
if (string.IsNullOrEmpty(selectedPath))
return;
string selectedFullPath = AssetsPath.GetFullPath.ForPath(selectedPath);
if (string.IsNullOrEmpty(selectedFullPath))
return;
if (!selectedFullPath.StartsWith(workspacePath))
{
((IProgressControls)mProgressControls).ShowError(
PlasticLocalization.Name.PathMustBeWithinWorkspace.GetString());
return;
}
((IProgressControls)mProgressControls).HideProgress();
if (selectedFullPath == workspacePath)
{
mCloudDriveRelativePath = "/";
return;
}
mCloudDriveRelativePath = selectedFullPath.Substring(workspacePath.Length).Replace('\\', '/');
}
protected override void DoOkButton()
{
bool isValid = mSelectedCloudDrive != null && mCloudDriveRelativePath.StartsWith("/");
if (!isValid || mProgressControls.ProgressData.IsWaitingAsyncResult)
GUI.enabled = false;
if (NormalButton(PlasticLocalization.Name.AddToCloudDriveButton.GetString()))
{
OkButtonAction();
}
GUI.enabled = true;
}
static string GetProposedCloudDriveRelativePath(string[] assetPaths)
{
if (assetPaths.Length == 0)
return string.Empty;
string commonRoot = Path.GetDirectoryName(
assetPaths[0].TrimEnd(
Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
for (int i = 1; i < assetPaths.Length; i++)
{
commonRoot = GetCommonRoot(
commonRoot,
Path.GetDirectoryName(
assetPaths[i].TrimEnd(
Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)));
}
return '/' + commonRoot.Replace('\\', '/');
}
static string GetCommonRoot(string path1, string path2)
{
string[] path1Parts = path1.Split(Path.DirectorySeparatorChar);
string[] path2Parts = path2.Split(Path.DirectorySeparatorChar);
int commonPartsCount = Mathf.Min(path1Parts.Length, path2Parts.Length);
for (int i = 0; i < commonPartsCount; i++)
{
if (path1Parts[i] != path2Parts[i])
{
commonPartsCount = i;
break;
}
}
return string.Join(
Path.DirectorySeparatorChar.ToString(),
path1Parts,
0,
commonPartsCount);
}
static string GetDefaultValue(string proposedValue, List<string> values)
{
if (values.Count == 0)
return null;
if (!string.IsNullOrEmpty(proposedValue) && values.Contains(proposedValue))
return proposedValue;
return values[0];
}
void InitializeProposedOrganizationProject(IPlasticWebRestApi restApi)
{
GetProposedOrganizationProject.Values proposedOrganizationProject =
GetProposedOrganizationProject.FromCloudProjectSettings();
mProposedOrganization = proposedOrganizationProject != null ?
proposedOrganizationProject.Organization :
GetDefaultServer.FromConfig(restApi);
mProposedProject = proposedOrganizationProject != null ?
proposedOrganizationProject.Project :
Application.productName;
}
List<string> mOrganizations = new List<string>();
List<string> mProjects = new List<string>();
List<CloudDriveWorkspace> mCloudDrives = new List<CloudDriveWorkspace>();
string mProposedOrganization;
string mProposedProject;
string mSelectedOrganization;
string mSelectedProject;
CloudDriveWorkspace mSelectedCloudDrive;
string mCloudDriveRelativePath;
IPlasticAPI mPlasticApi;
const float ENTRY_WIDTH = 400;
const float ENTRY_X = 120f;
const float BROWSE_BUTTON_WIDTH = 30;
const float BUTTON_MARGIN = 5;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c8d9f1a2b3e4f5a6b7c8d9e0f1a2b3c4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,391 @@
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using Codice.Client.Common;
using Codice.Client.Common.EventTracking;
using Codice.CM.Common;
using GluonGui;
using PlasticGui;
using PlasticGui.Gluon;
using PlasticGui.WorkspaceWindow;
using Unity.PlasticSCM.Editor.AssetsOverlays;
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
using Unity.PlasticSCM.Editor.AssetUtils;
using Unity.PlasticSCM.Editor.AssetUtils.Processor;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.Tree;
#if !UNITY_6000_0_OR_NEWER
using EditorGUI = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.EditorGUI;
#endif
namespace Unity.PlasticSCM.Editor.AssetMenu.Dialogs
{
internal class CheckinDialog : PlasticDialog
{
protected override Rect DefaultRect
{
get
{
var baseRect = base.DefaultRect;
return new Rect(baseRect.x, baseRect.y, 700, 450);
}
}
protected override string GetTitle()
{
return PlasticLocalization.GetString(
PlasticLocalization.Name.CheckinChanges);
}
internal static bool CheckinPaths(
WorkspaceInfo wkInfo,
List<string> paths,
IAssetStatusCache assetStatusCache,
bool isGluonMode,
IWorkspaceWindow workspaceWindow,
ViewHost viewHost,
WorkspaceOperationsMonitor workspaceOperationsMonitor,
IPendingChangesUpdater pendingChangesUpdater,
ISaveAssets saveAssets,
GuiMessage.IGuiMessage guiMessage,
IMergeViewLauncher mergeViewLauncher,
IGluonViewSwitcher gluonViewSwitcher)
{
MetaCache metaCache = new MetaCache();
metaCache.Build(paths);
CheckinDialog dialog = Create(
wkInfo,
paths,
assetStatusCache,
metaCache,
isGluonMode,
workspaceWindow,
viewHost,
workspaceOperationsMonitor,
pendingChangesUpdater,
saveAssets,
guiMessage,
mergeViewLauncher,
gluonViewSwitcher);
return dialog.RunModal(focusedWindow) == ResponseType.Ok;
}
protected override void DoComponentsArea()
{
Title(PlasticLocalization.GetString(PlasticLocalization.Name.CheckinOnlyComment));
Rect commentRect = GUILayoutUtility.GetRect(
new GUIContent(string.Empty),
EditorStyles.textArea,
GUILayout.MinHeight(120),
GUILayout.ExpandWidth(true));
GUI.SetNextControlName(CHECKIN_TEXTAREA_NAME);
mComment = EditorGUI.ScrollableTextAreaInternal(
commentRect,
mComment,
ref mScrollPosition,
EditorStyles.textArea);
if (!mTextAreaFocused)
{
UnityEditor.EditorGUI.FocusTextInControl(CHECKIN_TEXTAREA_NAME);
mTextAreaFocused = true;
}
Title(PlasticLocalization.GetString(PlasticLocalization.Name.Files));
DoFileList(
mWkInfo,
mPaths,
mAssetStatusCache,
mMetaCache);
}
void DoFileList(
WorkspaceInfo wkInfo,
List<string> paths,
IAssetStatusCache assetStatusCache,
MetaCache metaCache)
{
mFileListScrollPosition = GUILayout.BeginScrollView(
mFileListScrollPosition,
EditorStyles.helpBox,
GUILayout.ExpandHeight(true));
foreach (string path in paths)
{
if (MetaPath.IsMetaPath(path))
continue;
Texture fileIcon = Directory.Exists(path) ?
Images.GetFolderIcon() :
Images.GetFileIcon(path);
string label = WorkspacePath.GetWorkspaceRelativePath(
wkInfo.ClientPath, path);
if (metaCache.HasMeta(path))
label = string.Concat(label, UnityConstants.TREEVIEW_META_LABEL);
AssetsOverlays.AssetStatus assetStatus =
assetStatusCache.GetStatus(path);
Rect selectionRect = EditorGUILayout.GetControlRect(
true,
UnityConstants.TREEVIEW_ROW_HEIGHT);
DoListViewItem(selectionRect, fileIcon, label, assetStatus);
}
GUILayout.EndScrollView();
}
void DoListViewItem(
Rect itemRect,
Texture fileIcon,
string label,
AssetsOverlays.AssetStatus statusToDraw)
{
int iconPadding = 2;
Texture overlayIcon = DrawAssetOverlayIcon.GetOverlayIcon(statusToDraw);
itemRect = DrawTreeViewItem.DrawIconLeft(
itemRect,
itemRect.height - 2 * iconPadding,
fileIcon,
null,
overlayIcon);
GUI.Label(itemRect, label);
}
internal override void OkButtonAction()
{
if (!IsCheckinButtonEnabled())
return;
bool isCancelled;
mSaveAssets.ForPathsWithConfirmation(
mWkInfo.ClientPath, mPaths, mWorkspaceOperationsMonitor,
out isCancelled);
if (isCancelled)
return;
mIsRunningCheckin = true;
mPaths.AddRange(mMetaCache.GetExistingMeta(mPaths));
if (mIsGluonMode)
{
CheckinDialogOperations.CheckinPathsPartial(
mWkInfo,
mPaths,
mComment,
mViewHost,
this,
mGuiMessage,
mProgressControls,
mGluonViewSwitcher,
mPendingChangesUpdater);
return;
}
CheckinDialogOperations.CheckinPaths(
mWkInfo,
mPaths,
mComment,
mWorkspaceWindow,
this,
mGuiMessage,
mProgressControls,
mMergeViewLauncher,
mPendingChangesUpdater);
}
protected override void DoOkButton()
{
GUI.enabled = IsCheckinButtonEnabled();
try
{
if (!NormalButton(PlasticLocalization.GetString(
PlasticLocalization.Name.CheckinButton)))
return;
}
finally
{
if (!mSentCheckinTrackEvent)
{
TrackFeatureUseEvent.For(
PlasticGui.Plastic.API.GetRepositorySpec(mWkInfo),
TrackFeatureUseEvent.Features.UnityPackage.ContextMenuCheckinDialogCheckin);
mSentCheckinTrackEvent = true;
}
GUI.enabled = true;
}
OkButtonAction();
}
internal override void CancelButtonAction()
{
if (!mSentCancelTrackEvent)
{
TrackFeatureUseEvent.For(
PlasticGui.Plastic.API.GetRepositorySpec(mWkInfo),
TrackFeatureUseEvent.Features.UnityPackage.ContextMenuCheckinDialogCancel);
mSentCancelTrackEvent = true;
}
base.CancelButtonAction();
}
bool IsCheckinButtonEnabled()
{
return !string.IsNullOrEmpty(mComment) && !mIsRunningCheckin;
}
static CheckinDialog Create(
WorkspaceInfo wkInfo,
List<string> paths,
IAssetStatusCache assetStatusCache,
MetaCache metaCache,
bool isGluonMode,
IWorkspaceWindow workspaceWindow,
ViewHost viewHost,
WorkspaceOperationsMonitor workspaceOperationsMonitor,
IPendingChangesUpdater pendingChangesUpdater,
ISaveAssets saveAssets,
GuiMessage.IGuiMessage guiMessage,
IMergeViewLauncher mergeViewLauncher,
IGluonViewSwitcher gluonViewSwitcher)
{
var instance = CreateInstance<CheckinDialog>();
instance.IsResizable = true;
instance.minSize = new Vector2(520, 370);
instance.mWkInfo = wkInfo;
instance.mPaths = paths;
instance.mAssetStatusCache = assetStatusCache;
instance.mMetaCache = metaCache;
instance.mIsGluonMode = isGluonMode;
instance.mWorkspaceWindow = workspaceWindow;
instance.mViewHost = viewHost;
instance.mWorkspaceOperationsMonitor = workspaceOperationsMonitor;
instance.mPendingChangesUpdater = pendingChangesUpdater;
instance.mSaveAssets = saveAssets;
instance.mGuiMessage = guiMessage;
instance.mMergeViewLauncher = mergeViewLauncher;
instance.mGluonViewSwitcher = gluonViewSwitcher;
instance.mEnterKeyAction = instance.OkButtonAction;
instance.AddControlConsumingEnterKey(CHECKIN_TEXTAREA_NAME);
instance.mEscapeKeyAction = instance.CancelButtonAction;
return instance;
}
WorkspaceInfo mWkInfo;
List<string> mPaths;
IAssetStatusCache mAssetStatusCache;
MetaCache mMetaCache;
bool mIsGluonMode;
bool mTextAreaFocused;
string mComment;
bool mIsRunningCheckin;
Vector2 mFileListScrollPosition;
// IMGUI evaluates every frame, need to make sure feature tracks get sent only once
bool mSentCheckinTrackEvent = false;
bool mSentCancelTrackEvent = false;
IWorkspaceWindow mWorkspaceWindow;
WorkspaceOperationsMonitor mWorkspaceOperationsMonitor;
IPendingChangesUpdater mPendingChangesUpdater;
ISaveAssets mSaveAssets;
ViewHost mViewHost;
IMergeViewLauncher mMergeViewLauncher;
IGluonViewSwitcher mGluonViewSwitcher;
GuiMessage.IGuiMessage mGuiMessage;
const string CHECKIN_TEXTAREA_NAME = "checkin_textarea";
Vector2 mScrollPosition;
class MetaCache
{
internal bool HasMeta(string path)
{
return mCache.Contains(MetaPath.GetMetaPath(path));
}
internal List<string> GetExistingMeta(List<string> paths)
{
List<string> result = new List<string>();
foreach (string path in paths)
{
string metaPath = MetaPath.GetMetaPath(path);
if (!mCache.Contains(metaPath))
continue;
result.Add(metaPath);
}
return result;
}
internal void Build(List<string> paths)
{
HashSet<string> indexedKeys = BuildIndexedKeys(paths);
for (int i = paths.Count - 1; i >= 0; i--)
{
string currentPath = paths[i];
if (!MetaPath.IsMetaPath(currentPath))
continue;
string realPath = MetaPath.GetPathFromMetaPath(currentPath);
if (!indexedKeys.Contains(realPath))
continue;
// found foo.c and foo.c.meta
// with the same chage types - move .meta to cache
mCache.Add(currentPath);
paths.RemoveAt(i);
}
}
static HashSet<string> BuildIndexedKeys(List<string> paths)
{
HashSet<string> result = new HashSet<string>();
foreach (string path in paths)
{
if (MetaPath.IsMetaPath(path))
continue;
result.Add(path);
}
return result;
}
HashSet<string> mCache = new HashSet<string>();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 678db227e4ffec949980d309c0532b08
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
using Codice.Client.BaseCommands;
using Codice.Client.Commands;
using Codice.Client.Commands.CheckIn;
using Codice.Client.Common;
using Codice.Client.Common.Threading;
using Codice.CM.Common;
using Codice.CM.Common.Checkin.Partial;
using GluonGui;
using PlasticGui;
using PlasticGui.Gluon;
using PlasticGui.WorkspaceWindow;
using PlasticGui.WorkspaceWindow.PendingChanges;
namespace Unity.PlasticSCM.Editor.AssetMenu.Dialogs
{
internal static class CheckinDialogOperations
{
internal static void CheckinPaths(
WorkspaceInfo wkInfo,
List<string> paths,
string comment,
IWorkspaceWindow workspaceWindow,
CheckinDialog dialog,
GuiMessage.IGuiMessage guiMessage,
IProgressControls progressControls,
IMergeViewLauncher mergeViewLauncher,
IPendingChangesUpdater pendingChangesUpdater)
{
BaseCommandsImpl baseCommands = new BaseCommandsImpl();
progressControls.ShowProgress("Checkin in files");
IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);
waiter.Execute(
/*threadOperationDelegate*/ delegate
{
ApplyLocalChanges(wkInfo, paths);
CheckinParams ciParams = new CheckinParams();
ciParams.paths = paths.ToArray();
ciParams.comment = comment;
ciParams.time = DateTime.MinValue;
ciParams.flags = CheckinFlags.Recurse | CheckinFlags.ProcessSymlinks;
baseCommands.CheckIn(wkInfo, ciParams);
},
/*afterOperationDelegate*/ delegate
{
progressControls.HideProgress();
((IPlasticDialogCloser)dialog).CloseDialog();
if (waiter.Exception is CmClientMergeNeededException)
{
// we need to explicitly call EditorWindow.Close() to ensure
// that the dialog is closed before asking the user
dialog.Close();
if (!UserWantsToShowIncomingView(guiMessage))
return;
ShowIncomingChanges.FromCheckin(
wkInfo,
mergeViewLauncher,
progressControls);
return;
}
if (waiter.Exception != null)
{
ExceptionsHandler.DisplayException(waiter.Exception);
return;
}
if (pendingChangesUpdater != null)
pendingChangesUpdater.Update(DateTime.Now);
workspaceWindow.RefreshView(ViewType.HistoryView);
workspaceWindow.RefreshView(ViewType.BranchesView);
workspaceWindow.RefreshView(ViewType.ChangesetsView);
workspaceWindow.RefreshView(ViewType.LocksView);
});
}
internal static void CheckinPathsPartial(
WorkspaceInfo wkInfo,
List<string> paths,
string comment,
ViewHost viewHost,
CheckinDialog dialog,
GuiMessage.IGuiMessage guiMessage,
IProgressControls progressControls,
IGluonViewSwitcher gluonViewSwitcher,
IPendingChangesUpdater pendingChangesUpdater)
{
BaseCommandsImpl baseCommands = new BaseCommandsImpl();
progressControls.ShowProgress(PlasticLocalization.GetString(
PlasticLocalization.Name.CheckinInFilesProgress));
IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);
waiter.Execute(
/*threadOperationDelegate*/ delegate
{
ApplyLocalChanges(wkInfo, paths);
baseCommands.PartialCheckin(wkInfo, paths, comment);
},
/*afterOperationDelegate*/ delegate
{
progressControls.HideProgress();
((IPlasticDialogCloser)dialog).CloseDialog();
if (waiter.Exception is CheckinConflictsException)
{
// we need to explicitly call EditorWindow.Close() to ensure
// that the dialog is closed before asking the user
dialog.Close();
if (!UserWantsToShowIncomingView(guiMessage))
return;
gluonViewSwitcher.ShowIncomingChangesView();
return;
}
if (waiter.Exception != null)
{
ExceptionsHandler.DisplayException(waiter.Exception);
return;
}
if (pendingChangesUpdater != null)
pendingChangesUpdater.Update(DateTime.Now);
viewHost.RefreshView(ViewType.HistoryView);
viewHost.RefreshView(ViewType.LocksView);
});
}
static bool UserWantsToShowIncomingView(GuiMessage.IGuiMessage guiMessage)
{
GuiMessage.GuiMessageResponseButton result = guiMessage.ShowQuestion(
PlasticLocalization.GetString(PlasticLocalization.Name.CheckinConflictsTitle),
PlasticLocalization.GetString(PlasticLocalization.Name.UnityCheckinConflictsExplanation),
PlasticLocalization.GetString(PlasticLocalization.Name.CheckinShowIncomingChangesView),
PlasticLocalization.GetString(PlasticLocalization.Name.CancelButton),
null);
return result == GuiMessage.GuiMessageResponseButton.Positive;
}
static void ApplyLocalChanges(WorkspaceInfo wkInfo, List<string> paths)
{
ApplyLocalChangesOptions options = new ApplyLocalChangesOptions();
options.bIncludeDependencies = true;
options.MatchingOptions = new MovedMatchingOptions();
options.TypesToApply =
ChangeTypes.Changed |
ChangeTypes.Private |
ChangeTypes.LocallyDeleted |
ChangeTypes.LocallyMoved;
options.Operation = DependenciesOperation.Checkin;
options.bProcessSymlinks = true;
ApplyChanges.Apply(wkInfo, paths, options, null, out _, out _);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c44a2ac668da0a04d9e567739215b2eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: